Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1089 | pj | 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: test5.c,v 1.1 2002-09-02 10:29:30 pj Exp $ |
||
22 | |||
23 | File: $File$ |
||
24 | Revision: $Revision: 1.1 $ |
||
25 | Last update: $Date: 2002-09-02 10:29:30 $ |
||
26 | ------------ |
||
27 | |||
28 | The purpose of this test is to show that two budgets with different |
||
29 | period and budgets schedules correctly. |
||
30 | |||
31 | 2 never ending tasks are involved |
||
32 | */ |
||
33 | |||
34 | /* |
||
35 | * Copyright (C) 2002 Paolo Gai |
||
36 | * |
||
37 | * This program is free software; you can redistribute it and/or modify |
||
38 | * it under the terms of the GNU General Public License as published by |
||
39 | * the Free Software Foundation; either version 2 of the License, or |
||
40 | * (at your option) any later version. |
||
41 | * |
||
42 | * This program is distributed in the hope that it will be useful, |
||
43 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
44 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
45 | * GNU General Public License for more details. |
||
46 | * |
||
47 | * You should have received a copy of the GNU General Public License |
||
48 | * along with this program; if not, write to the Free Software |
||
49 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
50 | * |
||
51 | */ |
||
52 | |||
53 | #include "kernel/kern.h" |
||
54 | #include "modules/edf.h" |
||
55 | #include "modules/cbs.h" |
||
56 | #include "cbsstar.h" |
||
57 | #include "edfstar.h" |
||
58 | #include "modules/rr.h" |
||
59 | #include "modules/dummy.h" |
||
60 | |||
61 | #include "modules/sem.h" |
||
62 | #include "modules/hartport.h" |
||
63 | #include "modules/cabs.h" |
||
64 | |||
65 | #include "drivers/keyb.h" |
||
66 | |||
67 | // -------------------------------------------------- |
||
68 | // -------------------------------------------------- |
||
69 | // Init Part |
||
70 | // -------------------------------------------------- |
||
71 | // -------------------------------------------------- |
||
72 | |||
73 | /*+ sysyem tick in us +*/ |
||
74 | #define TICK 0 |
||
75 | |||
76 | /*+ RR tick in us +*/ |
||
77 | #define RRTICK 10000 |
||
78 | |||
79 | TIME __kernel_register_levels__(void *arg) |
||
80 | { |
||
81 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
82 | int cbsstar_level; |
||
83 | int edfstar_level, edfstar_level2, edfstar_level3; |
||
84 | int mybudget, mybudget2; |
||
85 | |||
86 | clear(); |
||
87 | |||
88 | EDF_register_level(EDF_ENABLE_ALL); |
||
89 | |||
90 | cbsstar_level = CBSSTAR_register_level(3, 0); |
||
91 | |||
92 | mybudget = CBSSTAR_setbudget(cbsstar_level, 2000, 50000); |
||
93 | edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level); |
||
94 | |||
95 | mybudget2 = CBSSTAR_setbudget(cbsstar_level, 10000, 25000); |
||
96 | edfstar_level2 = EDFSTAR_register_level(mybudget2, cbsstar_level); |
||
97 | edfstar_level3 = EDFSTAR_register_level(mybudget2, cbsstar_level); |
||
98 | |||
99 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
||
100 | dummy_register_level(); |
||
101 | |||
102 | cprintf("edfstar_level=%d, edfstar_level2=%d\n", |
||
103 | edfstar_level,edfstar_level2); |
||
104 | |||
105 | // for the keyboard... |
||
106 | CBS_register_level(CBS_ENABLE_ALL, 0); |
||
107 | |||
108 | CBS_register_level(CBS_ENABLE_ALL, edfstar_level3); |
||
109 | |||
110 | SEM_register_module(); |
||
111 | |||
112 | CABS_register_module(); |
||
113 | |||
114 | return TICK; |
||
115 | } |
||
116 | |||
117 | TASK __init__(void *arg) |
||
118 | { |
||
119 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
120 | |||
121 | KEYB_PARMS kparms = BASE_KEYB; |
||
122 | |||
123 | HARTPORT_init(); |
||
124 | |||
125 | //keyb_def_ctrlC(kparms, NULL); |
||
126 | //keyb_def_map(kparms,itaMap); |
||
127 | KEYB_init(&kparms); |
||
128 | |||
129 | __call_main__(mb); |
||
130 | |||
131 | return (void *)0; |
||
132 | } |
||
133 | |||
134 | // -------------------------------------------------- |
||
135 | // -------------------------------------------------- |
||
136 | // The Test |
||
137 | // -------------------------------------------------- |
||
138 | // -------------------------------------------------- |
||
139 | |||
140 | |||
141 | #include <kernel/kern.h> |
||
142 | #include <drivers/keyb.h> |
||
143 | #include <semaphore.h> |
||
144 | |||
145 | sem_t s; |
||
146 | |||
147 | void *star(void *arg) |
||
148 | { |
||
149 | int j,z; |
||
150 | |||
151 | for (;;) { |
||
152 | for (z=0; z<50; z++) { |
||
153 | for (j=0; j<60000; j++); |
||
154 | // sem_wait(&s); |
||
155 | cputs((char *)arg); |
||
156 | // sem_post(&s); |
||
157 | } |
||
158 | task_endcycle(); |
||
159 | } |
||
160 | |||
161 | return NULL; |
||
162 | } |
||
163 | |||
164 | |||
165 | void create1() |
||
166 | { |
||
167 | HARD_TASK_MODEL m1; |
||
168 | SOFT_TASK_MODEL ms; |
||
169 | PID p1a, p1b, p1c, p2; |
||
170 | |||
171 | hard_task_default_model(m1); |
||
172 | hard_task_def_wcet(m1, 5000); |
||
173 | hard_task_def_group(m1,1); |
||
174 | hard_task_def_periodic(m1); |
||
175 | |||
176 | |||
177 | |||
178 | |||
179 | hard_task_def_level(m1,2); |
||
180 | |||
181 | hard_task_def_arg(m1,(void *)"O"); |
||
182 | hard_task_def_mit(m1,5000); |
||
183 | p1a = task_create("a", star, &m1, NULL); |
||
184 | if (p1a == -1) { |
||
185 | perror("Could not create task a ..."); |
||
186 | sys_end(); |
||
187 | } |
||
188 | |||
189 | |||
190 | hard_task_def_level(m1,3); |
||
191 | |||
192 | hard_task_def_arg(m1,(void *)"."); |
||
193 | hard_task_def_mit(m1,50000); |
||
194 | p1b = task_create("b", star, &m1, NULL); |
||
195 | if (p1b == -1) { |
||
196 | perror("Could not create task c ..."); |
||
197 | sys_end(); |
||
198 | } |
||
199 | |||
200 | hard_task_def_level(m1,4); |
||
201 | |||
202 | hard_task_def_arg(m1,(void *)","); |
||
203 | hard_task_def_mit(m1,50000); |
||
204 | p1c = task_create("c", star, &m1, NULL); |
||
205 | if (p1c == -1) { |
||
206 | perror("Could not create task c ..."); |
||
207 | sys_end(); |
||
208 | } |
||
209 | |||
210 | soft_task_default_model(ms); |
||
211 | soft_task_def_met(ms, 5000); |
||
212 | soft_task_def_period(ms, 30000); |
||
213 | soft_task_def_group(ms,1); |
||
214 | soft_task_def_periodic(ms); |
||
215 | soft_task_def_level(ms,8); |
||
216 | soft_task_def_arg(ms,(void *)"X"); |
||
217 | p2 = task_create("S", star, &ms, NULL); |
||
218 | if (p2 == -1) { |
||
219 | perror("Could not create task S ..."); |
||
220 | sys_end(); |
||
221 | } |
||
222 | |||
223 | group_activate(1); |
||
224 | } |
||
225 | |||
226 | void endfun(KEY_EVT *k) |
||
227 | { |
||
228 | cprintf("ESC pressed!"); |
||
229 | |||
230 | sys_end(); |
||
231 | } |
||
232 | |||
233 | int main(int argc, char **argv) |
||
234 | { |
||
235 | KEY_EVT k; |
||
236 | |||
237 | set_exchandler_grx(); |
||
238 | |||
239 | sem_init(&s,0,1); |
||
240 | |||
241 | k.flag = 0; |
||
242 | k.scan = KEY_ESC; |
||
243 | k.ascii = 27; |
||
244 | keyb_hook(k,endfun); |
||
245 | |||
246 | create1(); |
||
247 | |||
248 | return 0; |
||
249 | } |
||
250 |