Rev 1630 | Rev 1639 | 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" |
||
1631 | anton | 35 | #include "modules/elastic.h" |
1627 | giacomo | 36 | |
1631 | anton | 37 | extern unsigned int usleep(unsigned int usec); // include file? |
38 | |||
1627 | giacomo | 39 | TASK elastic_test(void *arg) { |
40 | |||
1629 | anton | 41 | int nbr = (int)arg; |
42 | |||
1627 | giacomo | 43 | while(1) { |
1629 | anton | 44 | cprintf("%d.", nbr); |
1627 | giacomo | 45 | task_endcycle(); |
46 | } |
||
47 | } |
||
48 | |||
49 | int main(int argc, char **argv) |
||
50 | { |
||
1630 | anton | 51 | ELASTIC_TASK_MODEL e1, e2, e3, e4; |
52 | PID el_pid1, el_pid2, el_pid3, el_pid4; |
||
1631 | anton | 53 | struct timespec t; |
1627 | giacomo | 54 | |
1630 | anton | 55 | cprintf("Elastic Task Demo (U=1.0 in initfile.c)\n"); |
1627 | giacomo | 56 | |
1630 | anton | 57 | cprintf("Creating elastic task with Tmin = 100000, Tmax = 500000, C = 30000, E = 1\n"); |
1629 | anton | 58 | elastic_task_default_model(e1); |
1630 | anton | 59 | elastic_task_def_period(e1, 100000, 500000); |
60 | elastic_task_def_wcet(e1, 30000); |
||
61 | elastic_task_def_param(e1, 1, PERIOD_SCALING); |
||
1629 | anton | 62 | elastic_task_def_arg(e1, (void *)1); |
63 | el_pid1 = task_create("Elastic1",elastic_test,&e1,NULL); |
||
64 | if (el_pid1 == NIL) { |
||
65 | cprintf("ERROR: Cannot create Elastic1\n"); |
||
1627 | giacomo | 66 | sys_end(); |
67 | } |
||
1631 | anton | 68 | |
1629 | anton | 69 | task_activate(el_pid1); |
1627 | giacomo | 70 | |
1631 | anton | 71 | cprintf("\nCreating elastic task with Tmin = 200000, Tmax = 500000, C = 160000, E = 2\n"); |
1629 | anton | 72 | elastic_task_default_model(e2); |
1630 | anton | 73 | elastic_task_def_period(e2, 200000, 500000); |
1631 | anton | 74 | elastic_task_def_wcet(e2, 160000); |
75 | elastic_task_def_param(e2, 2, PERIOD_SCALING); |
||
1629 | anton | 76 | elastic_task_def_arg(e2, (void *)2); |
77 | el_pid2 = task_create("Elastic2",elastic_test,&e2,NULL); |
||
78 | if (el_pid2 == NIL) { |
||
79 | cprintf("ERROR: Cannot create Elastic2\n"); |
||
80 | sys_end(); |
||
81 | } |
||
1631 | anton | 82 | |
1629 | anton | 83 | task_activate(el_pid2); |
1627 | giacomo | 84 | |
1631 | anton | 85 | usleep(500000); |
86 | |||
87 | ELASTIC_set_period(el_pid2, 210000); |
||
88 | |||
89 | |||
90 | /* |
||
1630 | anton | 91 | cprintf("\nCreating elastic task with Tmin = 300000, Tmax = 500000, C = 90000, E = 1\n"); |
1629 | anton | 92 | elastic_task_default_model(e3); |
1630 | anton | 93 | elastic_task_def_period(e3, 300000, 500000); |
94 | elastic_task_def_wcet(e3, 90000); |
||
1629 | anton | 95 | elastic_task_def_param(e3, 1, PERIOD_SCALING); |
96 | elastic_task_def_arg(e3, (void *)3); |
||
97 | el_pid3 = task_create("Elastic3",elastic_test,&e3,NULL); |
||
98 | if (el_pid3 == NIL) { |
||
99 | cprintf("ERROR: Cannot create Elastic3\n"); |
||
100 | sys_end(); |
||
101 | } |
||
102 | task_activate(el_pid3); |
||
1628 | giacomo | 103 | |
1630 | anton | 104 | cprintf("\nCreating elastic task with Tmin = 50000, Tmax = 500000, C = 24000, E = 0\n"); |
105 | elastic_task_default_model(e4); |
||
106 | elastic_task_def_period(e4, 50000, 500000); |
||
107 | elastic_task_def_wcet(e4, 24000); |
||
108 | elastic_task_def_param(e4, 0, PERIOD_SCALING); |
||
109 | elastic_task_def_arg(e4, (void *)4); |
||
110 | el_pid4 = task_create("Elastic4",elastic_test,&e4,NULL); |
||
111 | if (el_pid4 == NIL) { |
||
112 | cprintf("ERROR: Cannot create Elastic4\n"); |
||
113 | sys_end(); |
||
114 | } |
||
115 | task_activate(el_pid4); |
||
1631 | anton | 116 | */ |
1629 | anton | 117 | |
1631 | anton | 118 | /* Exit at time t = 1.0 */ |
119 | t.tv_sec = 1; |
||
1629 | anton | 120 | t.tv_nsec = 0; |
121 | kern_event_post(&t, (void(*)(void*))sys_end, NULL); |
||
122 | while(1); |
||
1627 | giacomo | 123 | return 0; |
124 | |||
125 | } |