Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 158 → Rev 159

/shark/trunk/kernel/modules/edf.c
20,11 → 20,11
 
/**
------------
CVS : $Id: edf.c,v 1.4 2003-01-07 17:07:50 pj Exp $
CVS : $Id: edf.c,v 1.5 2003-05-05 07:31:43 pj Exp $
 
File: $File$
Revision: $Revision: 1.4 $
Last update: $Date: 2003-01-07 17:07:50 $
Revision: $Revision: 1.5 $
Last update: $Date: 2003-05-05 07:31:43 $
------------
 
This file contains the scheduling module EDF (Earliest Deadline First)
178,18 → 178,12
{
EDF_level_des *lev = (EDF_level_des *)(level_table[l]);
 
if (lev->flags & EDF_FAILED_GUARANTEE) {
*freebandwidth = 0;
return 0;
if (*freebandwidth >= lev->U) {
*freebandwidth -= lev->U;
return 1;
}
else
if (*freebandwidth >= lev->U) {
*freebandwidth -= lev->U;
return 1;
}
else
return 0;
 
return 0;
}
 
static int EDF_public_create(LEVEL l, PID p, TASK_MODEL *m)
201,6 → 195,19
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
222,30 → 229,6
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... */
}
 
252,8 → 235,7
static void EDF_public_detach(LEVEL l, PID p)
{
/* the EDF level doesn't introduce any dinamic allocated new field.
we have only to reset the NO_GUARANTEE FIELD and decrement the allocated
bandwidth */
we have only to decrement the allocated bandwidth */
 
EDF_level_des *lev = (EDF_level_des *)(level_table[l]);
 
261,10 → 243,9
edf_printf("(det%d)", p);
#endif
 
if (lev->flags & EDF_FAILED_GUARANTEE)
lev->flags &= ~EDF_FAILED_GUARANTEE;
else
if (lev->flags & EDF_ENABLE_GUARANTEE) {
lev->U -= (MAX_BANDWIDTH / lev->period[p]) * proc_table[p].wcet;
}
}
 
static void EDF_public_dispatch(LEVEL l, PID p, int nostop)
520,7 → 501,7
}
 
iq_init(&lev->ready, &freedesc, 0);
lev->flags = flags & 0x07;
lev->flags = flags;
lev->U = 0;
 
return l;
/shark/trunk/kernel/modules/cbs.c
20,11 → 20,11
 
/**
------------
CVS : $Id: cbs.c,v 1.4 2003-01-07 17:07:50 pj Exp $
CVS : $Id: cbs.c,v 1.5 2003-05-05 07:31:43 pj Exp $
 
File: $File$
Revision: $Revision: 1.4 $
Last update: $Date: 2003-01-07 17:07:50 $
Revision: $Revision: 1.5 $
Last update: $Date: 2003-05-05 07:31:43 $
------------
 
This file contains the aperiodic server CBS (Total Bandwidth Server)
259,17 → 259,12
{
CBS_level_des *lev = (CBS_level_des *)(level_table[l]);
 
if (lev->flags & CBS_FAILED_GUARANTEE) {
*freebandwidth = 0;
return 0;
if (*freebandwidth >= lev->U) {
*freebandwidth -= lev->U;
return 1;
}
else
if (*freebandwidth >= lev->U) {
*freebandwidth -= lev->U;
return 1;
}
else
return 0;
return 0;
}
 
static int CBS_public_create(LEVEL l, PID p, TASK_MODEL *m)
284,6 → 279,17
 
soft = (SOFT_TASK_MODEL *)m;
 
if (lev->flags & CBS_ENABLE_GUARANTEE) {
bandwidth_t b;
b = (MAX_BANDWIDTH / soft->period) * soft->met;
 
/* really update lev->U, checking an overflow... */
if (MAX_BANDWIDTH - lev->U > b)
lev->U += b;
else
return -1;
}
 
/* Enable wcet check */
proc_table[p].avail_time = soft->met;
proc_table[p].wcet = soft->met;
301,21 → 307,6
if (soft->arrivals == SAVE_ARRIVALS)
lev->flag[p] |= CBS_SAVE_ARRIVALS;
 
/* update the bandwidth... */
if (lev->flags & CBS_ENABLE_GUARANTEE) {
bandwidth_t b;
b = (MAX_BANDWIDTH / soft->period) * soft->met;
 
/* 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)...
(see EDF.c) */
lev->flags |= CBS_FAILED_GUARANTEE;
}
 
 
return 0; /* OK, also if the task cannot be guaranteed... */
}
 
322,15 → 313,13
static void CBS_public_detach(LEVEL l, PID p)
{
/* the CBS level doesn't introduce any dinamic allocated new field.
we have only to reset the NO_GUARANTEE FIELD and decrement the allocated
bandwidth */
we have only to decrement the allocated bandwidth */
 
CBS_level_des *lev = (CBS_level_des *)(level_table[l]);
 
if (lev->flags & CBS_FAILED_GUARANTEE)
lev->flags &= ~CBS_FAILED_GUARANTEE;
else
if (lev->flags & CBS_ENABLE_GUARANTEE) {
lev->U -= (MAX_BANDWIDTH / lev->period[p]) * proc_table[p].wcet;
}
}
 
static int CBS_public_eligible(LEVEL l, PID p)
566,7 → 555,7
 
lev->scheduling_level = master;
 
lev->flags = flags & 0x01;
lev->flags = flags;
 
return l;
}
/shark/trunk/kernel/modules/rm.c
20,11 → 20,11
 
/**
------------
CVS : $Id: rm.c,v 1.4 2003-01-07 17:07:50 pj Exp $
CVS : $Id: rm.c,v 1.5 2003-05-05 07:31:44 pj Exp $
 
File: $File$
Revision: $Revision: 1.4 $
Last update: $Date: 2003-01-07 17:07:50 $
Revision: $Revision: 1.5 $
Last update: $Date: 2003-05-05 07:31:44 $
------------
 
This file contains the scheduling module RM (Rate Monotonic)
168,18 → 168,12
{
RM_level_des *lev = (RM_level_des *)(level_table[l]);
 
if (lev->flags & RM_FAILED_GUARANTEE) {
*freebandwidth = 0;
return 0;
if (*freebandwidth >= lev->U) {
*freebandwidth -= lev->U;
return 1;
}
else
if (*freebandwidth >= lev->U) {
*freebandwidth -= lev->U;
return 1;
}
else
return 0;
 
return 0;
}
 
static int RM_public_create(LEVEL l, PID p, TASK_MODEL *m)
192,6 → 186,19
if (m->level != 0 && m->level != l) return -1;
h = (HARD_TASK_MODEL *)m;
if (!h->wcet || !h->mit) return -1;
 
/* update the bandwidth... */
if (lev->flags & RM_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 */
 
*iq_query_priority(p, &lev->ready) = lev->period[p] = h->mit;
209,30 → 216,6
proc_table[p].control |= CONTROL_CAP;
}
 
/* update the bandwidth... */
if (lev->flags & RM_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
RM_task_create the task_create will call level_guarantee that return
-1... return -1 in RM_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 |= RM_FAILED_GUARANTEE;
}
 
return 0; /* OK, also if the task cannot be guaranteed... */
}
 
244,10 → 227,9
 
RM_level_des *lev = (RM_level_des *)(level_table[l]);
 
if (lev->flags & RM_FAILED_GUARANTEE)
lev->flags &= ~RM_FAILED_GUARANTEE;
else
if (lev->flags & RM_ENABLE_GUARANTEE) {
lev->U -= (MAX_BANDWIDTH / lev->period[p]) * proc_table[p].wcet;
}
}
 
static void RM_public_dispatch(LEVEL l, PID p, int nostop)
488,7 → 470,7
}
 
iq_init(&lev->ready, &freedesc, 0);
lev->flags = flags & 0x07;
lev->flags = flags;
lev->U = 0;
 
return l;
/shark/trunk/include/modules/edf.h
21,11 → 21,11
 
/**
------------
CVS : $Id: edf.h,v 1.3 2003-03-13 13:39:04 pj Exp $
CVS : $Id: edf.h,v 1.4 2003-05-05 07:31:12 pj Exp $
 
File: $File$
Revision: $Revision: 1.3 $
Last update: $Date: 2003-03-13 13:39:04 $
Revision: $Revision: 1.4 $
Last update: $Date: 2003-05-05 07:31:12 $
------------
 
This file contains the scheduling module EDF (Earliest Deadline First)
134,10 → 134,7
#define EDF_ENABLE_GUARANTEE 2 /*+ Task Guarantee enabled +*/
#define EDF_ENABLE_ALL 3 /*+ All flags enabled +*/
 
#define EDF_FAILED_GUARANTEE 8 /*+ used in the module, unsettable
in EDF_register_level... +*/
 
 
/*+ Registration function:
int flag Options to be used in this level instance...
 
/shark/trunk/include/modules/cbs.h
21,11 → 21,11
 
/**
------------
CVS : $Id: cbs.h,v 1.3 2003-03-13 13:39:04 pj Exp $
CVS : $Id: cbs.h,v 1.4 2003-05-05 07:31:12 pj Exp $
 
File: $File$
Revision: $Revision: 1.3 $
Last update: $Date: 2003-03-13 13:39:04 $
Revision: $Revision: 1.4 $
Last update: $Date: 2003-05-05 07:31:12 $
------------
 
This file contains the aperiodic server CBS (Total Bandwidth Server)
112,9 → 112,6
#define CBS_ENABLE_GUARANTEE 1 /*+ Task Guarantee enabled +*/
#define CBS_ENABLE_ALL 1
 
#define CBS_FAILED_GUARANTEE 8 /*+ used in the module, unsettable
in EDF_register_level... +*/
 
/*+ Registration function:
int flags Options to be used in this level instance...
LEVEL master the level that must be used as master level for the
/shark/trunk/include/modules/rm.h
21,11 → 21,11
 
/**
------------
CVS : $Id: rm.h,v 1.3 2003-03-13 13:39:04 pj Exp $
CVS : $Id: rm.h,v 1.4 2003-05-05 07:31:12 pj Exp $
 
File: $File$
Revision: $Revision: 1.3 $
Last update: $Date: 2003-03-13 13:39:04 $
Revision: $Revision: 1.4 $
Last update: $Date: 2003-05-05 07:31:12 $
------------
 
This file contains the scheduling module RM (Rate Monotonic)
140,10 → 140,6
#define RM_ENABLE_GUARANTEE 2 /*+ Task Guarantee enabled +*/
#define RM_ENABLE_ALL 3 /*+ All flags enabled +*/
 
#define RM_FAILED_GUARANTEE 8 /*+ used in the module, unsettable
in RM_register_level... +*/
 
 
/*+ Registration function:
int flag Options to be used in this level instance...