Rev 1234 | Rev 1236 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1232 | giacomo | 1 | #include <kernel/kern.h> |
2 | |||
3 | #include "fsf_contract.h" |
||
4 | #include "fsf_server.h" |
||
1233 | giacomo | 5 | #include "func.h" |
1232 | giacomo | 6 | #include "event_header.h" |
7 | |||
8 | /* Activate task output */ |
||
9 | #define TASK_OUTPUT |
||
10 | |||
1233 | giacomo | 11 | int cal_cycles=0; |
12 | struct timespec zero_time; |
||
1232 | giacomo | 13 | |
14 | /* Soft and hard Task */ |
||
15 | TASK test_task(void *arg) |
||
16 | { |
||
17 | long long i,exec_cycles = 0; |
||
18 | int act = 0; |
||
1234 | giacomo | 19 | struct loader_task *l = (struct loader_task *)(arg); |
1232 | giacomo | 20 | char tmp[20]; |
21 | |||
1234 | giacomo | 22 | while((l->act_number) > act) { |
1232 | giacomo | 23 | |
24 | #ifdef TASK_OUTPUT |
||
25 | sprintf(tmp,"X[%06d]",act); |
||
26 | printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
||
27 | #endif |
||
28 | |||
1235 | giacomo | 29 | if (l->act_number > act+1) generic_set_next_activation(&l->act[act+1]); |
1232 | giacomo | 30 | |
1233 | giacomo | 31 | exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles; |
1232 | giacomo | 32 | |
1234 | giacomo | 33 | #ifdef TASK_OUTPUT |
34 | sprintf(tmp,"X[%06d]",act); |
||
35 | printf_xy((get_current_exec_task() % 5) * 9 + 34, get_current_exec_task() / 5 + 5, GREEN, tmp); |
||
36 | #endif |
||
37 | |||
1232 | giacomo | 38 | for (i=0;i<exec_cycles;i++) calibration_func(); |
39 | |||
1234 | giacomo | 40 | generic_task_endcycle(); |
1235 | giacomo | 41 | |
42 | act++; |
||
43 | |||
1232 | giacomo | 44 | } |
45 | |||
46 | return NULL; |
||
47 | |||
48 | } |
||
49 | |||
50 | /* Task create */ |
||
1234 | giacomo | 51 | void loader_task_create() |
1232 | giacomo | 52 | { |
53 | |||
1234 | giacomo | 54 | struct loader_task *current = loader_task_list; |
55 | int i=0, k=0, total_task; |
||
1232 | giacomo | 56 | int total_group = 0; |
57 | |||
1233 | giacomo | 58 | total_task = sizeof(loader_task_list)/sizeof(struct loader_task); |
1232 | giacomo | 59 | |
1235 | giacomo | 60 | cprintf("Created 1 %d loader tasks\n",total_task); |
61 | |||
1234 | giacomo | 62 | while (k < total_task) { |
1232 | giacomo | 63 | k++; |
64 | total_group++; |
||
65 | current->group = total_group; |
||
66 | |||
67 | for (i=0; i < current->number; i++) { |
||
68 | |||
69 | pthread_t j; |
||
70 | int err; |
||
71 | |||
72 | err = generic_create_thread(current->server,&j,NULL,test_task,(void *)current,generic_get_task_model(current)); |
||
73 | if (err) { |
||
74 | cprintf("Error fsf task creating\n"); |
||
75 | sys_end(); |
||
76 | } |
||
77 | |||
78 | } |
||
79 | |||
1234 | giacomo | 80 | current = &loader_task_list[k]; |
81 | |||
1232 | giacomo | 82 | } |
83 | |||
1234 | giacomo | 84 | cprintf("Created %d loader tasks\n",total_task); |
85 | |||
1232 | giacomo | 86 | |
87 | } |
||
88 | |||
89 | |||
90 | int main() |
||
91 | { |
||
92 | |||
1234 | giacomo | 93 | struct timespec total = {20,0}; |
1233 | giacomo | 94 | |
1232 | giacomo | 95 | generic_calibrate_cycle(); |
1234 | giacomo | 96 | |
1233 | giacomo | 97 | kern_gettime(&zero_time); |
1232 | giacomo | 98 | |
99 | generic_fsfinit(); |
||
100 | |||
1234 | giacomo | 101 | loader_task_create(); |
1232 | giacomo | 102 | |
1233 | giacomo | 103 | generic_set_simulation_time(&total); |
1232 | giacomo | 104 | |
105 | return 0; |
||
106 | |||
107 | } |