Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 262 → Rev 263

/shark/trunk/ports/first/modules/cbsstar.c
42,7 → 42,7
/*
* DEBUG stuffs begin
*/
#define CBSSTAR_DEBUG
//#define CBSSTAR_DEBUG
#ifdef CBSSTAR_DEBUG
 
static __inline__ void fake_printf(char *fmt, ...) {}
67,7 → 67,6
 
struct timespec dline; /* deadline */
int dline_timer; /* oslib event for budget reactivation*/
int vtimer;
int avail; /* current budget */
LEVEL l; /* Current CBSSTAR level */
84,7 → 83,6
 
#define CBSSTAR_NOACTIVE 0
#define CBSSTAR_ACTIVE 1
#define CBSSTAR_RECLAIMING 2
 
typedef struct {
level_des l; /* the standard level descriptor */
95,8 → 93,7
 
int tb[MAX_PROC]; /* link task->budget (used in guest_end) */
 
bandwidth_t U; /*+ the used bandwidth by the server +*/
bandwidth_t Uf; /*+ the actual used bandwidth by the server +*/
bandwidth_t U; /*+ the used bandwidth by the server +*/
 
int cap_lev;
 
109,10 → 106,7
{
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
126,17 → 120,6
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
145,6 → 128,7
... 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);
158,6 → 142,7
 
b->current = p;
 
lev = (CBSSTAR_level_des *)(level_table[b->l]);
job_task_default_model(job, b->dline);
job_task_def_noexc(job);
182,39 → 167,6
 
}
 
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)
244,29 → 196,9
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;
 
290,10 → 222,10
 
SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty);
tx = TIMESPEC2USEC(&ty);
b->avail -= (int)((long long)tx * (long long)lev->Uf / (int)lev->U);
b->avail -= tx;
 
#ifdef CBSSTAR_DEBUG
kern_printf("(CS:Cap p%d av=%d Uf=%u U=%u)", p, b->avail,lev->Uf, lev->U);
kern_printf("(CS:Cap p%d av=%d)", p, b->avail);
#endif
 
if (b->avail <= 0) b->flags = CBSSTAR_NOACTIVE;
546,7 → 478,7
CBSSTAR_level_des *lev; /* for readableness only */
PID i; /* a counter */
 
kern_printf("CBSSTAR_register_level\n");
printk("CBSSTAR_register_level\n");
 
/* request an entry in the level_table */
l = level_alloc_descriptor(sizeof(CBSSTAR_level_des));
570,7 → 502,6
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;
585,7 → 516,6
lev->tb[i] = NIL;
 
lev->U = 0;
lev->Uf = 0;
lev->cap_lev = NIL;
lev->scheduling_level = master;
 
613,7 → 543,6
if (Q< T && MAX_BANDWIDTH - lev->U > b) {
lev->U += b;
lev->Uf += b;
lev->freebudgets++;
lev->b[r].Q = Q;
/shark/trunk/ports/first/makefile
12,7 → 12,7
 
FIRST = first-contract.o first-server.o first-sync.o \
./modules/grubstar.o ./modules/posixstar.o \
./modules/edfstar.o ./modules/rmstar.o
./modules/edfstar.o ./modules/cbsstar.o ./modules/rmstar.o
 
OBJS = $(FIRST)