50,7 → 50,7 |
|
#define ELASTIC_IDLE APER_STATUS_BASE |
|
#define ELASTIC_DEBUG |
//#define ELASTIC_DEBUG |
|
typedef struct { |
|
58,15 → 58,12 |
|
TIME Tmin; |
TIME Tmax; |
TIME C; |
int E; |
int beta; |
|
TIME period; |
TIME wcet; |
TIME T; |
|
bandwidth_t Up; |
|
int kelastic; |
int beta; |
|
int flags; |
|
} ELASTIC_task_descr; |
74,7 → 71,7 |
typedef struct { |
level_des l; /*+ the standard level descriptor +*/ |
|
bandwidth_t U; /*+ the used bandwidth by the server +*/ |
bandwidth_t U; /*+ the bandwidth reserved for elastic tasks +*/ |
|
ELASTIC_task_descr *elist;//[MAX_PROC]; |
|
91,16 → 88,27 |
PID i; |
|
for (i=0; i<MAX_PROC; i++) { |
if (lev->elist[i].flags & ELASTIC_PRESENT) |
lev->elist[i].period = lev->elist[i].Tmax; |
if (lev->elist[i].flags & ELASTIC_PRESENT) { |
lev->elist[i].T = lev->elist[i].Tmax; |
} |
} |
|
return 0; |
|
} |
|
static int ELASTIC_check_guarantie(ELASTIC_level_des *lev) { |
static int ELASTIC_check_guarantee(ELASTIC_level_des *lev) { |
|
PID i; |
|
for (i=0; i<MAX_PROC; i++) { |
if (lev->elist[i].flags & ELASTIC_PRESENT) { |
|
lev->elist[i].T = lev->elist[i].Tmax; |
} |
} |
|
|
return 0; |
|
} |
113,10 → 121,10 |
|
/* Job deadline */ |
TIMESPEC_ASSIGN(&(lev->elist[p].dline),acttime); |
ADDUSEC2TIMESPEC(lev->elist[p].period,&(lev->elist[p].dline)); |
ADDUSEC2TIMESPEC(lev->elist[p].T,&(lev->elist[p].dline)); |
|
proc_table[p].avail_time = lev->elist[p].wcet; |
proc_table[p].wcet = lev->elist[p].wcet; |
proc_table[p].avail_time = lev->elist[p].C; |
proc_table[p].wcet = lev->elist[p].C; |
|
/* Job insertion */ |
job_task_default_model(job, lev->elist[p].dline); |
152,20 → 160,25 |
{ |
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]); |
|
if (*freebandwidth >= lev->U) { |
*freebandwidth -= lev->U; |
return 1; |
|
} else { |
return 0; |
} |
} |
|
|
static int ELASTIC_public_create(LEVEL l, PID p, TASK_MODEL *m) |
{ |
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]); |
ELASTIC_TASK_MODEL *elastic; |
ELASTIC_TASK_MODEL *elastic = (ELASTIC_TASK_MODEL *)m; |
ext_bandwidth_t Umin = 0; |
|
if (m->pclass != ELASTIC_PCLASS) return -1; |
if (m->level != 0 && m->level != l) return -1; |
elastic = (ELASTIC_TASK_MODEL *)m; |
|
if (elastic->wcet == 0) return -1; |
if (elastic->C == 0) return -1; |
if (elastic->Tmin > elastic->Tmax) return -1; |
if (elastic->Tmax == 0) return -1; |
|
174,12 → 187,28 |
NULL_TIMESPEC(&(lev->elist[p].dline)); |
lev->elist[p].Tmin = elastic->Tmin; |
lev->elist[p].Tmax = elastic->Tmax; |
lev->elist[p].wcet = elastic->wcet; |
lev->elist[p].kelastic = elastic->kelastic; |
lev->elist[p].C = elastic->C; |
lev->elist[p].E = elastic->E; |
lev->elist[p].beta = elastic->beta; |
|
if (lev->flags & ELASTIC_ENABLE_GUARANTEE) |
if (ELASTIC_check_guarantie(lev) != 0) { |
lev->elist[p].T = elastic->Tmin; |
|
/* check if new task can be admitted: */ |
/* compute minimum consumed bandwidth of all tasks */ |
Umin = 0; |
for (i=0; i<MAX_PROC; i++) { |
if (lev->elist[i].flags & ELASTIC_PRESENT) { |
if (lev->elist[i].E == 0) { |
/* The task is not elastic. Use current period T */ |
Umin += (MAX_BANDWIDTH / lev->elist[i].T) * lev->elist[i].C; |
} else { |
/* The task is elastic. Use maximum period Tmax */ |
Umin += (MAX_BANDWIDTH / lev->elist[i].Tmax) * lev->elist[i].C; |
} |
} |
} |
if (Umin > lev->U) { |
/* failed to add task */ |
lev->elist[p].flags = ELASTIC_EMPTY_SLOT; |
return -1; |
} |
186,13 → 215,8 |
|
ELASTIC_recompute(lev); |
|
if (lev->elist[p].period == 0) { |
lev->elist[p].flags = ELASTIC_EMPTY_SLOT; |
return -1; |
} |
|
proc_table[p].avail_time = elastic->wcet; |
proc_table[p].wcet = elastic->wcet; |
proc_table[p].avail_time = elastic->C; |
proc_table[p].wcet = elastic->C; |
proc_table[p].control |= CONTROL_CAP; |
|
return 0; /* OK, also if the task cannot be guaranteed... */ |
343,7 → 367,7 |
} |
|
/*+ Registration function +*/ |
LEVEL ELASTIC_register_level(int flags, LEVEL master) |
LEVEL ELASTIC_register_level(int flags, LEVEL master, bandwidth_t U) |
{ |
LEVEL l; /* the level that we register */ |
ELASTIC_level_des *lev; /* for readableness only */ |
379,15 → 403,14 |
NULL_TIMESPEC(&(lev->elist[i].dline)); |
lev->elist[i].Tmin = 0; |
lev->elist[i].Tmax = 0; |
lev->elist[i].period = 0; |
lev->elist[i].wcet = 0; |
lev->elist[i].Up = 0; |
lev->elist[i].kelastic = 0; |
lev->elist[i].T = 0; |
lev->elist[i].C = 0; |
lev->elist[i].E = 0; |
lev->elist[i].beta = 0; |
lev->elist[i].flags = ELASTIC_EMPTY_SLOT; |
} |
|
lev->U = 0; |
lev->U = U; |
|
lev->scheduling_level = master; |
|