Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 158 → Rev 159

/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;