Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 211 → Rev 212

/shark/trunk/kernel/modules/edf.c
20,11 → 20,11
 
/**
------------
CVS : $Id: edf.c,v 1.5 2003-05-05 07:31:43 pj Exp $
CVS : $Id: edf.c,v 1.6 2003-07-23 09:59:28 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.5 $
Last update: $Date: 2003-05-05 07:31:43 $
Revision: $Revision: 1.6 $
Last update: $Date: 2003-07-23 09:59:28 $
------------
 
This file contains the scheduling module EDF (Earliest Deadline First)
75,7 → 75,10
/*+ flags +*/
#define EDF_FLAG_SPORADIC 1
#define EDF_FLAG_NORAISEEXC 2
#define EDF_FLAG_SLEEP 4
 
#undef EDFDEBUG
 
/*+ the level redefinition for the Earliest Deadline First level +*/
typedef struct {
level_des l; /*+ the standard level descriptor +*/
139,6 → 142,10
case EDF_WAIT:
/* Without this, the task cannot be reactivated!!! */
proc_table[p].status = SLEEP;
 
/* Reset the EDF_FLAG_SLEEP */
lev->flag[p] &= ~EDF_FLAG_SLEEP;
 
break;
 
default:
215,11 → 222,12
#endif
 
lev->period[p] = h->mit;
lev->flag[p] = 0;
 
if (h->periodicity == APERIODIC)
lev->flag[p] = EDF_FLAG_SPORADIC;
else
lev->flag[p] = 0;
lev->flag[p] |= EDF_FLAG_SPORADIC;
lev->deadline_timer[p] = -1;
 
/* Enable wcet check */
289,14 → 297,21
struct timespec *temp;
 
#ifdef EDFDEBUG
edf_printf("(act%d)", p);
edf_printf("(act%d sleep%d)", p, lev->flag[p]&EDF_FLAG_SLEEP);
#endif
 
if (lev->flag[p] & EDF_FLAG_SLEEP) {
lev->flag[p] &= ~EDF_FLAG_SLEEP;
if (!(lev->flag[p] & EDF_FLAG_SPORADIC))
proc_table[p].status = EDF_IDLE;
return;
}
 
if (proc_table[p].status == EDF_WAIT) {
kern_raise(XACTIVATION,p);
return;
}
 
/* Test if we are trying to activate a non sleeping task */
/* Ignore this; the task is already active */
if (proc_table[p].status != SLEEP &&
351,27 → 366,53
{
EDF_level_des *lev = (EDF_level_des *)(level_table[l]);
 
#ifdef EDFDEBUG
edf_printf("(ecyc p%d %d.%d)",p,(int)schedule_time.tv_sec,(int)schedule_time.tv_nsec/1000);
#endif
//task_message evaluation
switch((long)(m)) {
 
/* the task has terminated his job before it consume the wcet. All OK! */
if (!lev->flag[p] & EDF_FLAG_SPORADIC)
proc_table[p].status = EDF_IDLE;
else
proc_table[p].status = EDF_WAIT;
//task_endcycle
case (long)(NULL):
 
/* we reset the capacity counters... */
if (lev->flags & EDF_ENABLE_WCET_CHECK)
proc_table[p].avail_time = proc_table[p].wcet;
#ifdef EDFDEBUG
edf_printf("(ecyc p%d %d.%d)",p,(int)schedule_time.tv_sec,(int)schedule_time.tv_nsec/1000);
#endif
 
jet_update_endcycle(); /* Update the Jet data... */
trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */
/* the task has terminated his job before it consume the wcet. All OK! */
if (!(lev->flag[p] & EDF_FLAG_SPORADIC) &&
!(lev->flag[p] & EDF_FLAG_SLEEP))
proc_table[p].status = EDF_IDLE;
else
proc_table[p].status = EDF_WAIT;
 
/* when the deadline timer fire, it recognize the situation and set
correctly all the stuffs (like reactivation, sleep, etc... ) */
/* we reset the capacity counters... */
if (lev->flags & EDF_ENABLE_WCET_CHECK)
proc_table[p].avail_time = proc_table[p].wcet;
 
jet_update_endcycle(); /* Update the Jet data... */
trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */
 
break;
 
//task_disable
case 1:
 
#ifdef EDFDEBUG
edf_printf("(disable%d)",p);
#endif
 
/* Set the EDF_FLAG_SLEEP, in the next endcycle the task will
be set in EDF_WAIT */
lev->flag[p] |= EDF_FLAG_SLEEP;
 
/* If the task is EDF_IDLE, set to EDF_WAIT now */
if (proc_table[p].status == EDF_IDLE)
proc_table[p].status = EDF_WAIT;
 
break;
 
}
 
return 0;
 
}
 
static void EDF_public_end(LEVEL l, PID p)
/shark/trunk/kernel/modules/cbs.c
20,11 → 20,11
 
/**
------------
CVS : $Id: cbs.c,v 1.5 2003-05-05 07:31:43 pj Exp $
CVS : $Id: cbs.c,v 1.6 2003-07-23 09:59:11 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.5 $
Last update: $Date: 2003-05-05 07:31:43 $
Revision: $Revision: 1.6 $
Last update: $Date: 2003-07-23 09:59:11 $
------------
 
This file contains the aperiodic server CBS (Total Bandwidth Server)
80,6 → 80,7
/*+ task flags +*/
#define CBS_SAVE_ARRIVALS 1
#define CBS_APERIODIC 2
#define CBS_SLEEP 4
 
/*+ the level redefinition for the Total Bandwidth Server level +*/
typedef struct {
145,7 → 146,7
/* if (TIMESPEC_A_LT_B(&lev->cbs_dline[p], acttime) )
kern_printf("$");
else
kern_printf("(Ûdline%d.%d act%d.%d wcet%d per%d avail%dÛ)",
kern_printf("(Ûdline%d.%d act%d.%d wcet%d per%d avail%dÛ)",
lev->cbs_dline[p].tv_sec,lev->cbs_dline[p].tv_nsec/1000,
acttime->tv_sec, acttime->tv_nsec/1000,
proc_table[p].wcet, lev->period[p], proc_table[p].avail_time);
210,6 → 211,13
if (p==5) cbs_counter++;
#endif
 
if (lev->flag[p] & CBS_SLEEP && proc_table[p].status == CBS_IDLE) {
proc_table[p].status = SLEEP;
proc_table[p].avail_time = proc_table[p].wcet;
NULL_TIMESPEC(&lev->cbs_dline[p]);
return;
}
 
if (proc_table[p].status == CBS_IDLE) {
/* the task has finished the current activation and must be
reactivated */
400,6 → 408,11
CBS_level_des *lev = (CBS_level_des *)(level_table[l]);
struct timespec t;
 
if (lev->flag[p] & CBS_SLEEP) {
lev->flag[p] &= ~CBS_SLEEP;
if (proc_table[p].status != SLEEP) return;
}
 
/* save activation (only if needed... */
if (proc_table[p].status != SLEEP) {
if (lev->flag[p] & CBS_SAVE_ARRIVALS)
456,29 → 469,43
{
CBS_level_des *lev = (CBS_level_des *)(level_table[l]);
 
/* check if the wcet is finished... */
CBS_avail_time_check(lev, p);
switch((long)(m)) {
 
if (lev->nact[p]) {
/* continue!!!! */
lev->nact[p]--;
level_table[ lev->scheduling_level ]->
private_epilogue(lev->scheduling_level,p);
}
else {
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level,p);
case (long)(NULL):
 
if (lev->flag[p] & CBS_APERIODIC)
proc_table[p].status = SLEEP;
else /* the task is soft_periodic */
proc_table[p].status = CBS_IDLE;
/* check if the wcet is finished... */
CBS_avail_time_check(lev, p);
 
if (lev->nact[p]) {
/* continue!!!! */
lev->nact[p]--;
level_table[ lev->scheduling_level ]->
private_epilogue(lev->scheduling_level,p);
} else {
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level,p);
 
if (lev->flag[p] & CBS_APERIODIC)
proc_table[p].status = SLEEP;
else /* the task is soft_periodic */
proc_table[p].status = CBS_IDLE;
}
 
jet_update_endcycle(); /* Update the Jet data... */
trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */
 
break;
 
case 1:
 
lev->flag[p] |= CBS_SLEEP;
 
break;
 
}
 
jet_update_endcycle(); /* Update the Jet data... */
trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */
return 0;
 
return 0;
}
 
static void CBS_public_end(LEVEL l, PID p)