20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: ds.c,v 1.2 2002-10-28 07:55:54 pj Exp $ |
CVS : $Id: ds.c,v 1.3 2002-11-11 08:32:06 pj Exp $ |
|
File: $File$ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-10-28 07:55:54 $ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2002-11-11 08:32:06 $ |
------------ |
|
This file contains the aperiodic server DS (Deferrable Server) |
83,7 → 83,7 |
int Cs; /*+ server capacity +*/ |
int availCs; /*+ server avail time +*/ |
|
QQUEUE wait; /*+ the wait queue of the DS +*/ |
IQUEUE wait; /*+ the wait queue of the DS +*/ |
PID activated; /*+ the task inserted in another queue +*/ |
|
int flags; /*+ the init flags... +*/ |
128,8 → 128,8 |
was not any other task to be put in the ready queue |
... we are now activating the next task */ |
if (lev->availCs > 0 && lev->activated == NIL) { |
if (qq_queryfirst(&lev->wait) != NIL) { |
lev->activated = qq_getfirst(&lev->wait); |
if (iq_query_first(&lev->wait) != NIL) { |
lev->activated = iq_getfirst(&lev->wait); |
DS_activation(lev); |
event_need_reschedule(); |
} |
178,7 → 178,7 |
static void DS_level_status(LEVEL l) |
{ |
DS_level_des *lev = (DS_level_des *)(level_table[l]); |
PID p = qq_queryfirst(&lev->wait); |
PID p = iq_query_first(&lev->wait); |
|
kern_printf("On-line guarantee : %s\n", |
onoff(lev->flags & DS_ENABLE_GUARANTEE_EDF || |
190,8 → 190,8 |
kern_printf("Activated: Pid: %2d Name: %10s Dl: %ld.%ld Nact: %d Stat: %s\n", |
lev->activated, |
proc_table[lev->activated].name, |
proc_table[lev->activated].timespec_priority.tv_sec, |
proc_table[lev->activated].timespec_priority.tv_nsec, |
iq_query_timespec(lev->activated,&lev->wait)->tv_sec, |
iq_query_timespec(lev->activated,&lev->wait)->tv_nsec, |
lev->nact[lev->activated], |
DS_status_to_a(proc_table[lev->activated].status)); |
|
200,7 → 200,7 |
p, |
proc_table[p].name, |
DS_status_to_a(proc_table[p].status)); |
p = proc_table[p].next; |
p = iq_query_next(p, &lev->wait); |
} |
} |
|
221,7 → 221,7 |
if (lev->flags & DS_BACKGROUND_BLOCK) |
return NIL; |
else |
return qq_queryfirst(&lev->wait); |
return iq_query_first(&lev->wait); |
} |
|
/* The on-line guarantee is enabled only if the appropriate flag is set... */ |
275,14 → 275,6 |
return 0; /* if the task p is chosen, it is always eligible */ |
} |
|
#ifdef __TEST1__ |
extern int testactive; |
extern struct timespec s_stime[]; |
extern TIME s_curr[]; |
extern TIME s_PID[]; |
extern int useds; |
#endif |
|
static void DS_task_dispatch(LEVEL l, PID p, int nostop) |
{ |
DS_level_des *lev = (DS_level_des *)(level_table[l]); |
294,7 → 286,7 |
to exe before calling task_dispatch. we have to check |
lev->activated != p instead */ |
if (lev->activated != p) { |
qq_extract(p, &lev->wait); |
iq_extract(p, &lev->wait); |
//kern_printf("#%d#",p); |
} |
else { |
311,16 → 303,6 |
} |
|
// kern_printf("(disp %d %d)",ty.tv_sec, ty.tv_nsec); |
|
#ifdef __TEST1__ |
if (testactive) |
{ |
TIMESPEC_ASSIGN(&s_stime[useds], &schedule_time); |
s_curr[useds] = proc_table[p].avail_time; |
s_PID[useds] = p; |
useds++; |
} |
#endif |
} |
|
static void DS_task_epilogue(LEVEL l, PID p) |
356,7 → 338,7 |
if (lev->activated == p) |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level,p); |
qq_insertfirst(p, &lev->wait); |
iq_insertfirst(p, &lev->wait); |
proc_table[p].status = DS_WAIT; |
lev->activated = NIL; |
} |
367,7 → 349,7 |
level_table[ lev->scheduling_level ]-> |
guest_epilogue(lev->scheduling_level,p); |
} else { //kern_printf("Û2"); |
qq_insertfirst(p, &lev->wait); |
iq_insertfirst(p, &lev->wait); |
proc_table[p].status = DS_WAIT; |
} |
} |
388,7 → 370,7 |
DS_activation(lev); |
} |
else { |
qq_insertlast(p, &lev->wait); |
iq_insertlast(p, &lev->wait); |
proc_table[p].status = DS_WAIT; |
} |
} |
408,7 → 390,7 |
|
/* when we reinsert the task into the system, the server capacity |
is always 0 because nobody executes with the DS before... */ |
qq_insertfirst(p, &lev->wait); |
iq_insertfirst(p, &lev->wait); |
proc_table[p].status = DS_WAIT; |
} |
|
445,18 → 427,18 |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level,p); |
else |
qq_extract(p, &lev->wait); |
iq_extract(p, &lev->wait); |
|
if (lev->nact[p] > 0) |
{ |
lev->nact[p]--; |
qq_insertlast(p, &lev->wait); |
iq_insertlast(p, &lev->wait); |
proc_table[p].status = DS_WAIT; |
} |
else |
proc_table[p].status = SLEEP; |
|
lev->activated = qq_getfirst(&lev->wait); |
lev->activated = iq_getfirst(&lev->wait); |
if (lev->activated != NIL) |
DS_activation(lev); |
} |
481,9 → 463,9 |
guest_end(lev->scheduling_level,p); |
|
proc_table[p].status = FREE; |
q_insertfirst(p,&freedesc); |
iq_insertfirst(p,&freedesc); |
|
lev->activated = qq_getfirst(&lev->wait); |
lev->activated = iq_getfirst(&lev->wait); |
if (lev->activated != NIL) |
DS_activation(lev); |
} |
509,36 → 491,16 |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level,p); |
else |
qq_extract(p, &lev->wait); |
iq_extract(p, &lev->wait); |
|
proc_table[p].status = SLEEP; |
|
lev->activated = qq_getfirst(&lev->wait); |
lev->activated = iq_getfirst(&lev->wait); |
if (lev->activated != NIL) |
DS_activation(lev); |
} |
static void DS_task_delay(LEVEL l, PID p, TIME usdelay) |
{ |
DS_level_des *lev = (DS_level_des *)(level_table[l]); |
struct timespec ty; |
TIME tx; |
|
/* update the server capacity */ |
if (lev->flags & DS_BACKGROUND) |
lev->flags &= ~DS_BACKGROUND; |
else { |
SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty); |
tx = TIMESPEC2USEC(&ty); |
lev->availCs -= tx; |
} |
|
/* I hope no delay when owning a mutex... */ |
if (lev->activated == p) |
level_table[ lev->scheduling_level ]-> |
guest_delay(lev->scheduling_level,p,usdelay); |
} |
|
|
static int DS_guest_create(LEVEL l, PID p, TASK_MODEL *m) |
{ kern_raise(XINVALID_GUEST,exec_shadow); return 0; } |
|
569,12 → 531,9 |
static void DS_guest_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void DS_guest_delay(LEVEL l, PID p,DWORD tickdelay) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
|
|
|
/* Registration functions */ |
|
|
647,7 → 606,6 |
lev->l.task_endcycle = DS_task_endcycle; |
lev->l.task_end = DS_task_end; |
lev->l.task_sleep = DS_task_sleep; |
lev->l.task_delay = DS_task_delay; |
|
lev->l.guest_create = DS_guest_create; |
lev->l.guest_detach = DS_guest_detach; |
659,7 → 617,6 |
lev->l.guest_endcycle = DS_guest_endcycle; |
lev->l.guest_end = DS_guest_end; |
lev->l.guest_sleep = DS_guest_sleep; |
lev->l.guest_delay = DS_guest_delay; |
|
/* fill the DS descriptor part */ |
|
671,7 → 628,7 |
|
lev->period = per; |
|
qq_init(&lev->wait); |
iq_init(&lev->wait, &freedesc, 0); |
lev->activated = NIL; |
|
lev->U = (MAX_BANDWIDTH / per) * Cs; |