Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 737 → Rev 741

/shark/trunk/kernel/modules/elastic.c
39,6 → 39,8
#include <kernel/var.h>
#include <kernel/func.h>
 
#include <ll/i386/64bit.h>
 
#include <stdlib.h>
 
#include <modules/elastic.h>
45,7 → 47,6
 
#include <tracer.h>
 
 
/* Task flags */
 
#define ELASTIC_PRESENT 1
55,7 → 56,6
 
#define ELASTIC_IDLE APER_STATUS_BASE
 
 
#define ELASTIC_DEBUG
 
#ifdef ELASTIC_DEBUG
111,8 → 111,10
 
ext_bandwidth_t U; /*+ the bandwidth reserved for elastic tasks +*/
 
ELASTIC_task_descr elist[MAX_PROC];
int c_scaling_factor; /*+ the computation time scaling factor +*/
 
ELASTIC_task_descr *elist;
 
LEVEL scheduling_level;
 
LEVEL current_level;
140,8 → 142,8
ptime1(&et->release), ptime2(&et->dline));
#endif
 
proc_table[p].avail_time = et->C;
proc_table[p].wcet = et->C;
mul32div32to32(et->C,lev->c_scaling_factor,SCALING_UNIT,proc_table[p].avail_time);
mul32div32to32(et->C,lev->c_scaling_factor,SCALING_UNIT,proc_table[p].wcet);
 
/* Job insertion */
job_task_default_model(job, et->dline);
248,7 → 250,7
if (et->flags & ELASTIC_PRESENT) {
if (et->U != et->oldU) {
/* Utilization has been changed. Compute new period */
et->T = ((long long)et->C * (long long)MAX_BANDWIDTH) / et->U;
et->T = ((long long)et->C * (long long)lev->c_scaling_factor * (long long)MAX_BANDWIDTH) / (et->U * (long long)SCALING_UNIT);
}
if (et->U < et->oldU) {
/* Task has been compressed. Change its deadline NOW! */
328,8 → 330,8
et->E = elastic->E;
et->beta = elastic->beta;
 
et->Umax = ((long long)MAX_BANDWIDTH * (long long)elastic->C) / elastic->Tmin;
et->Umin = ((long long)MAX_BANDWIDTH * (long long)elastic->C) / elastic->Tmax;
et->Umax = ((long long)MAX_BANDWIDTH * (long long)elastic->C * (long long)lev->c_scaling_factor) / ((long long)elastic->Tmin * (long long)SCALING_UNIT);
et->Umin = ((long long)MAX_BANDWIDTH * (long long)elastic->C * (long long)lev->c_scaling_factor) / ((long long)elastic->Tmax * (long long)SCALING_UNIT);
 
et->U = et->Umax;
et->oldU = 0;
336,8 → 338,8
et->T = et->Tmin;
et->dltimer = -1;
 
proc_table[p].avail_time = elastic->C;
proc_table[p].wcet = elastic->C;
mul32div32to32(et->C,lev->c_scaling_factor,SCALING_UNIT,proc_table[p].avail_time);
mul32div32to32(et->C,lev->c_scaling_factor,SCALING_UNIT,proc_table[p].wcet);
proc_table[p].control |= CONTROL_CAP;
 
return 0;
513,6 → 515,8
lev->l.public_block = ELASTIC_public_block;
lev->l.public_message = ELASTIC_public_message;
 
lev->elist = kern_alloc(MAX_PROC * sizeof(ELASTIC_task_descr));
 
/* fill the ELASTIC task descriptor part */
for (i=0; i<MAX_PROC; i++) {
NULL_TIMESPEC(&(lev->elist[i].dline));
526,6 → 530,8
lev->elist[i].flags = 0;
}
 
lev->c_scaling_factor = SCALING_UNIT;
 
lev->U = U;
 
lev->scheduling_level = master;
556,7 → 562,7
saveU = et->U;
 
et->E = 0; /* set elasticity to zero to force period */
et->U = ((long long)MAX_BANDWIDTH * (long long)et->C)/period;
et->U = ((long long)MAX_BANDWIDTH * (long long)et->C * (long long)lev->c_scaling_factor)/((long long)period * (long long)SCALING_UNIT);
if (ELASTIC_compress(lev) == -1) {
#ifdef ELASTIC_DEBUG
736,3 → 742,33
return lev->U;
 
}
 
int ELASTIC_set_scaling_factor(LEVEL level, int scaling_factor) {
SYS_FLAGS f;
ELASTIC_level_des *lev = (ELASTIC_level_des *)level_table[level];
f = kern_fsave();
lev->c_scaling_factor = scaling_factor;
if (ELASTIC_compress(lev) == -1) {
#ifdef ELASTIC_DEBUG
cprintf("ELASTIC_set_scaling_factor failed: could not compress\n");
#endif
kern_frestore(f);
return -1;
}
kern_frestore(f);
return 0;
}
 
int ELASTIC_get_scaling_factor(LEVEL level) {
ELASTIC_level_des *lev = (ELASTIC_level_des *)level_table[level];;
return lev->c_scaling_factor;
}