Rev 1234 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1233 | giacomo | 1 | #include "func.h" |
1232 | giacomo | 2 | |
1239 | giacomo | 3 | extern int cal_cycles; |
4 | extern struct timespec zero_time; |
||
5 | extern struct loader_task *loader_task_list; |
||
1233 | giacomo | 6 | |
1232 | giacomo | 7 | /* Delay Calibration */ |
8 | int calibrate_cycle() |
||
9 | { |
||
10 | long long i; |
||
11 | struct timespec start,end,diff; |
||
12 | |||
13 | kern_cli(); |
||
14 | kern_gettime(&start); |
||
15 | for (i=0;i<CALIBRATION_DELTA;i++) kern_gettime(NULL); |
||
16 | kern_gettime(&end); |
||
17 | kern_sti(); |
||
18 | |||
19 | SUBTIMESPEC(&end,&start,&diff); |
||
20 | cal_cycles = TIMESPEC2USEC(&diff); |
||
21 | cprintf("Calibration usec/[%d cycles] = %d\n",CALIBRATION_DELTA,cal_cycles); |
||
22 | |||
23 | return 0; |
||
24 | |||
25 | } |
||
26 | |||
1233 | giacomo | 27 | void *get_task_model(struct loader_task *current) { |
1239 | giacomo | 28 | if (current->local_scheduler == PAR_POSIX) { |
1232 | giacomo | 29 | static NRT_TASK_MODEL nrt; |
30 | |||
31 | nrt_task_default_model(nrt); |
||
32 | nrt_task_def_save_arrivals(nrt); |
||
33 | nrt_task_def_ctrl_jet(nrt); |
||
34 | nrt_task_def_usemath(nrt); |
||
35 | |||
36 | return &nrt; |
||
37 | |||
38 | } |
||
39 | |||
1239 | giacomo | 40 | if (current->local_scheduler == PAR_EDF) { |
1232 | giacomo | 41 | static HARD_TASK_MODEL ht; |
42 | |||
43 | hard_task_default_model(ht); |
||
44 | hard_task_def_ctrl_jet(ht); |
||
45 | hard_task_def_mit(ht,TIMESPEC2USEC(¤t->deadline)); |
||
46 | hard_task_def_wcet(ht,TIMESPEC2USEC(¤t->wcet)); |
||
47 | hard_task_def_usemath(ht); |
||
48 | return &ht; |
||
49 | } |
||
50 | |||
51 | |||
1239 | giacomo | 52 | if (current->local_scheduler == PAR_RM) { |
1232 | giacomo | 53 | static HARD_TASK_MODEL ht; |
54 | |||
55 | hard_task_default_model(ht); |
||
56 | hard_task_def_mit(ht,TIMESPEC2USEC(¤t->deadline)); |
||
57 | hard_task_def_wcet(ht,TIMESPEC2USEC(¤t->wcet)); |
||
58 | hard_task_def_ctrl_jet(ht); |
||
59 | hard_task_def_usemath(ht); |
||
60 | return &ht; |
||
61 | } |
||
1234 | giacomo | 62 | |
63 | return NULL; |
||
1232 | giacomo | 64 | |
65 | } |
||
66 | |||
67 | void set_simulation_time (struct timespec *total) { |
||
68 | struct timespec end_time; |
||
69 | |||
70 | ADDTIMESPEC(&zero_time,total,&end_time); |
||
71 | kern_event_post(&end_time,(void *)((void *)(sys_end)),NULL); |
||
72 | |||
73 | } |
||
74 | |||
1239 | giacomo | 75 | int calibration_func() { |
76 | return kern_gettime(NULL); |
||
77 | |||
78 | } |
||
79 | |||
80 | void start_simulation() { |
||
81 | |||
82 | int i, total_task; |
||
83 | struct loader_task *l; |
||
1232 | giacomo | 84 | struct timespec end_time; |
1239 | giacomo | 85 | |
86 | total_task = sizeof(loader_task_list)/sizeof(struct loader_task); |
||
87 | i = 0; |
||
88 | |||
89 | while (i<total_task) { |
||
90 | if (l->act_number>0) { |
||
91 | ADDTIMESPEC(&zero_time, &l->act[0], &end_time); |
||
92 | l->act_current++; |
||
93 | kern_event_post(&end_time,loader_task_activate,&l); |
||
94 | i++; |
||
95 | l=&loader_task_list[i]; |
||
96 | } |
||
97 | |||
98 | } |
||
99 | |||
1232 | giacomo | 100 | } |
1233 | giacomo | 101 | |
102 | |||
1239 | giacomo | 103 | void loader_task_activate(struct loader_task *l) { |
104 | |||
105 | struct timespec actual_time,end_time; |
||
106 | |||
107 | kern_gettime(&actual_time); |
||
108 | group_activate(l->group); |
||
109 | |||
110 | if (l->act_number > l->act_current) { |
||
111 | |||
112 | ADDTIMESPEC(&actual_time, &l->act[l->act_current], &end_time); |
||
113 | |||
114 | l->act_current++; |
||
115 | kern_event_post(&end_time,loader_task_activate,&l); |
||
116 | |||
117 | } |
||
118 | |||
1233 | giacomo | 119 | } |