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.4 2003-01-07 17:07:50 pj Exp $ |
|
File: $File$ |
Revision: $Revision: 1.5 $ |
Last update: $Date: 2003-05-05 07:31:43 $ |
Revision: $Revision: 1.4 $ |
Last update: $Date: 2003-01-07 17:07:50 $ |
------------ |
|
This file contains the scheduling module EDF (Earliest Deadline First) |
178,6 → 178,11 |
{ |
EDF_level_des *lev = (EDF_level_des *)(level_table[l]); |
|
if (lev->flags & EDF_FAILED_GUARANTEE) { |
*freebandwidth = 0; |
return 0; |
} |
else |
if (*freebandwidth >= lev->U) { |
*freebandwidth -= lev->U; |
return 1; |
184,6 → 189,7 |
} |
else |
return 0; |
|
} |
|
static int EDF_public_create(LEVEL l, PID p, TASK_MODEL *m) |
195,19 → 201,6 |
if (m->level != 0 && m->level != l) return -1; |
h = (HARD_TASK_MODEL *)m; |
if (!h->wcet || !h->mit) return -1; |
|
/* check the free bandwidth... */ |
if (lev->flags & EDF_ENABLE_GUARANTEE) { |
bandwidth_t b; |
b = (MAX_BANDWIDTH / h->mit) * h->wcet; |
|
/* really update lev->U, checking an overflow... */ |
if (MAX_BANDWIDTH - lev->U > b) |
lev->U += b; |
else |
return -1; |
} |
|
/* now we know that m is a valid model */ |
|
#ifdef EDFDEBUG |
229,6 → 222,30 |
proc_table[p].control |= CONTROL_CAP; |
} |
|
/* update the bandwidth... */ |
if (lev->flags & EDF_ENABLE_GUARANTEE) { |
bandwidth_t b; |
b = (MAX_BANDWIDTH / h->mit) * h->wcet; |
|
/* really update lev->U, checking an overflow... */ |
if (MAX_BANDWIDTH - lev->U > b) |
lev->U += b; |
else |
/* The task can NOT be guaranteed (U>MAX_BANDWIDTH)... |
in this case, we don't raise an exception... in fact, after the |
EDF_task_create the task_create will call level_guarantee that return |
-1... return -1 in EDF_task_create isn't correct, because: |
. generally, the guarantee must be done when also the resources |
are registered |
. returning -1 will cause the task_create to return with an errno |
ETASK_CREATE instead of ENO_GUARANTEE!!! |
|
Why I use the flag??? because if the lev->U overflows, if i.e. I set |
it to MAX_BANDWIDTH, I lose the correct allocated bandwidth... |
*/ |
lev->flags |= EDF_FAILED_GUARANTEE; |
} |
|
return 0; /* OK, also if the task cannot be guaranteed... */ |
} |
|
235,7 → 252,8 |
static void EDF_public_detach(LEVEL l, PID p) |
{ |
/* the EDF level doesn't introduce any dinamic allocated new field. |
we have only to decrement the allocated bandwidth */ |
we have only to reset the NO_GUARANTEE FIELD and decrement the allocated |
bandwidth */ |
|
EDF_level_des *lev = (EDF_level_des *)(level_table[l]); |
|
243,10 → 261,11 |
edf_printf("(det%d)", p); |
#endif |
|
if (lev->flags & EDF_ENABLE_GUARANTEE) { |
if (lev->flags & EDF_FAILED_GUARANTEE) |
lev->flags &= ~EDF_FAILED_GUARANTEE; |
else |
lev->U -= (MAX_BANDWIDTH / lev->period[p]) * proc_table[p].wcet; |
} |
} |
|
static void EDF_public_dispatch(LEVEL l, PID p, int nostop) |
{ |
501,7 → 520,7 |
} |
|
iq_init(&lev->ready, &freedesc, 0); |
lev->flags = flags; |
lev->flags = flags & 0x07; |
lev->U = 0; |
|
return l; |