Rev 1629 | Rev 1631 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1627 | giacomo | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Giacomo Guidi <giacomo@gandalf.sssup.ti> |
||
10 | * |
||
11 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
12 | * |
||
13 | * http://www.sssup.it |
||
14 | * http://retis.sssup.it |
||
15 | * http://shark.sssup.it |
||
16 | */ |
||
17 | |||
18 | /* |
||
19 | * This program is free software; you can redistribute it and/or modify |
||
20 | * it under the terms of the GNU General Public License as published by |
||
21 | * the Free Software Foundation; either version 2 of the License, or |
||
22 | * (at your option) any later version. |
||
23 | * |
||
24 | * This program is distributed in the hope that it will be useful, |
||
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
27 | * GNU General Public License for more details. |
||
28 | * |
||
29 | * You should have received a copy of the GNU General Public License |
||
30 | * along with this program; if not, write to the Free Software |
||
31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
32 | */ |
||
33 | |||
34 | #include "kernel/kern.h" |
||
35 | |||
36 | TASK elastic_test(void *arg) { |
||
37 | |||
1629 | anton | 38 | int nbr = (int)arg; |
39 | |||
1627 | giacomo | 40 | while(1) { |
1629 | anton | 41 | cprintf("%d.", nbr); |
1627 | giacomo | 42 | task_endcycle(); |
43 | } |
||
44 | } |
||
45 | |||
46 | int main(int argc, char **argv) |
||
47 | { |
||
1630 | anton | 48 | ELASTIC_TASK_MODEL e1, e2, e3, e4; |
49 | PID el_pid1, el_pid2, el_pid3, el_pid4; |
||
1627 | giacomo | 50 | |
1630 | anton | 51 | cprintf("Elastic Task Demo (U=1.0 in initfile.c)\n"); |
1627 | giacomo | 52 | |
1630 | anton | 53 | cprintf("Creating elastic task with Tmin = 100000, Tmax = 500000, C = 30000, E = 1\n"); |
1629 | anton | 54 | elastic_task_default_model(e1); |
1630 | anton | 55 | elastic_task_def_period(e1, 100000, 500000); |
56 | elastic_task_def_wcet(e1, 30000); |
||
57 | elastic_task_def_param(e1, 1, PERIOD_SCALING); |
||
1629 | anton | 58 | elastic_task_def_arg(e1, (void *)1); |
59 | el_pid1 = task_create("Elastic1",elastic_test,&e1,NULL); |
||
60 | if (el_pid1 == NIL) { |
||
61 | cprintf("ERROR: Cannot create Elastic1\n"); |
||
1627 | giacomo | 62 | sys_end(); |
63 | } |
||
1629 | anton | 64 | task_activate(el_pid1); |
1627 | giacomo | 65 | |
1630 | anton | 66 | cprintf("\nCreating elastic task with Tmin = 200000, Tmax = 500000, C = 60000, E = 1\n"); |
1629 | anton | 67 | elastic_task_default_model(e2); |
1630 | anton | 68 | elastic_task_def_period(e2, 200000, 500000); |
69 | elastic_task_def_wcet(e2, 60000); |
||
70 | elastic_task_def_param(e2, 1, PERIOD_SCALING); |
||
1629 | anton | 71 | elastic_task_def_arg(e2, (void *)2); |
72 | el_pid2 = task_create("Elastic2",elastic_test,&e2,NULL); |
||
73 | if (el_pid2 == NIL) { |
||
74 | cprintf("ERROR: Cannot create Elastic2\n"); |
||
75 | sys_end(); |
||
76 | } |
||
77 | task_activate(el_pid2); |
||
1627 | giacomo | 78 | |
1630 | anton | 79 | cprintf("\nCreating elastic task with Tmin = 300000, Tmax = 500000, C = 90000, E = 1\n"); |
1629 | anton | 80 | elastic_task_default_model(e3); |
1630 | anton | 81 | elastic_task_def_period(e3, 300000, 500000); |
82 | elastic_task_def_wcet(e3, 90000); |
||
1629 | anton | 83 | elastic_task_def_param(e3, 1, PERIOD_SCALING); |
84 | elastic_task_def_arg(e3, (void *)3); |
||
85 | el_pid3 = task_create("Elastic3",elastic_test,&e3,NULL); |
||
86 | if (el_pid3 == NIL) { |
||
87 | cprintf("ERROR: Cannot create Elastic3\n"); |
||
88 | sys_end(); |
||
89 | } |
||
90 | task_activate(el_pid3); |
||
1628 | giacomo | 91 | |
1630 | anton | 92 | cprintf("\nCreating elastic task with Tmin = 50000, Tmax = 500000, C = 24000, E = 0\n"); |
93 | elastic_task_default_model(e4); |
||
94 | elastic_task_def_period(e4, 50000, 500000); |
||
95 | elastic_task_def_wcet(e4, 24000); |
||
96 | elastic_task_def_param(e4, 0, PERIOD_SCALING); |
||
97 | elastic_task_def_arg(e4, (void *)4); |
||
98 | el_pid4 = task_create("Elastic4",elastic_test,&e4,NULL); |
||
99 | if (el_pid4 == NIL) { |
||
100 | cprintf("ERROR: Cannot create Elastic4\n"); |
||
101 | sys_end(); |
||
102 | } |
||
103 | task_activate(el_pid4); |
||
1629 | anton | 104 | |
105 | /* Exit at time t = 5.0 */ |
||
106 | struct timespec t; |
||
107 | t.tv_sec = 5; |
||
108 | t.tv_nsec = 0; |
||
109 | kern_event_post(&t, (void(*)(void*))sys_end, NULL); |
||
110 | while(1); |
||
1627 | giacomo | 111 | return 0; |
112 | |||
113 | } |