Rev 1116 | 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: testiq.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 | |||
83 | clear(); |
||
84 | |||
85 | EDF_register_level(EDF_ENABLE_ALL); |
||
86 | |||
87 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
||
88 | dummy_register_level(); |
||
89 | |||
90 | // for the keyboard... |
||
91 | CBS_register_level(CBS_ENABLE_ALL, 0); |
||
92 | |||
93 | SEM_register_module(); |
||
94 | |||
95 | CABS_register_module(); |
||
96 | |||
97 | return TICK; |
||
98 | } |
||
99 | |||
100 | TASK __init__(void *arg) |
||
101 | { |
||
102 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
103 | |||
104 | KEYB_PARMS kparms = BASE_KEYB; |
||
105 | |||
106 | HARTPORT_init(); |
||
107 | |||
108 | //keyb_def_ctrlC(kparms, NULL); |
||
109 | //keyb_def_map(kparms,itaMap); |
||
110 | KEYB_init(&kparms); |
||
111 | |||
112 | __call_main__(mb); |
||
113 | |||
114 | return (void *)0; |
||
115 | } |
||
116 | |||
117 | // -------------------------------------------------- |
||
118 | // -------------------------------------------------- |
||
119 | // The Test |
||
120 | // -------------------------------------------------- |
||
121 | // -------------------------------------------------- |
||
122 | |||
123 | |||
124 | #include <kernel/kern.h> |
||
125 | #include <drivers/keyb.h> |
||
126 | #include "iqueue.h" |
||
127 | |||
128 | sem_t s; |
||
129 | |||
130 | PID p2,p3,p4; |
||
131 | |||
132 | void *star(void *arg) |
||
133 | { |
||
134 | int j; |
||
135 | TIME last[5]; |
||
136 | |||
137 | QUEUE i = NIL; |
||
138 | IQUEUE ii; |
||
139 | |||
140 | q_timespec_insert(p2,&i); |
||
141 | q_timespec_insert(p3,&i); |
||
142 | |||
143 | iq_init(&ii,NULL,0); |
||
144 | *iq_query_timespec(p2,&ii) = proc_table[p2].timespec_priority; |
||
145 | *iq_query_timespec(p3,&ii) = proc_table[p3].timespec_priority; |
||
146 | *iq_query_timespec(p4,&ii) = proc_table[p4].timespec_priority; |
||
147 | iq_timespec_insert(p2,&ii); |
||
148 | iq_timespec_insert(p3,&ii); |
||
149 | |||
150 | cprintf("p2=%ld.%ld\n",proc_table[p2].timespec_priority.tv_sec,proc_table[p2].timespec_priority.tv_nsec/1000); |
||
151 | cprintf("p3=%ld.%ld\n",proc_table[p3].timespec_priority.tv_sec,proc_table[p3].timespec_priority.tv_nsec/1000); |
||
152 | cprintf("p4=%ld.%ld\n",proc_table[p4].timespec_priority.tv_sec,proc_table[p4].timespec_priority.tv_nsec/1000); |
||
153 | |||
154 | task_endcycle(); |
||
155 | |||
156 | for (j=0; j<200000; j++) { |
||
157 | q_timespec_insert(p4,&i); |
||
158 | q_extract(p4,&i); |
||
159 | } |
||
160 | |||
161 | |||
162 | task_endcycle(); |
||
163 | |||
164 | for (j=0; j<200000; j++) { |
||
165 | iq_timespec_insert(p4,&ii); |
||
166 | iq_extract(p4,&ii); |
||
167 | } |
||
168 | |||
169 | task_endcycle(); |
||
170 | |||
171 | jet_gettable(exec_shadow, &last[0], 3); |
||
172 | |||
173 | cprintf("\ninit=%d queue=%d iqueue=%d\n", |
||
174 | (int)last[0], (int)last[1], (int)last[2]); |
||
175 | |||
176 | sys_end(); |
||
177 | return NULL; |
||
178 | } |
||
179 | |||
180 | void *fake(void *arg) |
||
181 | { |
||
182 | cputs("#"); |
||
183 | task_endcycle(); |
||
184 | |||
185 | return NULL; |
||
186 | } |
||
187 | |||
188 | |||
189 | void create1() |
||
190 | { |
||
191 | HARD_TASK_MODEL m1; |
||
192 | PID p1a; |
||
193 | |||
194 | hard_task_default_model(m1); |
||
195 | hard_task_def_wcet(m1, 500000); |
||
196 | hard_task_def_group(m1,1); |
||
197 | hard_task_def_periodic(m1); |
||
198 | hard_task_def_mit(m1,1000000); |
||
199 | hard_task_def_ctrl_jet(m1); |
||
200 | p1a = task_create("a", star, &m1, NULL); |
||
201 | if (p1a == -1) { |
||
202 | perror("Could not create task a ..."); |
||
203 | sys_end(); |
||
204 | } |
||
205 | |||
206 | hard_task_default_model(m1); |
||
207 | hard_task_def_wcet(m1, 5000); |
||
208 | hard_task_def_aperiodic(m1); |
||
209 | hard_task_def_group(m1,1); |
||
210 | |||
211 | hard_task_def_mit(m1,100000); |
||
212 | p2 = task_create("a", fake, &m1, NULL); |
||
213 | if (p1a == -1) { |
||
214 | perror("Could not create task a ..."); |
||
215 | sys_end(); |
||
216 | } |
||
217 | |||
218 | hard_task_def_mit(m1,100001); |
||
219 | p3 = task_create("a", fake, &m1, NULL); |
||
220 | if (p1a == -1) { |
||
221 | perror("Could not create task a ..."); |
||
222 | sys_end(); |
||
223 | } |
||
224 | |||
225 | hard_task_def_mit(m1,100002); |
||
226 | p4 = task_create("a", fake, &m1, NULL); |
||
227 | if (p1a == -1) { |
||
228 | perror("Could not create task a ..."); |
||
229 | sys_end(); |
||
230 | } |
||
231 | |||
232 | group_activate(1); |
||
233 | } |
||
234 | |||
235 | void endfun(KEY_EVT *k) |
||
236 | { |
||
237 | cprintf("ESC pressed!"); |
||
238 | |||
239 | sys_end(); |
||
240 | } |
||
241 | |||
242 | int main(int argc, char **argv) |
||
243 | { |
||
244 | KEY_EVT k; |
||
245 | |||
246 | set_exchandler_grx(); |
||
247 | |||
248 | sem_init(&s,0,1); |
||
249 | |||
250 | k.flag = 0; |
||
251 | k.scan = KEY_ESC; |
||
252 | k.ascii = 27; |
||
253 | keyb_hook(k,endfun); |
||
254 | |||
255 | create1(); |
||
256 | |||
257 | return 0; |
||
258 | } |
||
259 |