Rev 14 | Rev 38 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | 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 | * Massimiliano Giorgi <massy@gandalf.sssup.it> |
||
11 | * Luca Abeni <luca@gandalf.sssup.it> |
||
12 | * (see the web pages for full authors list) |
||
13 | * |
||
14 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
15 | * |
||
16 | * http://www.sssup.it |
||
17 | * http://retis.sssup.it |
||
18 | * http://shark.sssup.it |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | ------------ |
||
29 | pj | 23 | CVS : $Id: rrsoft.c,v 1.3 2002-11-11 08:32:07 pj Exp $ |
2 | pj | 24 | |
25 | File: $File$ |
||
29 | pj | 26 | Revision: $Revision: 1.3 $ |
27 | Last update: $Date: 2002-11-11 08:32:07 $ |
||
2 | pj | 28 | ------------ |
29 | |||
30 | This file contains the scheduling module RRSOFT (Round Robin) |
||
31 | |||
32 | Read rrsoft.h for further details. |
||
33 | |||
34 | **/ |
||
35 | |||
36 | /* |
||
37 | * Copyright (C) 2000 Paolo Gai |
||
38 | * |
||
39 | * This program is free software; you can redistribute it and/or modify |
||
40 | * it under the terms of the GNU General Public License as published by |
||
41 | * the Free Software Foundation; either version 2 of the License, or |
||
42 | * (at your option) any later version. |
||
43 | * |
||
44 | * This program is distributed in the hope that it will be useful, |
||
45 | * but WITHOUT ANY WARRSOFTANTY; without even the implied waRRSOFTanty of |
||
46 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
47 | * GNU General Public License for more details. |
||
48 | * |
||
49 | * You should have received a copy of the GNU General Public License |
||
50 | * along with this program; if not, write to the Free Software |
||
51 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
52 | * |
||
53 | */ |
||
54 | |||
55 | |||
56 | #include <modules/rrsoft.h> |
||
57 | #include <ll/stdio.h> |
||
58 | #include <ll/string.h> |
||
59 | #include <kernel/model.h> |
||
60 | #include <kernel/descr.h> |
||
61 | #include <kernel/var.h> |
||
62 | #include <kernel/func.h> |
||
63 | |||
64 | /*+ Status used in the level +*/ |
||
65 | #define RRSOFT_READY MODULE_STATUS_BASE |
||
66 | #define RRSOFT_IDLE MODULE_STATUS_BASE+2 |
||
67 | |||
68 | /*+ the level redefinition for the Round Robin level +*/ |
||
69 | typedef struct { |
||
70 | level_des l; /*+ the standard level descriptor +*/ |
||
71 | |||
72 | int nact[MAX_PROC]; /*+ number of pending activations +*/ |
||
73 | |||
29 | pj | 74 | IQUEUE ready; /*+ the ready queue +*/ |
2 | pj | 75 | |
76 | int slice; /*+ the level's time slice +*/ |
||
77 | |||
78 | TIME period[MAX_PROC]; /*+ activation period +*/ |
||
79 | |||
80 | struct timespec reactivation_time[MAX_PROC]; |
||
81 | /*+ the time at witch the reactivation timer is post +*/ |
||
82 | int reactivation_timer[MAX_PROC]; |
||
83 | /*+ the recativation timer +*/ |
||
84 | |||
85 | BYTE periodic[MAX_PROC]; |
||
86 | |||
87 | |||
88 | struct multiboot_info *multiboot; /*+ used if the level have to insert |
||
89 | the main task +*/ |
||
90 | |||
91 | BYTE models; /*+ Task Model that the Module can Handle +*/ |
||
92 | } RRSOFT_level_des; |
||
93 | |||
94 | |||
95 | static char *RRSOFT_status_to_a(WORD status) |
||
96 | { |
||
97 | if (status < MODULE_STATUS_BASE) |
||
98 | return status_to_a(status); |
||
99 | |||
100 | switch (status) { |
||
101 | case RRSOFT_READY: return "RRSOFT_Ready"; |
||
102 | case RRSOFT_IDLE : return "RRSOFT_Idle"; |
||
103 | default : return "RRSOFT_Unknown"; |
||
104 | } |
||
105 | } |
||
106 | |||
107 | |||
108 | /* this is the periodic reactivation of the task... it is posted only |
||
109 | if the task is a periodic task */ |
||
110 | static void RRSOFT_timer_reactivate(void *par) |
||
111 | { |
||
112 | PID p = (PID) par; |
||
113 | RRSOFT_level_des *lev; |
||
114 | // kern_printf("react"); |
||
115 | |||
116 | lev = (RRSOFT_level_des *)level_table[proc_table[p].task_level]; |
||
117 | |||
118 | if (proc_table[p].status == RRSOFT_IDLE) { |
||
119 | /* the task has finished the current activation and must be |
||
120 | reactivated */ |
||
121 | proc_table[p].status = RRSOFT_READY; |
||
29 | pj | 122 | iq_insertlast(p,&lev->ready); |
2 | pj | 123 | |
124 | event_need_reschedule(); |
||
125 | } |
||
126 | else if (lev->nact[p] >= 0) |
||
127 | /* the task has not completed the current activation, so we save |
||
128 | the activation incrementing nact... */ |
||
129 | lev->nact[p]++; |
||
130 | |||
131 | /* repost the event at the next period end... */ |
||
132 | ADDUSEC2TIMESPEC(lev->period[p], &lev->reactivation_time[p]); |
||
133 | lev->reactivation_timer[p] = kern_event_post(&lev->reactivation_time[p], |
||
134 | RRSOFT_timer_reactivate, |
||
135 | (void *)p); |
||
136 | /* tracer stuff */ |
||
137 | // trc_logevent(TRC_INTACTIVATION,&p); |
||
138 | } |
||
139 | |||
140 | |||
141 | static int RRSOFT_level_accept_task_model(LEVEL l, TASK_MODEL *m) |
||
142 | { |
||
143 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
144 | |||
145 | if ((m->pclass == NRT_PCLASS || m->pclass == (NRT_PCLASS | l)) && lev->models & RRSOFT_ONLY_NRT) |
||
146 | return 0; |
||
147 | else if ((m->pclass == SOFT_PCLASS || m->pclass == (SOFT_PCLASS | l)) && lev->models & RRSOFT_ONLY_SOFT) |
||
148 | return 0; |
||
149 | else if ((m->pclass == HARD_PCLASS || m->pclass == (HARD_PCLASS | l)) && lev->models & RRSOFT_ONLY_HARD) |
||
150 | return 0; |
||
151 | else |
||
152 | return -1; |
||
153 | } |
||
154 | |||
155 | static int RRSOFT_level_accept_guest_model(LEVEL l, TASK_MODEL *m) |
||
156 | { |
||
157 | return -1; |
||
158 | } |
||
159 | |||
160 | static void RRSOFT_level_status(LEVEL l) |
||
161 | { |
||
162 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
29 | pj | 163 | PID p = iq_query_first(&lev->ready); |
2 | pj | 164 | |
165 | kern_printf("Slice: %d \n", lev->slice); |
||
166 | |||
167 | while (p != NIL) { |
||
168 | kern_printf("Pid: %d\t Name: %20s Status: %s\n",p,proc_table[p].name, |
||
169 | RRSOFT_status_to_a(proc_table[p].status)); |
||
29 | pj | 170 | p = iq_query_next(p, &lev->ready); |
2 | pj | 171 | } |
172 | |||
173 | for (p=0; p<MAX_PROC; p++) |
||
174 | if (proc_table[p].task_level == l && proc_table[p].status != RRSOFT_READY |
||
175 | && proc_table[p].status != FREE ) |
||
176 | kern_printf("Pid: %d\t Name: %20s Status: %s\n",p,proc_table[p].name, |
||
177 | RRSOFT_status_to_a(proc_table[p].status)); |
||
178 | |||
179 | } |
||
180 | |||
181 | |||
182 | /* This is not efficient but very fair :-) |
||
183 | The need of all this stuff is because if a task execute a long time |
||
184 | due to (shadow!) priority inheritance, then the task shall go to the |
||
185 | tail of the queue many times... */ |
||
186 | static PID RRSOFT_level_scheduler(LEVEL l) |
||
187 | { |
||
188 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
189 | |||
190 | PID p; |
||
191 | |||
192 | for (;;) { |
||
29 | pj | 193 | p = iq_query_first(&lev->ready); |
2 | pj | 194 | if (p == -1) |
195 | return p; |
||
196 | //{kern_printf("(s%d)",p); return p;} |
||
197 | |||
198 | // kern_printf("(p=%d l=%d avail=%d wcet =%d)\n",p,l,proc_table[p].avail_time, proc_table[p].wcet); |
||
199 | if (proc_table[p].avail_time <= 0) { |
||
200 | proc_table[p].avail_time += proc_table[p].wcet; |
||
29 | pj | 201 | iq_extract(p,&lev->ready); |
202 | iq_insertlast(p,&lev->ready); |
||
2 | pj | 203 | } |
204 | else |
||
205 | //{kern_printf("(s%d)",p); return p;} |
||
206 | return p; |
||
207 | |||
208 | } |
||
209 | } |
||
210 | |||
211 | static int RRSOFT_level_guarantee(LEVEL l, bandwidth_t *freebandwidth) |
||
212 | { |
||
213 | /* the RRSOFT level always guarantee... the function is defined because |
||
214 | there can be an aperiodic server at a level with less priority than |
||
215 | the RRSOFT that need guarantee (e.g., a TBS server) */ |
||
216 | return 1; |
||
217 | } |
||
218 | |||
219 | |||
220 | static int RRSOFT_task_create(LEVEL l, PID p, TASK_MODEL *m) |
||
221 | { |
||
222 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
223 | |||
224 | // kern_printf("create %d mod %d\n",p,m->pclass); |
||
225 | /* the task state is set at SLEEP by the general task_create |
||
226 | the only thing to set remains the capacity stuffs that are set |
||
227 | to the values passed in the model... */ |
||
228 | |||
229 | /* I used the wcet field because using wcet can account if a task |
||
230 | consume more than the timeslice... */ |
||
231 | |||
232 | if (lev->models & RRSOFT_ONLY_NRT && |
||
233 | (m->pclass == NRT_PCLASS || m->pclass == (NRT_PCLASS | l))) { |
||
234 | NRT_TASK_MODEL *nrt = (NRT_TASK_MODEL *)m; |
||
235 | |||
236 | // kern_printf("nrt"); |
||
237 | if (nrt->slice) { |
||
238 | proc_table[p].avail_time = nrt->slice; |
||
239 | proc_table[p].wcet = nrt->slice; |
||
240 | } |
||
241 | else { |
||
242 | proc_table[p].avail_time = lev->slice; |
||
243 | proc_table[p].wcet = lev->slice; |
||
244 | } |
||
245 | proc_table[p].control |= CONTROL_CAP; |
||
246 | |||
247 | if (nrt->arrivals == SAVE_ARRIVALS) |
||
248 | lev->nact[p] = 0; |
||
249 | else |
||
250 | lev->nact[p] = -1; |
||
251 | |||
252 | lev->periodic[p] = 0; |
||
253 | lev->period[p] = 0; |
||
254 | } |
||
255 | else if (lev->models & RRSOFT_ONLY_SOFT && |
||
256 | (m->pclass == SOFT_PCLASS || m->pclass == (SOFT_PCLASS | l))) { |
||
257 | SOFT_TASK_MODEL *soft = (SOFT_TASK_MODEL *)m; |
||
258 | // kern_printf("soft"); |
||
259 | proc_table[p].avail_time = lev->slice; |
||
260 | proc_table[p].wcet = lev->slice; |
||
261 | proc_table[p].control |= CONTROL_CAP; |
||
262 | |||
263 | if (soft->arrivals == SAVE_ARRIVALS) |
||
264 | lev->nact[p] = 0; |
||
265 | else |
||
266 | lev->nact[p] = -1; |
||
267 | |||
268 | if (soft->periodicity == PERIODIC) { |
||
269 | lev->periodic[p] = 1; |
||
270 | lev->period[p] = soft->period; |
||
271 | } |
||
272 | } |
||
273 | else if (lev->models & RRSOFT_ONLY_HARD && |
||
274 | (m->pclass == HARD_PCLASS || m->pclass == (HARD_PCLASS | l))) { |
||
275 | HARD_TASK_MODEL *hard = (HARD_TASK_MODEL *)m; |
||
276 | // kern_printf("hard"); |
||
277 | proc_table[p].avail_time = lev->slice; |
||
278 | proc_table[p].wcet = lev->slice; |
||
279 | proc_table[p].control |= CONTROL_CAP; |
||
280 | |||
281 | lev->nact[p] = 0; |
||
282 | |||
283 | if (hard->periodicity == PERIODIC) { |
||
284 | lev->periodic[p] = 1; |
||
285 | lev->period[p] = hard->mit; |
||
286 | } |
||
287 | } |
||
288 | |||
289 | return 0; /* OK */ |
||
290 | } |
||
291 | |||
292 | static void RRSOFT_task_detach(LEVEL l, PID p) |
||
293 | { |
||
294 | /* the RRSOFT level doesn't introduce any new field in the TASK_MODEL |
||
295 | so, all detach stuffs are done by the task_create |
||
296 | The task state is set at FREE by the general task_create */ |
||
297 | } |
||
298 | |||
299 | static int RRSOFT_task_eligible(LEVEL l, PID p) |
||
300 | { |
||
301 | return 0; /* if the task p is chosen, it is always eligible */ |
||
302 | } |
||
303 | |||
304 | static void RRSOFT_task_dispatch(LEVEL l, PID p, int nostop) |
||
305 | { |
||
306 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
307 | //static int p2count=0; |
||
308 | |||
309 | /* the task state is set EXE by the scheduler() |
||
310 | we extract the task from the ready queue |
||
311 | NB: we can't assume that p is the first task in the queue!!! */ |
||
29 | pj | 312 | iq_extract(p, &lev->ready); |
2 | pj | 313 | } |
314 | |||
315 | static void RRSOFT_task_epilogue(LEVEL l, PID p) |
||
316 | { |
||
317 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
318 | |||
319 | /* check if the slice is finished and insert the task in the coRRSOFTect |
||
320 | qqueue position */ |
||
321 | if (proc_table[p].avail_time <= 0) { |
||
322 | proc_table[p].avail_time += proc_table[p].wcet; |
||
29 | pj | 323 | iq_insertlast(p,&lev->ready); |
2 | pj | 324 | } |
325 | else |
||
326 | /* curr is >0, so the running task have to run for another cuRRSOFT usec */ |
||
29 | pj | 327 | iq_insertfirst(p,&lev->ready); |
2 | pj | 328 | |
329 | proc_table[p].status = RRSOFT_READY; |
||
330 | } |
||
331 | |||
332 | static void RRSOFT_task_activate(LEVEL l, PID p) |
||
333 | { |
||
334 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
335 | |||
336 | /* Test if we are trying to activate a non sleeping task */ |
||
337 | /* save activation (only if needed... */ |
||
338 | if (proc_table[p].status != SLEEP && proc_table[p].status != RRSOFT_IDLE) { |
||
339 | if (lev->nact[p] != -1) |
||
340 | lev->nact[p]++; |
||
341 | return; |
||
342 | } |
||
343 | |||
344 | ll_gettime(TIME_EXACT, &proc_table[p].request_time); |
||
345 | |||
346 | /* Insert task in the coRRSOFTect position */ |
||
347 | proc_table[p].status = RRSOFT_READY; |
||
29 | pj | 348 | iq_insertlast(p,&lev->ready); |
2 | pj | 349 | |
350 | /* Set the reactivation timer */ |
||
351 | if (lev->periodic[p]) |
||
352 | { |
||
353 | TIMESPEC_ASSIGN(&lev->reactivation_time[p], &proc_table[p].request_time); |
||
354 | ADDUSEC2TIMESPEC(lev->period[p], &lev->reactivation_time[p]); |
||
355 | // TIMESPEC_ASSIGN(&lev->reactivation_time[p], &lev->cbs_dline[p]); |
||
356 | lev->reactivation_timer[p] = kern_event_post(&lev->reactivation_time[p], |
||
357 | RRSOFT_timer_reactivate, |
||
358 | (void *)p); |
||
359 | } |
||
360 | } |
||
361 | |||
362 | static void RRSOFT_task_insert(LEVEL l, PID p) |
||
363 | { |
||
364 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
365 | |||
366 | /* Similar to RRSOFT_task_activate, but we don't check in what state |
||
367 | the task is and we don't set the request_time */ |
||
368 | |||
369 | /* Insert task in the coRRSOFTect position */ |
||
370 | proc_table[p].status = RRSOFT_READY; |
||
29 | pj | 371 | iq_insertlast(p,&lev->ready); |
2 | pj | 372 | } |
373 | |||
374 | static void RRSOFT_task_extract(LEVEL l, PID p) |
||
375 | { |
||
376 | /* Extract the running task from the level |
||
377 | . we have already extract it from the ready queue at the dispatch time. |
||
378 | . the capacity event have to be removed by the generic kernel |
||
379 | . the wcet don't need modification... |
||
380 | . the state of the task is set by the calling function |
||
381 | |||
382 | So, we do nothing!!! |
||
383 | */ |
||
384 | } |
||
385 | |||
386 | static void RRSOFT_task_endcycle(LEVEL l, PID p) |
||
387 | { |
||
388 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
389 | |||
390 | if (lev->nact[p] > 0) { |
||
391 | /* continue!!!! */ |
||
392 | ll_gettime(TIME_EXACT, &proc_table[p].request_time); |
||
393 | lev->nact[p]--; |
||
394 | // qq_insertlast(p,&lev->ready); |
||
29 | pj | 395 | iq_insertfirst(p,&lev->ready); |
2 | pj | 396 | proc_table[p].status = RRSOFT_READY; |
397 | } |
||
398 | else |
||
399 | proc_table[p].status = RRSOFT_IDLE; |
||
400 | } |
||
401 | |||
402 | static void RRSOFT_task_end(LEVEL l, PID p) |
||
403 | { |
||
404 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
405 | |||
406 | lev->nact[p] = -1; |
||
407 | |||
408 | /* we delete the reactivation timer */ |
||
409 | if (lev->periodic[p]) { |
||
410 | event_delete(lev->reactivation_timer[p]); |
||
411 | lev->reactivation_timer[p] = -1; |
||
412 | } |
||
413 | |||
414 | /* then, we insert the task in the free queue */ |
||
415 | proc_table[p].status = FREE; |
||
29 | pj | 416 | iq_insertlast(p,&freedesc); |
2 | pj | 417 | } |
418 | |||
419 | static void RRSOFT_task_sleep(LEVEL l, PID p) |
||
420 | { |
||
421 | RRSOFT_level_des *lev = (RRSOFT_level_des *)(level_table[l]); |
||
422 | |||
423 | if (lev->nact[p] >= 0) lev->nact[p] = 0; |
||
424 | |||
425 | /* we delete the reactivation timer */ |
||
426 | if (lev->periodic[p]) { |
||
427 | event_delete(lev->reactivation_timer[p]); |
||
428 | lev->reactivation_timer[p] = -1; |
||
429 | } |
||
430 | |||
431 | proc_table[p].status = SLEEP; |
||
432 | } |
||
433 | |||
434 | static int RRSOFT_guest_create(LEVEL l, PID p, TASK_MODEL *m) |
||
14 | pj | 435 | { kern_raise(XINVALID_GUEST,exec_shadow); return 0; } |
2 | pj | 436 | |
437 | static void RRSOFT_guest_detach(LEVEL l, PID p) |
||
14 | pj | 438 | { kern_raise(XINVALID_GUEST,exec_shadow); } |
2 | pj | 439 | |
440 | static void RRSOFT_guest_dispatch(LEVEL l, PID p, int nostop) |
||
14 | pj | 441 | { kern_raise(XINVALID_GUEST,exec_shadow); } |
2 | pj | 442 | |
443 | static void RRSOFT_guest_epilogue(LEVEL l, PID p) |
||
14 | pj | 444 | { kern_raise(XINVALID_GUEST,exec_shadow); } |
2 | pj | 445 | |
446 | static void RRSOFT_guest_activate(LEVEL l, PID p) |
||
14 | pj | 447 | { kern_raise(XINVALID_GUEST,exec_shadow); } |
2 | pj | 448 | |
449 | static void RRSOFT_guest_insert(LEVEL l, PID p) |
||
14 | pj | 450 | { kern_raise(XINVALID_GUEST,exec_shadow); } |
2 | pj | 451 | |
452 | static void RRSOFT_guest_extract(LEVEL l, PID p) |
||
14 | pj | 453 | { kern_raise(XINVALID_GUEST,exec_shadow); } |
2 | pj | 454 | |
455 | static void RRSOFT_guest_endcycle(LEVEL l, PID p) |
||
14 | pj | 456 | { kern_raise(XINVALID_GUEST,exec_shadow); } |
2 | pj | 457 | |
458 | static void RRSOFT_guest_end(LEVEL l, PID p) |
||
14 | pj | 459 | { kern_raise(XINVALID_GUEST,exec_shadow); } |
2 | pj | 460 | |
461 | static void RRSOFT_guest_sleep(LEVEL l, PID p) |
||
14 | pj | 462 | { kern_raise(XINVALID_GUEST,exec_shadow); } |
2 | pj | 463 | |
464 | |||
465 | |||
466 | /* Registration functions */ |
||
467 | |||
468 | /*+ This init function install the "main" task +*/ |
||
469 | static void RRSOFT_call_main(void *l) |
||
470 | { |
||
471 | LEVEL lev; |
||
472 | PID p; |
||
473 | NRT_TASK_MODEL m; |
||
474 | void *mb; |
||
475 | |||
476 | lev = (LEVEL)l; |
||
477 | |||
478 | nrt_task_default_model(m); |
||
479 | nrt_task_def_level(m,lev); /* with this we are sure that the task aRRSOFTives |
||
480 | to the coRRSOFTect level */ |
||
481 | |||
482 | mb = ((RRSOFT_level_des *)level_table[lev])->multiboot; |
||
483 | nrt_task_def_arg(m,mb); |
||
484 | nrt_task_def_usemath(m); |
||
485 | nrt_task_def_nokill(m); |
||
486 | nrt_task_def_ctrl_jet(m); |
||
487 | |||
488 | p = task_create("Main", __init__, (TASK_MODEL *)&m, NULL); |
||
489 | |||
490 | if (p == NIL) |
||
491 | printk("\nPanic!!! can't create main task...\n"); |
||
492 | |||
493 | RRSOFT_task_activate(lev,p); |
||
494 | } |
||
495 | |||
496 | |||
497 | /*+ Registration function: |
||
498 | TIME slice the slice for the Round Robin queue |
||
499 | int createmain 1 if the level creates the main task 0 otherwise |
||
500 | struct multiboot_info *mb used if createmain specified +*/ |
||
501 | void RRSOFT_register_level(TIME slice, |
||
502 | int createmain, |
||
503 | struct multiboot_info *mb, |
||
504 | BYTE models) |
||
505 | { |
||
506 | LEVEL l; /* the level that we register */ |
||
507 | RRSOFT_level_des *lev; /* for readableness only */ |
||
508 | PID i; |
||
509 | |||
510 | printk("RRSOFT_register_level\n"); |
||
511 | |||
512 | /* request an entry in the level_table */ |
||
513 | l = level_alloc_descriptor(); |
||
514 | |||
515 | /* alloc the space needed for the RRSOFT_level_des */ |
||
516 | lev = (RRSOFT_level_des *)kern_alloc(sizeof(RRSOFT_level_des)); |
||
517 | |||
518 | printk(" lev=%d\n",(int)lev); |
||
519 | |||
520 | /* update the level_table with the new entry */ |
||
521 | level_table[l] = (level_des *)lev; |
||
522 | |||
523 | /* fill the standard descriptor */ |
||
524 | strncpy(lev->l.level_name, RRSOFT_LEVELNAME, MAX_LEVELNAME); |
||
525 | lev->l.level_code = RRSOFT_LEVEL_CODE; |
||
526 | lev->l.level_version = RRSOFT_LEVEL_VERSION; |
||
527 | |||
528 | lev->l.level_accept_task_model = RRSOFT_level_accept_task_model; |
||
529 | lev->l.level_accept_guest_model = RRSOFT_level_accept_guest_model; |
||
530 | lev->l.level_status = RRSOFT_level_status; |
||
531 | lev->l.level_scheduler = RRSOFT_level_scheduler; |
||
532 | lev->l.level_guarantee = RRSOFT_level_guarantee; |
||
533 | |||
534 | lev->l.task_create = RRSOFT_task_create; |
||
535 | lev->l.task_detach = RRSOFT_task_detach; |
||
536 | lev->l.task_eligible = RRSOFT_task_eligible; |
||
537 | lev->l.task_dispatch = RRSOFT_task_dispatch; |
||
538 | lev->l.task_epilogue = RRSOFT_task_epilogue; |
||
539 | lev->l.task_activate = RRSOFT_task_activate; |
||
540 | lev->l.task_insert = RRSOFT_task_insert; |
||
541 | lev->l.task_extract = RRSOFT_task_extract; |
||
542 | lev->l.task_endcycle = RRSOFT_task_endcycle; |
||
543 | lev->l.task_end = RRSOFT_task_end; |
||
544 | lev->l.task_sleep = RRSOFT_task_sleep; |
||
545 | |||
546 | lev->l.guest_create = RRSOFT_guest_create; |
||
547 | lev->l.guest_detach = RRSOFT_guest_detach; |
||
548 | lev->l.guest_dispatch = RRSOFT_guest_dispatch; |
||
549 | lev->l.guest_epilogue = RRSOFT_guest_epilogue; |
||
550 | lev->l.guest_activate = RRSOFT_guest_activate; |
||
551 | lev->l.guest_insert = RRSOFT_guest_insert; |
||
552 | lev->l.guest_extract = RRSOFT_guest_extract; |
||
553 | lev->l.guest_endcycle = RRSOFT_guest_endcycle; |
||
554 | lev->l.guest_end = RRSOFT_guest_end; |
||
555 | lev->l.guest_sleep = RRSOFT_guest_sleep; |
||
556 | |||
557 | /* fill the RRSOFT descriptor part */ |
||
558 | for (i = 0; i < MAX_PROC; i++) { |
||
559 | lev->nact[i] = -1; |
||
560 | NULL_TIMESPEC(&lev->reactivation_time[i]); |
||
561 | lev->reactivation_timer[i] = -1; |
||
562 | lev->periodic[i] = 0; |
||
563 | lev->period[i] = 0; |
||
564 | } |
||
565 | |||
29 | pj | 566 | iq_init(&lev->ready, &freedesc, 0); |
2 | pj | 567 | |
568 | if (slice < RRSOFT_MINIMUM_SLICE) slice = RRSOFT_MINIMUM_SLICE; |
||
569 | if (slice > RRSOFT_MAXIMUM_SLICE) slice = RRSOFT_MAXIMUM_SLICE; |
||
570 | lev->slice = slice; |
||
571 | |||
572 | lev->multiboot = mb; |
||
573 | |||
574 | lev->models = models; |
||
575 | |||
576 | if (createmain) |
||
577 | sys_atrunlevel(RRSOFT_call_main,(void *) l, RUNLEVEL_INIT); |
||
578 | } |
||
579 | |||
580 | |||
581 | |||
582 |