Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1624 | 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 | * Paolo Gai <pj@gandalf.sssup.it> |
||
10 | * (see the web pages for full authors list) |
||
11 | * |
||
12 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
13 | * |
||
14 | * http://www.sssup.it |
||
15 | * http://retis.sssup.it |
||
16 | * http://shark.sssup.it |
||
17 | */ |
||
18 | |||
19 | /* |
||
20 | ------------ |
||
21 | CVS : $Id: test1.c,v 1.1.1.1 2004-05-24 17:54:51 giacomo Exp $ |
||
22 | |||
23 | File: $File$ |
||
24 | Revision: $Revision: 1.1.1.1 $ |
||
25 | Last update: $Date: 2004-05-24 17:54:51 $ |
||
26 | ------------ |
||
27 | |||
28 | this test shows a set of 5 tasks (+main+dummy+keyboard driver). |
||
29 | |||
30 | The first 4 tasks are scheduled by a EDFSTAR Module, whereas the |
||
31 | fifth one is a standard traditional EDF task. The 4 tasks uses a |
||
32 | budget of 10000/100000. |
||
33 | |||
34 | if edfstar.c is compiled with edfstar_printf3 active, a couple |
||
35 | (dline, curtime) is showed (in ms). |
||
36 | |||
37 | if cbsstar.c is compiled with cbsstar_printf3 active, the budget |
||
38 | replenishments are showed. |
||
39 | */ |
||
40 | |||
41 | /* |
||
42 | * Copyright (C) 2002 Paolo Gai |
||
43 | * |
||
44 | * This program is free software; you can redistribute it and/or modify |
||
45 | * it under the terms of the GNU General Public License as published by |
||
46 | * the Free Software Foundation; either version 2 of the License, or |
||
47 | * (at your option) any later version. |
||
48 | * |
||
49 | * This program is distributed in the hope that it will be useful, |
||
50 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
51 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
52 | * GNU General Public License for more details. |
||
53 | * |
||
54 | * You should have received a copy of the GNU General Public License |
||
55 | * along with this program; if not, write to the Free Software |
||
56 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
57 | * |
||
58 | */ |
||
59 | |||
60 | #include "kernel/kern.h" |
||
61 | #include "modules/edf.h" |
||
62 | #include "modules/cbs.h" |
||
63 | #include "cbsstar.h" |
||
64 | #include "edfstar.h" |
||
65 | #include "modules/rr.h" |
||
66 | #include "modules/dummy.h" |
||
67 | |||
68 | #include "modules/sem.h" |
||
69 | #include "modules/hartport.h" |
||
70 | #include "modules/cabs.h" |
||
71 | |||
72 | #include "drivers/keyb.h" |
||
73 | |||
74 | |||
75 | // -------------------------------------------------- |
||
76 | // -------------------------------------------------- |
||
77 | // Init Part |
||
78 | // -------------------------------------------------- |
||
79 | // -------------------------------------------------- |
||
80 | |||
81 | |||
82 | /*+ sysyem tick in us +*/ |
||
83 | #define TICK 0 |
||
84 | |||
85 | /*+ RR tick in us +*/ |
||
86 | #define RRTICK 10000 |
||
87 | |||
88 | TIME __kernel_register_levels__(void *arg) |
||
89 | { |
||
90 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
91 | int cbsstar_level, edfstar_level, mybudget; |
||
92 | |||
93 | EDF_register_level(EDF_ENABLE_ALL); |
||
94 | |||
95 | cbsstar_level = CBSSTAR_register_level(3, 0); |
||
96 | mybudget = CBSSTAR_setbudget(cbsstar_level, 10000, 100000); |
||
97 | edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level); |
||
98 | |||
99 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
||
100 | dummy_register_level(); |
||
101 | |||
102 | // for the keyboard... |
||
103 | CBS_register_level(CBS_ENABLE_ALL, 0); |
||
104 | |||
105 | SEM_register_module(); |
||
106 | |||
107 | CABS_register_module(); |
||
108 | |||
109 | return TICK; |
||
110 | } |
||
111 | |||
112 | TASK __init__(void *arg) |
||
113 | { |
||
114 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
115 | |||
116 | KEYB_PARMS kparms = BASE_KEYB; |
||
117 | |||
118 | HARTPORT_init(); |
||
119 | |||
120 | //keyb_def_ctrlC(kparms, NULL); |
||
121 | //keyb_def_map(kparms,itaMap); |
||
122 | KEYB_init(&kparms); |
||
123 | __call_main__(mb); |
||
124 | |||
125 | return (void *)0; |
||
126 | } |
||
127 | |||
128 | // -------------------------------------------------- |
||
129 | // -------------------------------------------------- |
||
130 | // The Test |
||
131 | // -------------------------------------------------- |
||
132 | // -------------------------------------------------- |
||
133 | |||
134 | |||
135 | #include <kernel/kern.h> |
||
136 | #include <drivers/keyb.h> |
||
137 | |||
138 | void *star(void *arg) |
||
139 | { |
||
140 | int i,j; |
||
141 | |||
142 | for (i=0; i<5; i++) { |
||
143 | for (j=0; j<100000; j++); |
||
144 | cputc('°'); |
||
145 | cputs((char *)arg); |
||
146 | task_endcycle(); |
||
147 | } |
||
148 | |||
149 | return NULL; |
||
150 | } |
||
151 | |||
152 | void *edftask(void *arg) |
||
153 | { |
||
154 | int i,j; |
||
155 | |||
156 | for (i=0; i<5; i++) { |
||
157 | for (j=0; j<100000; j++); |
||
158 | cputc('°'); |
||
159 | cputs((char *)arg); |
||
160 | task_endcycle(); |
||
161 | } |
||
162 | |||
163 | return NULL; |
||
164 | } |
||
165 | |||
166 | void create1() |
||
167 | { |
||
168 | HARD_TASK_MODEL m1, m2; |
||
169 | PID p1a, p1b, p1c, p1d, p2; |
||
170 | |||
171 | hard_task_default_model(m1); |
||
172 | hard_task_def_wcet(m1, 5000); |
||
173 | hard_task_def_level(m1,2); |
||
174 | hard_task_def_group(m1,1); |
||
175 | hard_task_def_periodic(m1); |
||
176 | |||
177 | hard_task_def_arg(m1,(void *)"a"); |
||
178 | hard_task_def_mit(m1,10000); |
||
179 | p1a = task_create("a", star, &m1, NULL); |
||
180 | if (p1a == -1) { |
||
181 | perror("Could not create task a ..."); |
||
182 | sys_end(); |
||
183 | } |
||
184 | |||
185 | hard_task_def_arg(m1,(void *)"b"); |
||
186 | hard_task_def_mit(m1,15000); |
||
187 | p1b = task_create("b", star, &m1, NULL); |
||
188 | if (p1b == -1) { |
||
189 | perror("Could not create task b ..."); |
||
190 | sys_end(); |
||
191 | } |
||
192 | |||
193 | hard_task_def_arg(m1,(void *)"c"); |
||
194 | hard_task_def_mit(m1,20000); |
||
195 | p1c = task_create("c", star, &m1, NULL); |
||
196 | if (p1c == -1) { |
||
197 | perror("Could not create task c ..."); |
||
198 | sys_end(); |
||
199 | } |
||
200 | |||
201 | hard_task_def_arg(m1,(void *)"d"); |
||
202 | hard_task_def_mit(m1,30000); |
||
203 | p1d = task_create("d", star, &m1, NULL); |
||
204 | if (p1d == -1) { |
||
205 | perror("Could not create task d ..."); |
||
206 | sys_end(); |
||
207 | } |
||
208 | |||
209 | hard_task_default_model(m2); |
||
210 | hard_task_def_mit(m2,50000); // the budget has dline 100,000! |
||
211 | hard_task_def_wcet(m2, 5000); |
||
212 | hard_task_def_arg(m2,(void *)"Û"); |
||
213 | hard_task_def_group(m2,1); |
||
214 | hard_task_def_periodic(m2); |
||
215 | |||
216 | p2 = task_create("2", edftask, &m2, NULL); |
||
217 | if (p2 == -1) { |
||
218 | perror("Could not create task edf ..."); |
||
219 | sys_end(); |
||
220 | } |
||
221 | |||
222 | cprintf("stars=%d %d %d %d, star2=%d\n", p1a, p1b, p1c, p1d, p2); |
||
223 | |||
224 | group_activate(1); |
||
225 | } |
||
226 | |||
227 | int main(int argc, char **argv) |
||
228 | { |
||
229 | char c; |
||
230 | |||
231 | clear(); |
||
232 | |||
233 | cprintf("Hello, world!\nPress ESC to end the demo...\n"); |
||
234 | |||
235 | create1(); |
||
236 | |||
237 | do { |
||
238 | c =keyb_getch(BLOCK); |
||
239 | } while (c != ESC); |
||
240 | |||
241 | cprintf("ESC pressed!"); |
||
242 | |||
243 | sys_end(); |
||
244 | |||
245 | return 0; |
||
246 | } |
||
247 |