20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: ps.c,v 1.1.1.1 2002-03-29 14:12:52 pj Exp $ |
CVS : $Id: ps.c,v 1.3 2002-11-11 08:32:06 pj Exp $ |
|
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:52 $ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2002-11-11 08:32:06 $ |
------------ |
|
This file contains the aperiodic server PS (Polling Server) |
122,7 → 122,7 |
int Cs; /*+ server capacity +*/ |
int availCs; /*+ server avail time +*/ |
|
QQUEUE wait; /*+ the wait queue of the PS +*/ |
IQUEUE wait; /*+ the wait queue of the PS +*/ |
PID activated; /*+ the task inserted in another queue +*/ |
|
int flags; /*+ the init flags... +*/ |
167,8 → 167,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); |
PS_activation(lev); |
event_need_reschedule(); |
} |
219,7 → 219,7 |
static void PS_level_status(LEVEL l) |
{ |
PS_level_des *lev = (PS_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 & PS_ENABLE_GUARANTEE_EDF || |
231,8 → 231,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], |
PS_status_to_a(proc_table[lev->activated].status)); |
|
241,7 → 241,7 |
p, |
proc_table[p].name, |
PS_status_to_a(proc_table[p].status)); |
p = proc_table[p].next; |
p = iq_query_next(p, &lev->wait); |
} |
} |
|
262,7 → 262,7 |
if (lev->flags & PS_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... */ |
316,14 → 316,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 PS_task_dispatch(LEVEL l, PID p, int nostop) |
{ |
PS_level_des *lev = (PS_level_des *)(level_table[l]); |
335,7 → 327,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 { |
352,16 → 344,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 PS_task_epilogue(LEVEL l, PID p) |
397,7 → 379,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 = PS_WAIT; |
lev->activated = NIL; |
} |
408,7 → 390,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 = PS_WAIT; |
} |
} |
429,7 → 411,7 |
PS_activation(lev); |
} |
else { |
qq_insertlast(p, &lev->wait); |
iq_insertlast(p, &lev->wait); |
proc_table[p].status = PS_WAIT; |
} |
} |
449,7 → 431,7 |
|
/* when we reinsert the task into the system, the server capacity |
is always 0 because nobody executes with the PS before... */ |
qq_insertfirst(p, &lev->wait); |
iq_insertfirst(p, &lev->wait); |
proc_table[p].status = PS_WAIT; |
} |
|
486,18 → 468,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 = PS_WAIT; |
} |
else |
proc_table[p].status = SLEEP; |
|
lev->activated = qq_getfirst(&lev->wait); |
lev->activated = iq_getfirst(&lev->wait); |
if (lev->activated == NIL) |
lev->availCs = 0; /* see note (*) at the begin of the file */ |
else |
524,9 → 506,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) |
lev->availCs = 0; /* see note (*) at the begin of the file */ |
else |
554,74 → 536,51 |
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) |
lev->availCs = 0; /* see note (*) at the begin of the file */ |
else |
PS_activation(lev); |
} |
static void PS_task_delay(LEVEL l, PID p, TIME usdelay) |
{ |
PS_level_des *lev = (PS_level_des *)(level_table[l]); |
struct timespec ty; |
TIME tx; |
|
/* update the server capacity */ |
if (lev->flags & PS_BACKGROUND) |
lev->flags &= ~PS_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 PS_guest_create(LEVEL l, PID p, TASK_MODEL *m) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); return 0; } |
{ kern_raise(XINVALID_GUEST,exec_shadow); return 0; } |
|
static void PS_guest_detach(LEVEL l, PID p) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void PS_guest_dispatch(LEVEL l, PID p, int nostop) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void PS_guest_epilogue(LEVEL l, PID p) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void PS_guest_activate(LEVEL l, PID p) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void PS_guest_insert(LEVEL l, PID p) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void PS_guest_extract(LEVEL l, PID p) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void PS_guest_endcycle(LEVEL l, PID p) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void PS_guest_end(LEVEL l, PID p) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void PS_guest_sleep(LEVEL l, PID p) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void PS_guest_delay(LEVEL l, PID p,DWORD tickdelay) |
{ kern_raise(XUNVALID_GUEST,exec_shadow); } |
|
|
|
|
/* Registration functions */ |
|
|
694,7 → 653,6 |
lev->l.task_endcycle = PS_task_endcycle; |
lev->l.task_end = PS_task_end; |
lev->l.task_sleep = PS_task_sleep; |
lev->l.task_delay = PS_task_delay; |
|
lev->l.guest_create = PS_guest_create; |
lev->l.guest_detach = PS_guest_detach; |
706,7 → 664,6 |
lev->l.guest_endcycle = PS_guest_endcycle; |
lev->l.guest_end = PS_guest_end; |
lev->l.guest_sleep = PS_guest_sleep; |
lev->l.guest_delay = PS_guest_delay; |
|
/* fill the PS descriptor part */ |
|
718,7 → 675,7 |
|
lev->period = per; |
|
qq_init(&lev->wait); |
iq_init(&lev->wait, &freedesc, 0); |
lev->activated = NIL; |
|
lev->U = (MAX_BANDWIDTH / per) * Cs; |