42,7 → 42,7 |
/* |
* DEBUG stuffs begin |
*/ |
//#define CBSSTAR_DEBUG |
#define CBSSTAR_DEBUG |
#ifdef CBSSTAR_DEBUG |
|
static __inline__ void fake_printf(char *fmt, ...) {} |
67,6 → 67,7 |
|
struct timespec dline; /* deadline */ |
int dline_timer; /* oslib event for budget reactivation*/ |
int vtimer; |
int avail; /* current budget */ |
|
LEVEL l; /* Current CBSSTAR level */ |
83,6 → 84,7 |
|
#define CBSSTAR_NOACTIVE 0 |
#define CBSSTAR_ACTIVE 1 |
#define CBSSTAR_RECLAIMING 2 |
|
typedef struct { |
level_des l; /* the standard level descriptor */ |
93,7 → 95,8 |
|
int tb[MAX_PROC]; /* link task->budget (used in guest_end) */ |
|
bandwidth_t U; /*+ the used bandwidth by the server +*/ |
bandwidth_t U; /*+ the used bandwidth by the server +*/ |
bandwidth_t Uf; /*+ the actual used bandwidth by the server +*/ |
|
int cap_lev; |
|
106,7 → 109,10 |
{ |
struct budget_struct *b = a; |
PID p; |
|
CBSSTAR_level_des *lev; |
|
lev = (CBSSTAR_level_des *)(level_table[b->l]); |
|
#ifdef CBSSTAR_DEBUG |
cbsstar_printf("(CS:HrdRes:"); |
#endif |
120,6 → 126,17 |
b->avail += b->Q; |
if (b->avail > b->Q) b->avail = b->Q; |
|
if (b->flags==CBSSTAR_RECLAIMING && b->avail>0) { |
bandwidth_t bw; |
bw = (MAX_BANDWIDTH / b->T) * b->Q; |
|
lev->Uf += bw; |
|
#ifdef CBSSTAR_DEBUG |
kern_printf("BW=%ld, U=%u, Uf=%u",(long)bw, lev->U, lev->Uf); |
#endif |
} |
|
if (b->avail > 0) b->flags = CBSSTAR_ACTIVE; |
|
/* avail may be <0 because a task executed via a shadow fo many time |
128,7 → 145,6 |
... we are now activating the next task */ |
if (b->current == NIL && b->flags) { |
if (iq_query_first(&(b->tasks)) != NIL) { |
CBSSTAR_level_des *lev; |
JOB_TASK_MODEL job; |
|
p = iq_getfirst(&b->tasks); |
142,7 → 158,6 |
|
b->current = p; |
|
lev = (CBSSTAR_level_des *)(level_table[b->l]); |
|
job_task_default_model(job, b->dline); |
job_task_def_noexc(job); |
167,6 → 182,39 |
|
} |
|
void CBSSTAR_ANC(void *arg) |
{ |
struct budget_struct *b = arg; |
CBSSTAR_level_des *lev=(CBSSTAR_level_des *)level_table[b->l]; |
|
//#ifdef CBSSTAR_DEBUG |
kern_printf("(CS:Rec:"); |
//#endif |
|
b->vtimer = NIL; |
if (b->current != NIL && iq_query_first(&(b->tasks)) != NIL) { |
bandwidth_t bw; |
|
b->flags=CBSSTAR_RECLAIMING; |
|
bw = (MAX_BANDWIDTH / b->T) * b->Q; |
|
lev->Uf -= bw; |
|
#ifdef CBSSTAR_DEBUG |
kern_printf("bw=%ld, U=%u, Uf=%u",(long)bw, lev->U, lev->Uf); |
#endif |
|
|
} |
|
//#ifdef CBSSTAR_DEBUG |
kern_printf(")"); |
//#endif |
|
|
} |
|
static void CBSSTAR_activation(CBSSTAR_level_des *lev, |
PID p, |
struct timespec *acttime) |
196,9 → 244,29 |
TIMESPEC_ASSIGN(&b->dline, acttime); |
ADDUSEC2TIMESPEC(b->T, &b->dline); |
b->avail=b->Q; |
if (b->flags==CBSSTAR_RECLAIMING) { |
bandwidth_t bw; |
|
bw = (MAX_BANDWIDTH / b->T) * b->Q; |
|
lev->Uf += bw; |
|
#ifdef CBSSTAR_DEBUG |
kern_printf("BW=%ld, U=%u, Uf=%u",(long)bw, lev->U, lev->Uf); |
#endif |
} |
|
|
b->flags=CBSSTAR_ACTIVE; |
|
} |
|
SUBTIMESPEC(&b->dline, &t3, &t2); |
if (b->vtimer!=NIL) kern_event_delete(b->vtimer); |
b->vtimer=NIL; |
b->vtimer = kern_event_post(&t2, CBSSTAR_ANC, b); |
|
|
/* record the current task inserted in the master module */ |
b->current = p; |
|
222,10 → 290,10 |
|
SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty); |
tx = TIMESPEC2USEC(&ty); |
b->avail -= tx; |
b->avail -= (int)((long long)tx * (long long)lev->Uf / (int)lev->U); |
|
#ifdef CBSSTAR_DEBUG |
kern_printf("(CS:Cap p%d av=%d)", p, b->avail); |
kern_printf("(CS:Cap p%d av=%d Uf=%u U=%u)", p, b->avail,lev->Uf, lev->U); |
#endif |
|
if (b->avail <= 0) b->flags = CBSSTAR_NOACTIVE; |
478,7 → 546,7 |
CBSSTAR_level_des *lev; /* for readableness only */ |
PID i; /* a counter */ |
|
printk("CBSSTAR_register_level\n"); |
kern_printf("CBSSTAR_register_level\n"); |
|
/* request an entry in the level_table */ |
l = level_alloc_descriptor(sizeof(CBSSTAR_level_des)); |
502,6 → 570,7 |
lev->b[i].T = 0; |
NULL_TIMESPEC(&lev->b[i].dline); |
lev->b[i].dline_timer = NIL; |
lev->b[i].vtimer=NIL; |
lev->b[i].avail = 0; |
lev->b[i].current = -1; |
lev->b[i].flags = CBSSTAR_ACTIVE; |
516,6 → 585,7 |
lev->tb[i] = NIL; |
|
lev->U = 0; |
lev->Uf = 0; |
lev->cap_lev = NIL; |
lev->scheduling_level = master; |
|
543,6 → 613,7 |
if (Q< T && MAX_BANDWIDTH - lev->U > b) { |
|
lev->U += b; |
lev->Uf += b; |
lev->freebudgets++; |
|
lev->b[r].Q = Q; |