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) |