Subversion Repositories shark

Rev

Rev 1232 | Rev 1234 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1233 giacomo 1
#include <kernel/kern.h>
2
#include "func.h"
1232 giacomo 3
 
1233 giacomo 4
 
5
 
1232 giacomo 6
/* Delay Calibration */
7
int calibrate_cycle()
8
{
9
  long long i;
10
  struct timespec start,end,diff;
11
 
12
  kern_cli();
13
  kern_gettime(&start);
14
  for (i=0;i<CALIBRATION_DELTA;i++) kern_gettime(NULL);
15
  kern_gettime(&end);
16
  kern_sti();
17
 
18
  SUBTIMESPEC(&end,&start,&diff);
19
  cal_cycles = TIMESPEC2USEC(&diff);
20
  cprintf("Calibration usec/[%d cycles] = %d\n",CALIBRATION_DELTA,cal_cycles);
21
 
22
  return 0;
23
 
24
}
25
 
1233 giacomo 26
void *get_task_model(struct loader_task *current) {
1232 giacomo 27
  if (current->local_scheduler == LOADER_POSIX_SCHEDULER) {
28
    static NRT_TASK_MODEL nrt;
29
 
30
    nrt_task_default_model(nrt);
31
    nrt_task_def_save_arrivals(nrt);
32
    nrt_task_def_ctrl_jet(nrt);
33
    nrt_task_def_usemath(nrt);
34
 
35
    return &nrt;
36
 
37
  }  
38
 
39
  if (current->local_scheduler == LOADER_EDF_SCHEDULER) {
40
    static HARD_TASK_MODEL ht;
41
 
42
    hard_task_default_model(ht);
43
    hard_task_def_ctrl_jet(ht);          
44
    hard_task_def_mit(ht,TIMESPEC2USEC(&current->deadline));
45
    hard_task_def_wcet(ht,TIMESPEC2USEC(&current->wcet));
46
    hard_task_def_usemath(ht);
47
    return &ht;
48
  }  
49
 
50
 
51
  if (current->local_scheduler == LOADER_RM_SCHEDULER) {
52
    static HARD_TASK_MODEL ht;
53
 
54
    hard_task_default_model(ht);
55
    hard_task_def_mit(ht,TIMESPEC2USEC(&current->deadline));
56
    hard_task_def_wcet(ht,TIMESPEC2USEC(&current->wcet));
57
    hard_task_def_ctrl_jet(ht);
58
    hard_task_def_usemath(ht);
59
    return &ht;
60
  }  
61
 
62
}  
63
 
64
void set_simulation_time (struct timespec *total) {
65
  struct timespec end_time;
66
  kern_gettime(&zero_time);
67
 
68
  ADDTIMESPEC(&zero_time,total,&end_time);
69
  kern_event_post(&end_time,(void *)((void *)(sys_end)),NULL);
70
 
71
}
72
 
73
void set_next_activation(struct timespec *next) {
74
  struct timespec end_time;
75
 ADDTIMESPEC(&zero_time,next,&end_time);
76
 kern_event_post(&end_time,(void *)((void *)(task_activate(exec_shadow))),NULL);
77
}
1233 giacomo 78
 
79
int calibration_func() {
80
  return kern_gettime(NULL);
81
 
82
}