Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 401 → Rev 402

/shark/trunk/ports/first/modules/grubstar.c
245,32 → 245,10
SUBTIMESPEC(&schedule_time, &lev->cap_lasttime, &ty);
tx = TIMESPEC2USEC(&ty);
 
if ((lev->U - lev->Uf) < 0) {
kern_printf("Error (U - Uf) < 0\n");
sys_end();
}
b->avail -= tx;
 
//Calculate reclaiming only one time
if (b->last_reclaiming == 0) {
 
//Geometrical n->+inf sum(tx*((lev->U - lev->Uf)/MAX_BANDWIDTH)^n)
mul32div32to32(tx,MAX_BANDWIDTH,(MAX_BANDWIDTH - lev->U + lev->Uf),b->last_reclaiming);
b->last_reclaiming -= tx;
if (b->last_reclaiming < 3) {
b->last_reclaiming = 0;
b->avail -= tx;
} else {
b->avail -= tx - b->last_reclaiming;
TRACER_LOGEVENT(FTrace_EVT_server_using_rec,3,(int)(b),b->last_reclaiming);
}
 
} else {
b->avail -= tx;
}
 
#ifdef GRUBSTAR_DEBUG
kern_printf("(GS:Cap p%d av=%d tx=%d rec=%d)", p, b->avail,(int)tx,b->last_reclaiming);
kern_printf("(GS:Cap p%d av=%d tx=%d)", p, b->avail,(int)tx);
#endif
 
if (b->avail <= 0) {
454,6 → 432,7
{
GRUBSTAR_level_des *lev = (GRUBSTAR_level_des *)(level_table[l]);
struct timespec ty;
int temp;
 
#ifdef GRUBSTAR_DEBUG
kern_printf("(GS:Dsp:%d)", p);
474,9 → 453,23
 
/* ...and finally, we have to post a capacity event */
ADDUSEC2TIMESPEC(lev->b[lev->tb[exec]].avail,&ty);
/* Reclaiming Computation */
if ((lev->U - lev->Uf) < 0) {
cprintf("GRUBSTAR Error: Bad Reclaiming Computation\n");
sys_end();
}
 
mul32div32to32(lev->b[lev->tb[exec]].avail,(lev->U-lev->Uf),MAX_BANDWIDTH,lev->b[lev->tb[exec]].last_reclaiming);
 
if (lev->b[lev->tb[exec]].last_reclaiming > 0)
TRACER_LOGEVENT(FTrace_EVT_server_using_rec,3,(int)(&lev->b[lev->tb[exec]]),lev->b[lev->tb[exec]].last_reclaiming);
 
temp = lev->b[lev->tb[exec]].avail + lev->b[lev->tb[exec]].last_reclaiming;
 
ADDUSEC2TIMESPEC(temp,&ty);
 
lev->cap_lev = kern_event_post(&ty,capacity_handler, lev);
}
 
691,11 → 684,15
 
}
 
/* Change Q and T parameters of a budget
* It returns the time to wait before the change is effective
*/
int GRUBSTAR_adjust_budget(LEVEL l, TIME Q, TIME T, int budget)
{
 
GRUBSTAR_level_des *lev = (GRUBSTAR_level_des *)(level_table[l]);
bandwidth_t b;
TIME OldPeriod = lev->b[budget].T;
 
mul32div32to32(MAX_BANDWIDTH,lev->b[budget].Q,lev->b[budget].T,b);
 
709,7 → 706,12
lev->U += lev->b[budget].Ub;
if (lev->b[budget].flags != GRUBSTAR_RECLAIMING) lev->Uf += lev->b[budget].Ub;
 
return 0;
if (lev->b[budget].flags == GRUBSTAR_NOACTIVE)
return 0;
if (lev->b[budget].flags == GRUBSTAR_RECLAIMING)
return 0;
return OldPeriod;
 
}