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: test2.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 | The purpose of this test is to show that two budgets with different |
||
29 | period and capacity schedules correctly. |
||
30 | |||
31 | 4 periodic 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 | // -------------------------------------------------- |
||
70 | // Init Part |
||
71 | // -------------------------------------------------- |
||
72 | // -------------------------------------------------- |
||
73 | |||
74 | |||
75 | /*+ sysyem tick in us +*/ |
||
76 | #define TICK 0 |
||
77 | |||
78 | /*+ RR tick in us +*/ |
||
79 | #define RRTICK 10000 |
||
80 | |||
81 | TIME __kernel_register_levels__(void *arg) |
||
82 | { |
||
83 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
84 | int cbsstar_level, edfstar_level, edfstar_level2, mybudget, mybudget2; |
||
85 | clear(); |
||
86 | EDF_register_level(EDF_ENABLE_ALL); |
||
87 | |||
88 | cbsstar_level = CBSSTAR_register_level(3, 0); |
||
89 | |||
90 | mybudget = CBSSTAR_setbudget(cbsstar_level, 1000, 50000); |
||
91 | edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level); |
||
92 | |||
93 | mybudget2 = CBSSTAR_setbudget(cbsstar_level, 10000, 25000); |
||
94 | edfstar_level2 = EDFSTAR_register_level(mybudget2, cbsstar_level); |
||
95 | |||
96 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
||
97 | dummy_register_level(); |
||
98 | |||
99 | cprintf("edfstar_level=%d, edfstar_level2=%d\n", |
||
100 | edfstar_level,edfstar_level2); |
||
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_init(&kparms); |
||
121 | |||
122 | __call_main__(mb); |
||
123 | |||
124 | return (void *)0; |
||
125 | } |
||
126 | |||
127 | // -------------------------------------------------- |
||
128 | // -------------------------------------------------- |
||
129 | // The Test |
||
130 | // -------------------------------------------------- |
||
131 | // -------------------------------------------------- |
||
132 | |||
133 | |||
134 | #include <kernel/kern.h> |
||
135 | #include <drivers/keyb.h> |
||
136 | |||
137 | void *star(void *arg) |
||
138 | { |
||
139 | int i,j,z; |
||
140 | |||
141 | for (i=0; i<100; i++) { |
||
142 | for (z=0; z<5; z++) { |
||
143 | for (j=0; j<60000; j++); |
||
144 | cputs((char *)arg); |
||
145 | } |
||
146 | task_endcycle(); |
||
147 | } |
||
148 | |||
149 | return NULL; |
||
150 | } |
||
151 | |||
152 | // version for the "slow" budget |
||
153 | void *slow(void *arg) |
||
154 | { |
||
155 | int i,j,z; |
||
156 | |||
157 | for (i=0; i<15; i++) { |
||
158 | for (z=0; z<5; z++) { |
||
159 | for (j=0; j<200000; j++); |
||
160 | cputs((char *)arg); |
||
161 | } |
||
162 | task_endcycle(); |
||
163 | } |
||
164 | |||
165 | return NULL; |
||
166 | } |
||
167 | |||
168 | void create1() |
||
169 | { |
||
170 | HARD_TASK_MODEL m1; |
||
171 | PID p1a, p1b, p1c, p1d; |
||
172 | |||
173 | hard_task_default_model(m1); |
||
174 | hard_task_def_wcet(m1, 5000); |
||
175 | hard_task_def_group(m1,1); |
||
176 | hard_task_def_periodic(m1); |
||
177 | |||
178 | |||
179 | |||
180 | |||
181 | hard_task_def_level(m1,2); |
||
182 | |||
183 | hard_task_def_arg(m1,(void *)"."); |
||
184 | hard_task_def_mit(m1,5000); |
||
185 | p1a = task_create("a", slow, &m1, NULL); |
||
186 | if (p1a == -1) { |
||
187 | perror("Could not create task a ..."); |
||
188 | sys_end(); |
||
189 | } |
||
190 | |||
191 | hard_task_def_arg(m1,(void *)","); |
||
192 | hard_task_def_mit(m1,5000); |
||
193 | p1b = task_create("b", slow, &m1, NULL); |
||
194 | if (p1b == -1) { |
||
195 | perror("Could not create task b ..."); |
||
196 | sys_end(); |
||
197 | } |
||
198 | |||
199 | |||
200 | |||
201 | |||
202 | hard_task_def_level(m1,3); |
||
203 | |||
204 | hard_task_def_arg(m1,(void *)"o"); |
||
205 | hard_task_def_mit(m1,5000); |
||
206 | p1c = task_create("c", star, &m1, NULL); |
||
207 | if (p1c == -1) { |
||
208 | perror("Could not create task c ..."); |
||
209 | sys_end(); |
||
210 | } |
||
211 | |||
212 | hard_task_def_arg(m1,(void *)"O"); |
||
213 | hard_task_def_mit(m1,5000); |
||
214 | p1d = task_create("d", star, &m1, NULL); |
||
215 | if (p1d == -1) { |
||
216 | perror("Could not create task d ..."); |
||
217 | sys_end(); |
||
218 | } |
||
219 | |||
220 | group_activate(1); |
||
221 | } |
||
222 | |||
223 | int main(int argc, char **argv) |
||
224 | { |
||
225 | char c; |
||
226 | |||
227 | cprintf("Hello, world!"); |
||
228 | |||
229 | create1(); |
||
230 | |||
231 | do { |
||
232 | c =keyb_getch(BLOCK); |
||
233 | } while (c != ESC); |
||
234 | |||
235 | cprintf("ESC pressed!"); |
||
236 | |||
237 | sys_end(); |
||
238 | |||
239 | return 0; |
||
240 | } |
||
241 |