20,11 → 20,11 |
|
/* |
------------ |
CVS : $Id: cbsstar.c,v 1.4 2003-01-07 17:10:16 pj Exp $ |
CVS : $Id: cbsstar.c,v 1.5 2003-06-18 08:13:01 trimarchi Exp $ |
|
File: $File$ |
Revision: $Revision: 1.4 $ |
Last update: $Date: 2003-01-07 17:10:16 $ |
Revision: $Revision: 1.5 $ |
Last update: $Date: 2003-06-18 08:13:01 $ |
------------ |
|
Read CBSSTAR.h for general details. |
75,10 → 75,8 |
* DEBUG stuffs begin |
*/ |
|
//#define CBSSTAR_DEBUG |
#ifdef CBSSTAR_DEBUG_OLD |
|
#ifdef CBSSTAR_DEBUG |
|
static __inline__ void fake_printf(char *fmt, ...) {} |
|
//#define cbsstar_printf kern_printf |
89,8 → 87,8 |
#define cbsstar_printf2 fake_printf |
#define cbsstar_printf3 fake_printf |
|
#if 0 |
void cbsstar_printq(QQUEUE *q) |
#if 0 |
void cbsstar_printq(IQUEUE *q) |
{ |
PID p; |
kern_printf("["); |
106,7 → 104,7 |
static __inline__ void cbsstar_printq(QQUEUE *q) {} |
#endif |
|
#if 0 |
#if 0 |
static __inline__ void cbsstar_printblob(int x) { if (x) cputc('±'); else cputc('Û'); } |
#else |
static __inline__ void cbsstar_printblob(int x) {} |
123,7 → 121,7 |
struct budget_struct { |
TIME Q; /* budget */ |
TIME T; /* period */ |
|
|
struct timespec dline; /* deadline */ |
int dline_timer; /* oslib event for budget reactivation*/ |
int avail; /* current budget */ |
144,6 → 142,8 |
int tb[MAX_PROC]; /* link task->budget (used in guest_end) */ |
|
bandwidth_t U; /*+ the used bandwidth by the server +*/ |
|
int cap_lev; |
|
LEVEL scheduling_level; |
|
185,10 → 185,11 |
*/ /* we modify the deadline ... */ |
TIMESPEC_ASSIGN(&b->dline, acttime); |
ADDUSEC2TIMESPEC(b->T, &b->dline); |
|
|
/* and the capacity */ |
b->avail = b->Q; |
|
|
#ifdef CBSSTAR_DEBUG |
cbsstar_printf3("±%d±",lev->tb[p]); |
cbsstar_printblob(lev->tb[p]); |
201,7 → 202,7 |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf("(C:iact p%d %ld.%ld av=%d)",p,b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail); |
#endif |
|
//kern_printf("Pid %d, Act %d, Dd %d", p,acttime->tv_nsec/1000,(b->dline).tv_nsec/1000); |
/* and, finally, we reinsert the task in the master level */ |
job_task_default_model(job, b->dline); |
job_task_def_noexc(job); |
259,7 → 260,7 |
article because if there is only the standard scheduling policy |
this never apply) we reassign the deadline */ |
|
if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time) ) { |
if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time) ) { |
/* we kill the current activation */ |
level_table[ lev->scheduling_level ]-> |
private_extract(lev->scheduling_level, p); |
276,7 → 277,6 |
cbsstar_printf3("±%d±",lev->tb[p]); |
cbsstar_printblob(lev->tb[p]); |
#endif |
|
/* and, finally, we reinsert the task in the master level */ |
job_task_default_model(job, b->dline); |
job_task_def_noexc(job); |
292,6 → 292,7 |
return 0; |
} |
|
|
static void CBSSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m) |
{ |
/* A task has been activated for some reason. Basically, the task is |
381,6 → 382,14 |
iq_extract(p, &lev->b[lev->tb[p]].tasks); |
} |
|
static void capacity_handler() |
{ |
//kern_printf("!"); |
event_need_reschedule(); |
|
} |
|
|
static void CBSSTAR_private_dispatch(LEVEL l, PID p, int nostop) |
{ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
404,8 → 413,8 |
if (!nostop) { |
TIMESPEC_ASSIGN(&ty, &schedule_time); |
ADDUSEC2TIMESPEC(lev->b[lev->tb[p]].avail,&ty); |
cap_timer = kern_event_post(&ty, capacity_timer, NULL); |
} |
lev->cap_lev = kern_event_post(&ty, capacity_handler, NULL); |
} |
} |
|
static void CBSSTAR_private_epilogue(LEVEL l, PID p) |
413,12 → 422,16 |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
struct budget_struct *b = &lev->b[lev->tb[p]]; |
|
#ifdef CBSSTAR_DEBUG |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf("(C:gepi %d",p); |
#endif |
#endif |
|
CBSSTAR_account_capacity(lev,p); |
|
if (lev->cap_lev!=NIL) |
kern_event_delete(lev->cap_lev); |
lev->cap_lev=NIL; |
|
/* we have to check if the capacity is still available */ |
if (b->avail > 0) { |
/* there is capacity available, maybe it is simply a preemption; |
425,10 → 438,11 |
the task have to return to the ready queue */ |
level_table[ lev->scheduling_level ]-> |
private_epilogue(lev->scheduling_level,p); |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf2(" *av=%d", b->avail); |
#endif |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(" *av=%d", b->avail); |
#endif |
} else { |
|
/* The capacity is exausted; the deadline have to be postponed and |
the task have to be reinserted in the master module */ |
JOB_TASK_MODEL job; |
443,15 → 457,14 |
while (b->avail <= 0) { |
ADDUSEC2TIMESPEC(b->T, &b->dline); |
b->avail += b->Q; |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf3("±%d±",lev->tb[p]); |
cbsstar_printblob(lev->tb[p]); |
#endif |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf("±%d±",b->avail); |
#endif |
} |
|
#ifdef CBSSTAR_DEBUG |
cbsstar_printf2(" %ld.%ld av=%d",b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail); |
#endif |
#ifdef CBSSTAR_DEBUG |
kern_printf(" %ld.%ld av=%d",b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail); |
#endif |
|
/* and, finally, we reinsert the task in the master level */ |
job_task_default_model(job, b->dline); |
462,6 → 475,7 |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(")"); |
#endif |
|
} |
|
|
510,12 → 524,11 |
|
lev->n = n; |
lev->freebudgets = 0; |
|
for (i=0; i<MAX_PROC; i++) |
lev->tb[i] = NIL; |
|
lev->U = 0; |
|
lev->cap_lev=NIL; |
lev->scheduling_level = master; |
|
return l; |