/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,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; |
/shark/trunk/include/kernel/model.h |
---|
21,11 → 21,11 |
/** |
------------ |
CVS : $Id: model.h,v 1.10 2004-05-25 12:14:35 giacomo Exp $ |
CVS : $Id: model.h,v 1.11 2004-05-26 15:35:31 anton Exp $ |
File: $File$ |
Revision: $Revision: 1.10 $ |
Last update: $Date: 2004-05-25 12:14:35 $ |
Revision: $Revision: 1.11 $ |
Last update: $Date: 2004-05-26 15:35:31 $ |
------------ |
This file contains the definitions of the task and resource models. |
263,10 → 263,6 |
#define SAVE_ARRIVALS 0 |
#define SKIP_ARRIVALS 1 |
#define NO_PREDEFINED_SCALING 0 |
#define WCET_SCALING 1 |
#define PERIOD_SCALING 2 |
/* ----------------------------------------------------------------------- |
DUMMY_TASK_MODEL: model used only for the dummy task |
----------------------------------------------------------------------- */ |
479,6 → 475,7 |
The default model set noraiseexc and period to 0, and accept a deadline |
*/ |
typedef struct { |
TASK_MODEL t; |
TIME period; |
509,14 → 506,47 |
#define job_task_def_trace(m) task_def_trace((m).t) |
#define job_task_def_notrace(m) task_def_notrace((m).t) |
/* ----------------------------------------------------------------------- |
ELASTIC_TASK_MODEL: Elastic Task |
----------------------------------------------------------------------- */ |
/* This model implements an elastic task. An elastic task is described by |
the following attributes: |
Tmin - The nominal (minimum) period. This is the period the task |
wants to execute at whenever there are enough resources. |
Tmax - The maximum tolerable period. The elastic model will never |
force the task to execute at a longer period than this. |
C - The declared worst-case execution time. By default, |
an exception will be raised if the wcet is violated. |
E - The elasticity coefficient. A coefficient of 0 means |
that its utilization cannot be changed by the elastic |
algorithm. A large number means that the task is very |
elastic. The default value is 0. |
beta - This parameter determines how the elastic scaling is done. |
PERIOD_SCALING means that the period will be changed, while |
WCET_SCALING means that the wcet will be changed. The |
default is PERIOD_SCALING. |
*/ |
/* Elastic Task */ |
#define PERIOD_SCALING 0 |
#define WCET_SCALING 1 |
typedef struct { |
TASK_MODEL t; |
TIME Tmin; |
TIME Tmax; |
TIME wcet; |
int kelastic; |
TIME C; |
int E; |
int beta; |
int arrivals; |
} ELASTIC_TASK_MODEL; |
525,9 → 555,9 |
task_default_model((m).t,ELASTIC_PCLASS), \ |
(m).Tmin = 0, \ |
(m).Tmax = 0, \ |
(m).wcet = 0, \ |
(m).kelastic = 0, \ |
(m).beta = NO_PREDEFINED_SCALING, \ |
(m).C = 0, \ |
(m).E = 0, \ |
(m).beta = PERIOD_SCALING, \ |
(m).arrivals = SKIP_ARRIVALS |
#define elastic_task_def_level(m,l) task_def_level((m).t,l) |
#define elastic_task_def_arg(m,a) task_def_arg((m).t,a) |
540,8 → 570,8 |
#define elastic_task_def_ctrl_jet(m) task_def_ctrl_jet((m).t) |
#define elastic_task_def_period(m,min,max) (m).Tmin = (min),\ |
(m).Tmax = (max) |
#define elastic_task_def_wcet(m,w) (m).wcet = (w) |
#define elastic_task_def_param(m,k,b) (m).kelastic = (k), \ |
#define elastic_task_def_wcet(m,w) (m).C = (w) |
#define elastic_task_def_param(m,E,b) (m).E = (E), \ |
(m).beta = (b) |
#define elastic_task_def_save_arrivals(m) (m).arrivals = SAVE_ARRIVALS |
#define elastic_task_def_skip_arrivals(m) (m).arrivals = SKIP_ARRIVALS |
/shark/trunk/include/modules/elastic.h |
---|
45,7 → 45,7 |
#define ELASTIC_ENABLE_GUARANTEE 1 /*+ Task Guarantee enabled +*/ |
#define ELASTIC_ENABLE_ALL 1 |
LEVEL ELASTIC_register_level(int flags, LEVEL master); |
LEVEL ELASTIC_register_level(int flags, LEVEL master, bandwidth_t U); |
__END_DECLS |
#endif |