Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 690 → Rev 691

/shark/trunk/kernel/modules/edf.c
20,11 → 20,11
 
/**
------------
CVS : $Id: edf.c,v 1.14 2004-05-17 15:03:51 anton Exp $
CVS : $Id: edf.c,v 1.15 2004-05-26 15:36:23 anton Exp $
 
File: $File$
Revision: $Revision: 1.14 $
Last update: $Date: 2004-05-17 15:03:51 $
Revision: $Revision: 1.15 $
Last update: $Date: 2004-05-26 15:36:23 $
------------
 
This file contains the scheduling module EDF (Earliest Deadline First)
507,8 → 507,8
if (lev->flags & EDF_ENABLE_WCET_CHECK) {
proc_table[p].control |= CONTROL_CAP;
}
jet_update_endcycle(); /* Update the Jet data... */
proc_table[p].avail_time = proc_table[p].wcet;
jet_update_endcycle(); /* Update the Jet data... */
TRACER_LOGEVENT(FTrace_EVT_task_end_cycle,(unsigned short int)proc_table[p].context,(unsigned int)l);
return 0;
/shark/trunk/kernel/modules/elastic.c
50,23 → 50,20
 
#define ELASTIC_IDLE APER_STATUS_BASE
 
#define ELASTIC_DEBUG
//#define ELASTIC_DEBUG
 
typedef struct {
 
struct timespec dline;
TIME Tmin;
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,8 → 88,9
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;
99,8 → 97,18
 
}
 
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]);
 
return 1;
 
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,25 → 187,36
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].flags = ELASTIC_EMPTY_SLOT;
return -1;
}
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;
}
 
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... */
241,7 → 265,7
kern_raise(XWCET_VIOLATION,p);
}
 
level_table[ lev->scheduling_level ]->
private_epilogue(lev->scheduling_level,p);
 
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;