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