Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 670 → Rev 671

/shark/trunk/kernel/modules/bd_edf.c
38,11 → 38,11
*/
 
/*
* CVS : $Id: bd_edf.c,v 1.2 2003-01-07 17:07:50 pj Exp $
* CVS : $Id: bd_edf.c,v 1.3 2004-05-25 10:02:01 giacomo Exp $
*
* File: $File$
* Revision: $Revision: 1.2 $
* Last update: $Date: 2003-01-07 17:07:50 $
* Revision: $Revision: 1.3 $
* Last update: $Date: 2004-05-25 10:02:01 $
*/
 
#include <modules/bd_edf.h>
64,15 → 64,6
TIME dl[MAX_PROC];
} bd_edf_resource_des;
 
static int res_level_accept_resource_model(RLEVEL l, RES_MODEL *r)
{
assertk(mylevel==l);
if (r->rclass==BDEDF_RCLASS||r->rclass==(BDEDF_RCLASS|l))
return 0;
else
return -1;
}
 
static int res_register(RLEVEL l, PID p, RES_MODEL *r)
{
bd_edf_resource_des *m=(bd_edf_resource_des*)(resource_table[l]);
/shark/trunk/kernel/modules/elastic.c
0,0 → 1,275
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
* Mauro Marinoni
* Anton Cervin
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include <kernel/model.h>
#include <kernel/descr.h>
#include <kernel/var.h>
#include <kernel/func.h>
 
#include <stdlib.h>
 
#include <modules/elastic.h>
 
#include <tracer.h>
 
#define ELASTIC_EMPTY_SLOT 0
 
typedef struct {
 
struct timespec dline;
TIME Tmin;
TIME Tmax;
 
TIME period;
TIME wcet;
int kelastic;
int beta;
 
int nact;
 
int flags;
 
} ELASTIC_task_descr;
 
typedef struct {
level_des l; /*+ the standard level descriptor +*/
 
bandwidth_t U; /*+ the used bandwidth by the server +*/
 
ELASTIC_task_descr *elist;
 
LEVEL scheduling_level;
 
LEVEL current_level;
 
int flags;
 
} ELASTIC_level_des;
 
static void ELASTIC_activation(ELASTIC_level_des *lev,
PID p,
struct timespec *acttime)
{
JOB_TASK_MODEL job;
/*
job_task_default_model(job, lev->cbs_dline[p]);
job_task_def_noexc(job);
level_table[ lev->scheduling_level ]->
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job);
 
*/
 
}
 
/* The on-line guarantee is enabled only if the appropriate flag is set... */
static int ELASTIC_public_guarantee(LEVEL l, bandwidth_t *freebandwidth)
{
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;
 
if (m->pclass != ELASTIC_PCLASS) return -1;
if (m->level != 0 && m->level != l) return -1;
elastic = (ELASTIC_TASK_MODEL *)m;
 
return 0; /* OK, also if the task cannot be guaranteed... */
 
}
 
static void ELASTIC_public_detach(LEVEL l, PID p)
{
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]);
 
}
 
static int ELASTIC_public_eligible(LEVEL l, PID p)
{
 
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]);
JOB_TASK_MODEL job;
 
return 0;
 
}
 
static void ELASTIC_public_dispatch(LEVEL l, PID p, int nostop)
{
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]);
level_table[ lev->scheduling_level ]->
private_dispatch(lev->scheduling_level,p,nostop);
}
 
static void ELASTIC_public_epilogue(LEVEL l, PID p)
{
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]);
JOB_TASK_MODEL job;
 
}
 
static void ELASTIC_public_activate(LEVEL l, PID p, struct timespec *t)
{
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]);
 
}
 
static void ELASTIC_public_unblock(LEVEL l, PID p)
{
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]);
struct timespec acttime;
 
kern_gettime(&acttime);
 
ELASTIC_activation(lev,p,&acttime);
 
}
 
static void ELASTIC_public_block(LEVEL l, PID p)
{
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]);
 
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level,p);
 
}
 
static int ELASTIC_public_message(LEVEL l, PID p, void *m)
{
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]);
 
switch((long)(m)) {
 
case (long)(NULL):
 
jet_update_endcycle(); /* Update the Jet data... */
TRACER_LOGEVENT(FTrace_EVT_task_end_cycle,(unsigned short int)proc_table[p].context,(unsigned int)l);
 
break;
 
case 1:
 
TRACER_LOGEVENT(FTrace_EVT_task_disable,(unsigned short int)proc_table[p].context,(unsigned int)l);
 
break;
 
}
 
return 0;
 
}
 
static void ELASTIC_public_end(LEVEL l, PID p)
{
ELASTIC_level_des *lev = (ELASTIC_level_des *)(level_table[l]);
 
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level,p);
 
}
 
/*+ Registration function +*/
LEVEL ELASTIC_register_level(int flags, LEVEL master)
{
LEVEL l; /* the level that we register */
ELASTIC_level_des *lev; /* for readableness only */
PID i;
 
printk("ELASTIC_register_level\n");
 
/* request an entry in the level_table */
l = level_alloc_descriptor(sizeof(ELASTIC_level_des));
 
lev = (ELASTIC_level_des *)level_table[l];
 
/* fill the standard descriptor */
if (flags & ELASTIC_ENABLE_GUARANTEE)
lev->l.public_guarantee = ELASTIC_public_guarantee;
else
lev->l.public_guarantee = NULL;
lev->l.public_create = ELASTIC_public_create;
lev->l.public_detach = ELASTIC_public_detach;
lev->l.public_end = ELASTIC_public_end;
lev->l.public_eligible = ELASTIC_public_eligible;
lev->l.public_dispatch = ELASTIC_public_dispatch;
lev->l.public_epilogue = ELASTIC_public_epilogue;
lev->l.public_activate = ELASTIC_public_activate;
lev->l.public_unblock = ELASTIC_public_unblock;
lev->l.public_block = ELASTIC_public_block;
lev->l.public_message = ELASTIC_public_message;
 
lev->elist = malloc(MAX_PROC * sizeof(ELASTIC_task_descr));
if (lev->elist == NULL) {
printk("ELASTIC: Error allocating elastic task decriptor table\n");
sys_end();
}
 
/* fill the CBS descriptor part */
for (i=0; i<MAX_PROC; i++) {
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].kelastic = 0;
lev->elist[i].beta = 0;
lev->elist[i].nact = 0;
lev->elist[i].flags = ELASTIC_EMPTY_SLOT;
}
 
lev->U = 0;
 
lev->scheduling_level = master;
 
lev->current_level = l;
 
lev->flags = flags;
 
return l;
}
 
/shark/trunk/kernel/modules/makefile
22,6 → 22,7
posix.o \
dummy.o \
rrsoft.o \
elastic.o \
intdrive.o
 
APER_OBJ = tbs.o \
/shark/trunk/include/kernel/model.h
21,11 → 21,11
 
/**
------------
CVS : $Id: model.h,v 1.6 2004-05-17 15:03:50 anton Exp $
CVS : $Id: model.h,v 1.7 2004-05-25 10:02:18 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.6 $
Last update: $Date: 2004-05-17 15:03:50 $
Revision: $Revision: 1.7 $
Last update: $Date: 2004-05-25 10:02:18 $
------------
 
This file contains the definitions of the task and resource models.
250,8 → 250,8
#define SOFT_PCLASS 2
#define NRT_PCLASS 3
#define JOB_PCLASS 4
#define ELASTIC_PCLASS 5
 
 
/* -----------------------------------------------------------------------
Useful stuffs
----------------------------------------------------------------------- */
263,8 → 263,10
#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
----------------------------------------------------------------------- */
507,7 → 509,46
#define job_task_def_trace(m) task_def_trace((m).t)
#define job_task_def_notrace(m) task_def_notrace((m).t)
 
/* Elastic Task */
 
typedef struct {
TASK_MODEL t;
TIME Tmin;
TIME Tmax;
TIME wcet;
int kelastic;
int beta;
int arrivals;
} ELASTIC_TASK_MODEL;
#define elastic_task_default_model(m,dl) \
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).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)
#define elastic_task_def_stack(m,s) task_def_stack((m).t,s)
#define elastic_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s)
#define elastic_task_def_group(m,g) task_def_group((m).t,g)
#define elastic_task_def_usemath(m) task_def_usemath((m).t)
#define elastic_task_def_system(m) task_def_system((m).t)
#define elastic_task_def_nokill(m) task_def_nokill((m).t)
#define elastic_task_def_ctrl_jet(m) task_def_ctrl_jet((m).t)
#define elastic_task_def_period(m,Tmin,Tmax) (m).Tmin = (Tmin),\
(m).Tmax = (Tmax)
#define elastic_task_def_wcet(m,wcet) (m).wcet = (wcet)
#define elastic_task_def_const(m,kelastic,beta) (m).kelastic = (kelastic), \
(m).beta = (beta)
#define elastic_task_def_save_arrivals(m) (m).arrivals = SAVE_ARRIVALS
#define elastic_task_def_skip_arrivals(m) (m).arrivals = SKIP_ARRIVALS
#define elastic_task_def_joinable(m) task_def_joinable((m).t)
#define elastic_task_def_unjoinable(m) task_def_unjoinable((m).t)
#define elastic_task_def_trace(m) task_def_trace((m).t)
#define elastic_task_def_notrace(m) task_def_notrace((m).t)
 
 
 
517,6 → 558,7
 
 
 
 
/* -----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------