20,11 → 20,11 |
|
/* |
------------ |
CVS : $Id: cbsstar.c,v 1.3 2002-11-11 08:17:59 pj Exp $ |
CVS : $Id: cbsstar.c,v 1.4 2003-01-07 17:10:16 pj Exp $ |
|
File: $File$ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2002-11-11 08:17:59 $ |
Revision: $Revision: 1.4 $ |
Last update: $Date: 2003-01-07 17:10:16 $ |
------------ |
|
Read CBSSTAR.h for general details. |
77,7 → 77,7 |
|
//#define CBSSTAR_DEBUG |
|
#ifdef CBSSTAR_DEBUF |
#ifdef CBSSTAR_DEBUG |
|
static __inline__ void fake_printf(char *fmt, ...) {} |
|
206,10 → 206,7 |
job_task_default_model(job, b->dline); |
job_task_def_noexc(job); |
level_table[ lev->scheduling_level ]-> |
guest_create(lev->scheduling_level, p, (TASK_MODEL *)&job); |
level_table[ lev->scheduling_level ]-> |
guest_activate(lev->scheduling_level, p); |
|
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
} |
|
|
228,35 → 225,8 |
} |
|
|
static int CBSSTAR_level_accept_task_model(LEVEL l, TASK_MODEL *m) |
{ |
return -1; |
} |
|
static int CBSSTAR_level_accept_guest_model(LEVEL l, TASK_MODEL *m) |
{ |
if (m->pclass == BUDGET_PCLASS || m->pclass == (BUDGET_PCLASS | l)) { |
return 0; |
} |
|
return -1; |
} |
|
|
static void CBSSTAR_level_status(LEVEL l) |
{ |
kern_printf("CBSSTAR level_status (level %d)\n", l); |
} |
|
static PID CBSSTAR_level_scheduler(LEVEL l) |
{ |
/* the CBSSTAR don't schedule anything... |
it's an EDF level or similar that do it! */ |
return NIL; |
} |
|
/* The on-line guarantee is enabled only if the appropriate flag is set... */ |
static int CBSSTAR_level_guarantee(LEVEL l, bandwidth_t *freebandwidth) |
static int CBSSTAR_public_guarantee(LEVEL l, bandwidth_t *freebandwidth) |
{ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
|
272,19 → 242,8 |
return 0; |
} |
|
static int CBSSTAR_task_create(LEVEL l, PID p, TASK_MODEL *m) |
static int CBSSTAR_private_eligible(LEVEL l, PID p) |
{ |
kern_raise(XINVALID_TASK,exec_shadow); |
return 0; /* OK, also if the task cannot be guaranteed... */ |
} |
|
static void CBSSTAR_task_detach(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
|
static int CBSSTAR_task_eligible(LEVEL l, PID p) |
{ |
/* this function is never called! ... maybe I should remove it? */ |
#if 0 |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
struct budget_struct *b = &lev->b[lev->tb[p]]; |
JOB_TASK_MODEL job; |
303,7 → 262,7 |
if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time) ) { |
/* we kill the current activation */ |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level, p); |
private_extract(lev->scheduling_level, p); |
|
/* we modify the deadline ... */ |
TIMESPEC_ASSIGN(&b->dline, &schedule_time); |
322,9 → 281,7 |
job_task_default_model(job, b->dline); |
job_task_def_noexc(job); |
level_table[ lev->scheduling_level ]-> |
guest_create(lev->scheduling_level, p, (TASK_MODEL *)&job); |
level_table[ lev->scheduling_level ]-> |
guest_activate(lev->scheduling_level, p); |
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
|
return -1; |
} |
332,35 → 289,10 |
cbsstar_printf(")"); |
#endif |
|
#endif |
return 0; |
} |
|
static void CBSSTAR_task_dispatch(LEVEL l, PID p, int nostop) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
|
static void CBSSTAR_task_epilogue(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
|
static void CBSSTAR_task_activate(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
|
static void CBSSTAR_task_insert(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
|
static void CBSSTAR_task_extract(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
|
static void CBSSTAR_task_endcycle(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
|
static void CBSSTAR_task_end(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
|
static void CBSSTAR_task_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
|
static int CBSSTAR_guest_create(LEVEL l, PID p, TASK_MODEL *m) |
static void CBSSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m) |
{ |
/* A task has been activated for some reason. Basically, the task is |
inserted in the queue if the queue is empty, otherwise the task is |
367,8 → 299,15 |
inserted into the master module, and an oslib event is posted. */ |
|
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
BUDGET_TASK_MODEL *budget = (BUDGET_TASK_MODEL *)m; |
BUDGET_TASK_MODEL *budget; |
|
if (m->pclass != BUDGET_PCLASS || |
(m->level != 0 && m->level != l)) { |
kern_raise(XINVALID_TASK, p); |
return; |
} |
budget = (BUDGET_TASK_MODEL *)m; |
|
#ifdef CBSSTAR_DEBUG |
cbsstar_printf("(C:gcr %d b%d", p, budget->b); |
#endif |
379,7 → 318,7 |
/* This is the first task in the budget, |
the task have to be inserted into the master module */ |
struct timespec t; |
ll_gettime(TIME_EXACT, &t); |
kern_gettime(&t); |
CBSSTAR_activation(lev,p,&t); |
} else { |
/* The budget is not empty, another task is already into the |
394,11 → 333,9 |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(")"); |
#endif |
|
return 0; |
} |
|
static void CBSSTAR_guest_end(LEVEL l, PID p) |
static void CBSSTAR_private_extract(LEVEL l, PID p) |
{ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
|
416,7 → 353,7 |
if (lev->b[lev->tb[p]].current == p) { |
/* remove the task from the master module */ |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level, p); |
private_extract(lev->scheduling_level, p); |
|
#ifdef CBSSTAR_DEBUG |
cbsstar_printq(&lev->b[lev->tb[p]].tasks); |
432,7 → 369,7 |
PID n; |
struct timespec t; |
|
ll_gettime(TIME_EXACT, &t); |
kern_gettime(&t); |
n = iq_getfirst(&lev->b[lev->tb[p]].tasks); |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf("{p%d n%d}",p,n); |
444,7 → 381,7 |
iq_extract(p, &lev->b[lev->tb[p]].tasks); |
} |
|
static void CBSSTAR_guest_dispatch(LEVEL l, PID p, int nostop) |
static void CBSSTAR_private_dispatch(LEVEL l, PID p, int nostop) |
{ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
struct timespec ty; |
461,7 → 398,7 |
|
/* ... then, we dispatch it to the master level */ |
level_table[ lev->scheduling_level ]-> |
guest_dispatch(lev->scheduling_level,p,nostop); |
private_dispatch(lev->scheduling_level,p,nostop); |
|
/* ...and finally, we have to post a capacity event */ |
if (!nostop) { |
471,7 → 408,7 |
} |
} |
|
static void CBSSTAR_guest_epilogue(LEVEL l, PID p) |
static void CBSSTAR_private_epilogue(LEVEL l, PID p) |
{ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
struct budget_struct *b = &lev->b[lev->tb[p]]; |
487,7 → 424,7 |
/* there is capacity available, maybe it is simply a preemption; |
the task have to return to the ready queue */ |
level_table[ lev->scheduling_level ]-> |
guest_epilogue(lev->scheduling_level,p); |
private_epilogue(lev->scheduling_level,p); |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf2(" *av=%d", b->avail); |
#endif |
498,7 → 435,7 |
|
/* we kill the current activation */ |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level, p); |
private_extract(lev->scheduling_level, p); |
|
/* we modify the deadline according to rule 4 ... */ |
/* there is a while because if the wcet is << than the system tick |
520,9 → 457,7 |
job_task_default_model(job, b->dline); |
job_task_def_noexc(job); |
level_table[ lev->scheduling_level ]-> |
guest_create(lev->scheduling_level, p, (TASK_MODEL *)&job); |
level_table[ lev->scheduling_level ]-> |
guest_activate(lev->scheduling_level, p); |
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
} |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(")"); |
529,27 → 464,7 |
#endif |
} |
|
static void CBSSTAR_guest_detach(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void CBSSTAR_guest_activate(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void CBSSTAR_guest_insert(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void CBSSTAR_guest_extract(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void CBSSTAR_guest_endcycle(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void CBSSTAR_guest_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
|
|
|
/* Registration functions */ |
|
/*+ Registration function: |
565,56 → 480,21 |
#endif |
|
/* request an entry in the level_table */ |
l = level_alloc_descriptor(); |
l = level_alloc_descriptor(sizeof(CBSSTAR_level_des)); |
|
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(" alloco descrittore %d %d\n",l,(int)sizeof(CBSSTAR_level_des)); |
#endif |
lev = (CBSSTAR_level_des *)level_table[l]; |
|
/* alloc the space needed for the CBSSTAR_level_des */ |
lev = (CBSSTAR_level_des *)kern_alloc(sizeof(CBSSTAR_level_des)); |
printk(" lev=%d\n",(int)lev); |
|
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(" lev=%d\n",(int)lev); |
#endif |
|
/* update the level_table with the new entry */ |
level_table[l] = (level_des *)lev; |
|
/* fill the standard descriptor */ |
strncpy(lev->l.level_name, CBSSTAR_LEVELNAME, MAX_LEVELNAME); |
lev->l.level_code = CBSSTAR_LEVEL_CODE; |
lev->l.level_version = CBSSTAR_LEVEL_VERSION; |
lev->l.private_insert = CBSSTAR_private_insert; |
lev->l.private_extract = CBSSTAR_private_extract; |
lev->l.private_eligible = CBSSTAR_private_eligible; |
lev->l.private_dispatch = CBSSTAR_private_dispatch; |
lev->l.private_epilogue = CBSSTAR_private_epilogue; |
|
lev->l.level_accept_task_model = CBSSTAR_level_accept_task_model; |
lev->l.level_accept_guest_model = CBSSTAR_level_accept_guest_model; |
lev->l.level_status = CBSSTAR_level_status; |
lev->l.level_scheduler = CBSSTAR_level_scheduler; |
lev->l.level_guarantee = CBSSTAR_level_guarantee; |
lev->l.public_guarantee = CBSSTAR_public_guarantee; |
|
lev->l.task_create = CBSSTAR_task_create; |
lev->l.task_detach = CBSSTAR_task_detach; |
lev->l.task_eligible = CBSSTAR_task_eligible; |
lev->l.task_dispatch = CBSSTAR_task_dispatch; |
lev->l.task_epilogue = CBSSTAR_task_epilogue; |
lev->l.task_activate = CBSSTAR_task_activate; |
lev->l.task_insert = CBSSTAR_task_insert; |
lev->l.task_extract = CBSSTAR_task_extract; |
lev->l.task_endcycle = CBSSTAR_task_endcycle; |
lev->l.task_end = CBSSTAR_task_end; |
lev->l.task_sleep = CBSSTAR_task_sleep; |
|
lev->l.guest_create = CBSSTAR_guest_create; |
lev->l.guest_detach = CBSSTAR_guest_detach; |
lev->l.guest_dispatch = CBSSTAR_guest_dispatch; |
lev->l.guest_epilogue = CBSSTAR_guest_epilogue; |
lev->l.guest_activate = CBSSTAR_guest_activate; |
lev->l.guest_insert = CBSSTAR_guest_insert; |
lev->l.guest_extract = CBSSTAR_guest_extract; |
lev->l.guest_endcycle = CBSSTAR_guest_endcycle; |
lev->l.guest_end = CBSSTAR_guest_end; |
lev->l.guest_sleep = CBSSTAR_guest_sleep; |
|
/* fill the CBSSTAR descriptor part */ |
lev->b = (struct budget_struct *)kern_alloc(sizeof(struct budget_struct)*n); |
|
649,30 → 529,25 |
cbsstar_printf("(C:sbud)"); |
#endif |
|
if (lev->l.level_code == CBSSTAR_LEVEL_CODE && |
lev->l.level_version == CBSSTAR_LEVEL_VERSION) { |
if (lev->freebudgets != lev->n) { |
bandwidth_t b; |
b = (MAX_BANDWIDTH / T) * Q; |
if (lev->freebudgets != lev->n) { |
bandwidth_t b; |
b = (MAX_BANDWIDTH / T) * Q; |
|
/* really update lev->U, checking an overflow... */ |
if (Q< T && MAX_BANDWIDTH - lev->U > b) { |
int r = lev->freebudgets; // the return value |
|
/* really update lev->U, checking an overflow... */ |
if (Q< T && MAX_BANDWIDTH - lev->U > b) { |
int r = lev->freebudgets; // the return value |
|
lev->U += b; |
lev->freebudgets++; |
|
lev->b[r].Q = Q; |
lev->b[r].T = T; |
|
return r; |
} |
else |
return -2; |
lev->U += b; |
lev->freebudgets++; |
|
lev->b[r].Q = Q; |
lev->b[r].T = T; |
|
return r; |
} |
else |
return -1; |
return -2; |
} |
else |
return -3; |
return -1; |
} |