Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 28 → Rev 29

/shark/trunk/kernel/modules/ss.c
20,11 → 20,11
 
/**
------------
CVS : $Id: ss.c,v 1.2 2002-10-28 07:55:55 pj Exp $
CVS : $Id: ss.c,v 1.3 2002-11-11 08:32:07 pj Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2002-10-28 07:55:55 $
Revision: $Revision: 1.3 $
Last update: $Date: 2002-11-11 08:32:07 $
------------
 
This file contains the aperiodic Sporadic Server (SS).
155,7 → 155,7
bandwidth_t U; /*+ the used bandwidth by the server +*/
 
QQUEUE wait; /*+ the wait queue of the SS +*/
IQUEUE wait; /*+ the wait queue of the SS +*/
PID activated; /*+ the task inserted in another queue +*/
 
int flags; /*+ the init flags... +*/
465,8 → 465,8
}
 
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);
/* if server is active, replenish time already set */
if (lev->server_active == SS_SERVER_NOTACTIVE) {
lev->server_active = SS_SERVER_ACTIVE;
536,7 → 536,7
void SS_level_status(LEVEL l)
{
SS_level_des *lev = (SS_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",
(lev->flags & SS_ENABLE_GUARANTEE_EDF ||
554,8 → 554,8
kern_printf("Activated: Pid: %d 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],
SS_status_to_a(proc_table[lev->activated].status));
 
564,7 → 564,7
p,
proc_table[p].name,
SS_status_to_a(proc_table[p].status));
p = proc_table[p].next;
p = iq_query_next(p, &lev->wait);
}
}
 
593,7 → 593,7
if (lev->flags & SS_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... */
696,7 → 696,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);
#ifdef DEBUG
kern_printf("extr task:%d ",p);
#endif
779,7 → 779,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 = SS_WAIT;
lev->activated = NIL;
}
793,7 → 793,7
guest_epilogue(lev->scheduling_level,p);
}
else { /* goes into wait queue */
qq_insertfirst(p, &lev->wait);
iq_insertfirst(p, &lev->wait);
proc_table[p].status = SS_WAIT;
}
}
833,7 → 833,7
SS_activation(lev);
}
else {
qq_insertlast(p, &lev->wait);
iq_insertlast(p, &lev->wait);
proc_table[p].status = SS_WAIT;
}
}
860,7 → 860,7
 
/* when we reinsert the task into the system, the server capacity
is always 0 because nobody executes with the SS before... */
qq_insertfirst(p, &lev->wait);
iq_insertfirst(p, &lev->wait);
proc_table[p].status = SS_WAIT;
}
 
912,11 → 912,11
if (lev->activated == p)
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 = SS_WAIT;
}
else {
923,7 → 923,7
proc_table[p].status = SLEEP;
}
lev->activated = qq_getfirst(&lev->wait);
lev->activated = iq_getfirst(&lev->wait);
if (lev->activated != NIL) {
SS_activation(lev);
}
962,9 → 962,9
level_table[lev->scheduling_level]->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) {
SS_activation(lev);
}
1004,11 → 1004,11
if (lev->activated == p)
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) {
SS_activation(lev);
}
1020,41 → 1020,7
}
}
 
static void SS_task_delay(LEVEL l, PID p, TIME usdelay)
{
SS_level_des *lev = (SS_level_des *)(level_table[l]);
struct timespec ty;
int tx;
 
#ifdef DEBUG
kern_printf("SS_tdelay ");
#endif
 
/* update the server capacity */
if (BACKGROUND_ON)
lev->flags &= ~SS_BACKGROUND;
else {
 
SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty);
tx = TIMESPEC2USEC(&ty);
lev->availCs -= tx;
lev->replenish_amount += tx;
#ifdef DEBUG
kern_printf("PID:%d RA=%d ",p,lev->replenish_amount);
#endif
 
/* Here set replenish amount because delay may be too long and
replenish time could arrive */
SS_set_ra(l);
}
 
/* I hope no delay when owning a mutex... */
if (lev->activated == p)
level_table[ lev->scheduling_level ]->
guest_delay(lev->scheduling_level,p,usdelay);
}
 
 
/*-------------------------------------------------------------------*/
 
/*** Guest functions ***/
1092,10 → 1058,7
static void SS_guest_sleep(LEVEL l, PID p)
{ kern_raise(XINVALID_GUEST,exec_shadow); }
 
static void SS_guest_delay(LEVEL l, PID p,DWORD tickdelay)
{ kern_raise(XINVALID_GUEST,exec_shadow); }
 
 
/*-------------------------------------------------------------------*/
 
/*** Registration functions ***/
1153,7 → 1116,6
lev->l.task_endcycle = SS_task_endcycle;
lev->l.task_end = SS_task_end;
lev->l.task_sleep = SS_task_sleep;
lev->l.task_delay = SS_task_delay;
 
lev->l.guest_create = SS_guest_create;
lev->l.guest_detach = SS_guest_detach;
1165,7 → 1127,6
lev->l.guest_endcycle = SS_guest_endcycle;
lev->l.guest_end = SS_guest_end;
lev->l.guest_sleep = SS_guest_sleep;
lev->l.guest_delay = SS_guest_delay;
 
/* fill the SS descriptor part */
 
1177,7 → 1138,7
 
lev->period = per;
 
qq_init(&lev->wait);
iq_init(&lev->wait, &freedesc, 0);
lev->activated = NIL;
 
lev->U = (MAX_BANDWIDTH / per) * Cs;