Rev 1233 | 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(¤t->deadline)); |
||
45 | hard_task_def_wcet(ht,TIMESPEC2USEC(¤t->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(¤t->deadline)); |
||
56 | hard_task_def_wcet(ht,TIMESPEC2USEC(¤t->wcet)); |
||
57 | hard_task_def_ctrl_jet(ht); |
||
58 | hard_task_def_usemath(ht); |
||
59 | return &ht; |
||
60 | } |
||
1234 | giacomo | 61 | |
62 | return NULL; |
||
1232 | giacomo | 63 | |
64 | } |
||
65 | |||
66 | void set_simulation_time (struct timespec *total) { |
||
67 | struct timespec end_time; |
||
68 | |||
69 | ADDTIMESPEC(&zero_time,total,&end_time); |
||
70 | kern_event_post(&end_time,(void *)((void *)(sys_end)),NULL); |
||
71 | |||
72 | } |
||
73 | |||
74 | void set_next_activation(struct timespec *next) { |
||
75 | struct timespec end_time; |
||
76 | ADDTIMESPEC(&zero_time,next,&end_time); |
||
77 | kern_event_post(&end_time,(void *)((void *)(task_activate(exec_shadow))),NULL); |
||
78 | } |
||
1233 | giacomo | 79 | |
80 | int calibration_func() { |
||
81 | return kern_gettime(NULL); |
||
82 | |||
83 | } |