Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1638 → Rev 1637

/advdemos/trunk/edfact/initfile.c
0,0 → 1,99
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/*
------------
CVS : $Id: initfile.c,v 1.1.1.1 2004-05-24 17:54:51 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2004-05-24 17:54:51 $
------------
*/
 
/*
* Copyright (C) 2000 Paolo Gai
*
* 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/kern.h"
#include "edfact.h"
#include "modules/cbs.h"
#include "modules/rr.h"
#include "modules/dummy.h"
 
#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
 
#include "drivers/keyb.h"
 
 
/*+ sysyem tick in us +*/
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
EDFACT_register_level(EDFACT_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 0);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
SEM_register_module();
 
CABS_register_module();
 
return TICK;
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
KEYB_PARMS kparms = BASE_KEYB;
 
HARTPORT_init();
 
//keyb_def_ctrlC(kparms, NULL);
keyb_def_map(kparms,itaMap);
KEYB_init(&kparms);
 
__call_main__(mb);
 
return (void *)0;
}
 
/advdemos/trunk/edfact/edfact.c
0,0 → 1,565
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/**
------------
CVS : $Id: edfact.c,v 1.1.1.1 2004-05-24 17:54:51 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2004-05-24 17:54:51 $
------------
**/
 
/*
* Copyright (C) 2001 Paolo Gai
*
* 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 "edfact.h"
#include <ll/stdio.h>
#include <ll/string.h>
#include <kernel/model.h>
#include <kernel/descr.h>
#include <kernel/var.h>
#include <kernel/func.h>
 
//#define edfact_printf kern_printf
#define edfact_printf printk
 
/*+ Status used in the level +*/
#define EDFACT_READY MODULE_STATUS_BASE /*+ - Ready status +*/
#define EDFACT_IDLE MODULE_STATUS_BASE+4 /*+ to wait the deadline +*/
 
/*+ flags +*/
#define EDFACT_FLAG_NORAISEEXC 2
 
/*+ the level redefinition for the Earliest Deadline First level +*/
typedef struct {
level_des l; /*+ the standard level descriptor +*/
 
TIME period[MAX_PROC]; /*+ The task periods; the deadlines are
stored in the priority field +*/
int deadline_timer[MAX_PROC];
/*+ The task deadline timers +*/
 
struct timespec deadline_timespec[MAX_PROC];
 
int dline_miss[MAX_PROC]; /*+ Deadline miss counter +*/
int wcet_miss[MAX_PROC]; /*+ Wcet miss counter +*/
 
int nact[MAX_PROC]; /*+ Wcet miss counter +*/
 
int flag[MAX_PROC];
/*+ used to manage the JOB_TASK_MODEL and the
periodicity +*/
 
IQUEUE ready; /*+ the ready queue +*/
 
int flags; /*+ the init flags... +*/
 
bandwidth_t U; /*+ the used bandwidth +*/
 
} EDFACT_level_des;
 
 
static void EDFACT_timer_deadline(void *par);
 
static void EDFACT_internal_activate(EDFACT_level_des *lev, PID p,
struct timespec *t)
{
struct timespec *temp;
 
temp = iq_query_timespec(p, &lev->ready);
 
TIMESPEC_ASSIGN(temp,t);
ADDUSEC2TIMESPEC(lev->period[p], temp);
 
TIMESPEC_ASSIGN(&lev->deadline_timespec[p],
temp);
 
/* Insert task in the correct position */
proc_table[p].status = EDFACT_READY;
iq_timespec_insert(p,&lev->ready);
 
/* needed because when there is a wcet miss I disable CONTROL_CAP */
proc_table[p].control |= CONTROL_CAP;
}
 
static void EDFACT_timer_deadline(void *par)
{
PID p = (PID) par;
EDFACT_level_des *lev;
 
lev = (EDFACT_level_des *)level_table[proc_table[p].task_level];
 
switch (proc_table[p].status) {
case EDFACT_IDLE:
edfact_printf("I%d",p);
 
EDFACT_internal_activate(lev,p, &lev->deadline_timespec[p]);
 
event_need_reschedule();
break;
 
default:
edfact_printf("D%d",p);
/* else, a deadline miss occurred!!! */
lev->dline_miss[p]++;
 
/* the task is into another state */
lev->nact[p]++;
 
/* Set the deadline timer */
ADDUSEC2TIMESPEC(lev->period[p], &lev->deadline_timespec[p]);
}
 
/* Set the deadline timer */
lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p],
EDFACT_timer_deadline,
(void *)p);
 
}
 
static void EDFACT_timer_guest_deadline(void *par)
{
PID p = (PID) par;
 
edfact_printf("AAARRRGGGHHH!!!");
kern_raise(XDEADLINE_MISS,p);
}
 
 
/* The scheduler only gets the first task in the queue */
static PID EDFACT_public_scheduler(LEVEL l)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
return iq_query_first(&lev->ready);
}
 
/* The on-line guarantee is enabled only if the appropriate flag is set... */
static int EDFACT_public_guarantee(LEVEL l, bandwidth_t *freebandwidth)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
if (lev->flags & EDFACT_FAILED_GUARANTEE) {
*freebandwidth = 0;
return 0;
}
else
if (*freebandwidth >= lev->U) {
*freebandwidth -= lev->U;
return 1;
}
else
return 0;
 
}
 
static int EDFACT_public_create(LEVEL l, PID p, TASK_MODEL *m)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
HARD_TASK_MODEL *h;
 
if (m->pclass != HARD_PCLASS) return -1;
if (m->level != 0 && m->level != l) return -1;
h = (HARD_TASK_MODEL *)m;
if (!h->wcet || !h->mit || h->periodicity != PERIODIC) return -1;
/* now we know that m is a valid model */
 
lev->period[p] = h->mit;
 
lev->flag[p] = 0;
lev->deadline_timer[p] = -1;
lev->dline_miss[p] = 0;
lev->wcet_miss[p] = 0;
lev->nact[p] = 0;
 
/* Enable wcet check */
proc_table[p].avail_time = h->wcet;
proc_table[p].wcet = h->wcet;
proc_table[p].control |= CONTROL_CAP;
 
/* update the bandwidth... */
if (lev->flags & EDFACT_ENABLE_GUARANTEE) {
bandwidth_t b;
b = (MAX_BANDWIDTH / h->mit) * h->wcet;
 
/* really update lev->U, checking an overflow... */
if (MAX_BANDWIDTH - lev->U > b)
lev->U += b;
else
/* The task can NOT be guaranteed (U>MAX_BANDWIDTH)...
in this case, we don't raise an exception... in fact, after the
EDFACT_task_create the task_create will call level_guarantee that return
-1... return -1 in EDFACT_task_create isn't correct, because:
. generally, the guarantee must be done when also the resources
are registered
. returning -1 will cause the task_create to return with an errno
ETASK_CREATE instead of ENO_GUARANTEE!!!
 
Why I use the flag??? because if the lev->U overflows, if i.e. I set
it to MAX_BANDWIDTH, I lose the correct allocated bandwidth...
*/
lev->flags |= EDFACT_FAILED_GUARANTEE;
}
 
return 0; /* OK, also if the task cannot be guaranteed... */
}
 
static void EDFACT_public_detach(LEVEL l, PID p)
{
/* the EDFACT level doesn't introduce any dinamic allocated new field.
we have only to reset the NO_GUARANTEE FIELD and decrement the allocated
bandwidth */
 
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
if (lev->flags & EDFACT_FAILED_GUARANTEE)
lev->flags &= ~EDFACT_FAILED_GUARANTEE;
else
lev->U -= (MAX_BANDWIDTH / lev->period[p]) * proc_table[p].wcet;
}
 
static void EDFACT_public_dispatch(LEVEL l, PID p, int nostop)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
/* the task state is set EXE by the scheduler()
we extract the task from the ready queue
NB: we can't assume that p is the first task in the queue!!! */
iq_extract(p, &lev->ready);
}
 
static void EDFACT_public_epilogue(LEVEL l, PID p)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
/* check if the wcet is finished... */
if (proc_table[p].avail_time <= 0 && proc_table[p].control&CONTROL_CAP) {
/* wcet finished: disable wcet event and count wcet miss */
edfact_printf("W%d",p);
proc_table[p].control &= ~CONTROL_CAP;
lev->wcet_miss[p]++;
}
 
/* the task it returns into the ready queue... */
iq_timespec_insert(p,&lev->ready);
proc_table[p].status = EDFACT_READY;
}
 
static void EDFACT_public_activate(LEVEL l, PID p)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
struct timespec t;
 
/* Test if we are trying to activate a non sleeping task */
/* save activation (only if needed... */
if (proc_table[p].status != SLEEP) {
/* a periodic task cannot be activated when it is already active */
kern_raise(XACTIVATION,p);
return;
}
 
kern_gettime(&t);
EDFACT_internal_activate(lev,p, &t);
 
/* Set the deadline timer */
lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p],
EDFACT_timer_deadline,
(void *)p);
 
}
 
static void EDFACT_public_unblock(LEVEL l, PID p)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
/* Insert task in the coEDFect position */
proc_table[p].status = EDFACT_READY;
iq_timespec_insert(p,&lev->ready);
}
 
static void EDFACT_public_block(LEVEL l, PID p)
{
}
 
static int EDFACT_public_message(LEVEL l, PID p, void *m)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
struct timespec t;
 
/* we reset the capacity counters... */
proc_table[p].avail_time = proc_table[p].wcet;
 
if (lev->nact[p] > 0) {
edfact_printf("E%d",p);
 
/* Pending activation: reactivate the thread!!! */
lev->nact[p]--;
 
/* see also EDFACT_timer_deadline */
kern_gettime(&t);
EDFACT_internal_activate(lev,p, &t);
 
/* check if the deadline has already expired */
if (TIMESPEC_A_LT_B(iq_query_timespec(p, &lev->ready), &schedule_time)) {
/* count the deadline miss */
lev->dline_miss[p]++;
kern_event_delete(lev->deadline_timer[p]);
}
 
}
else {
edfact_printf("e%d",p);
 
/* the task has terminated his job before it consume the wcet. All OK! */
proc_table[p].status = EDFACT_IDLE;
 
/* when the deadline timer fire, it recognize the situation and set
correctly all the stuffs (like reactivation, etc... ) */
}
 
jet_update_endcycle(); /* Update the Jet data... */
 
return 0;
}
 
static void EDFACT_public_end(LEVEL l, PID p)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
edfact_printf("Û%d",p);
 
/* we finally put the task in the ready queue */
proc_table[p].status = FREE;
iq_insertfirst(p,&freedesc);
/* and free the allocated bandwidth */
lev->U -= (MAX_BANDWIDTH/lev->period[p]) * proc_table[p].wcet;
 
if (lev->deadline_timer[p] != -1) {
edfact_printf("²%d",p);
kern_event_delete(lev->deadline_timer[p]);
}
}
 
 
/* Guest Functions
These functions manages a JOB_TASK_MODEL, that is used to put
a guest task in the EDFACT ready queue. */
 
static void EDFACT_private_insert(LEVEL l, PID p, TASK_MODEL *m)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
JOB_TASK_MODEL *job;
 
if (m->pclass != JOB_PCLASS || (m->level != 0 && m->level != l) ) {
kern_raise(XINVALID_TASK, p);
return;
}
 
job = (JOB_TASK_MODEL *)m;
 
TIMESPEC_ASSIGN(iq_query_timespec(p, &lev->ready), &job->deadline);
lev->deadline_timer[p] = -1;
lev->dline_miss[p] = 0;
lev->wcet_miss[p] = 0;
lev->nact[p] = 0;
 
if (job->noraiseexc)
lev->flag[p] = EDFACT_FLAG_NORAISEEXC;
else {
lev->flag[p] = 0;
lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready),
EDFACT_timer_guest_deadline,
(void *)p);
}
 
lev->period[p] = job->period;
 
/* Insert task in the correct position */
iq_timespec_insert(p,&lev->ready);
proc_table[p].status = EDFACT_READY;
 
/* there is no bandwidth guarantee at this level, it is performed
by the level that inserts guest tasks... */
}
 
static void EDFACT_private_dispatch(LEVEL l, PID p, int nostop)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
/* the task state is set to EXE by the scheduler()
we extract the task from the ready queue
NB: we can't assume that p is the first task in the queue!!! */
iq_extract(p, &lev->ready);
}
 
static void EDFACT_private_epilogue(LEVEL l, PID p)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
/* the task has been preempted. it returns into the ready queue... */
iq_timespec_insert(p,&lev->ready);
proc_table[p].status = EDFACT_READY;
}
 
static void EDFACT_private_extract(LEVEL l, PID p)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
//kern_printf("EDFACT_guest_end: dline timer %d\n",lev->deadline_timer[p]);
if (proc_table[p].status == EDFACT_READY)
{
iq_extract(p, &lev->ready);
//kern_printf("(g_end rdy extr)");
}
 
/* we remove the deadline timer, because the slice is finished */
if (lev->deadline_timer[p] != NIL) {
// kern_printf("EDFACT_guest_end: dline timer %d\n",lev->deadline_timer[p]);
kern_event_delete(lev->deadline_timer[p]);
lev->deadline_timer[p] = NIL;
}
 
}
 
/* Registration functions */
 
/*+ Registration function:
int flags the init flags ... see EDFACT.h +*/
LEVEL EDFACT_register_level(int flags)
{
LEVEL l; /* the level that we register */
EDFACT_level_des *lev; /* for readableness only */
PID i; /* a counter */
 
printk("EDFACT_register_level\n");
 
/* request an entry in the level_table */
l = level_alloc_descriptor(sizeof(EDFACT_level_des));
 
lev = (EDFACT_level_des *)level_table[l];
 
printk(" lev=%d\n",(int)lev);
 
/* fill the standard descriptor */
lev->l.private_insert = EDFACT_private_insert;
lev->l.private_extract = EDFACT_private_extract;
lev->l.private_dispatch = EDFACT_private_dispatch;
lev->l.private_epilogue = EDFACT_private_epilogue;
 
lev->l.public_scheduler = EDFACT_public_scheduler;
if (flags & EDFACT_ENABLE_GUARANTEE)
lev->l.public_guarantee = EDFACT_public_guarantee;
else
lev->l.public_guarantee = NULL;
lev->l.public_create = EDFACT_public_create;
lev->l.public_detach = EDFACT_public_detach;
lev->l.public_end = EDFACT_public_end;
lev->l.public_dispatch = EDFACT_public_dispatch;
lev->l.public_epilogue = EDFACT_public_epilogue;
lev->l.public_activate = EDFACT_public_activate;
lev->l.public_unblock = EDFACT_public_unblock;
lev->l.public_block = EDFACT_public_block;
lev->l.public_message = EDFACT_public_message;
 
/* fill the EDFACT descriptor part */
for(i=0; i<MAX_PROC; i++) {
lev->period[i] = 0;
lev->deadline_timer[i] = -1;
lev->flag[i] = 0;
lev->dline_miss[i] = 0;
lev->wcet_miss[i] = 0;
lev->nact[i] = 0;
}
 
iq_init(&lev->ready,&freedesc, 0);
lev->flags = flags & 0x07;
lev->U = 0;
 
return l;
}
 
bandwidth_t EDFACT_usedbandwidth(LEVEL l)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
return lev->U;
}
 
int EDFACT_get_dline_miss(PID p)
{
LEVEL l = proc_table[p].task_level;
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
return lev->dline_miss[p];
}
 
int EDFACT_get_wcet_miss(PID p)
{
LEVEL l = proc_table[p].task_level;
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
return lev->wcet_miss[p];
}
 
int EDFACT_get_nact(PID p)
{
LEVEL l = proc_table[p].task_level;
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
return lev->nact[p];
}
 
int EDFACT_reset_dline_miss(PID p)
{
LEVEL l = proc_table[p].task_level;
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
lev->dline_miss[p] = 0;
return 0;
}
 
int EDFACT_reset_wcet_miss(PID p)
{
LEVEL l = proc_table[p].task_level;
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
lev->wcet_miss[p] = 0;
return 0;
}
 
/advdemos/trunk/edfact/testact.c
0,0 → 1,245
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/**
------------
CVS : $Id: testact.c,v 1.1.1.1 2004-05-24 17:54:51 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2004-05-24 17:54:51 $
------------
**/
 
/*
* Copyright (C) 2001 Paolo Gai
*
* 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
*
*/
 
/* the demo tests EDFACT with my Celeron 366 Mhz.
Aster1 meet all wcets and all deadlines
Aster2 miss all wcets but hits all the deadlines
Aster3 blocks on a semaphore so it miss all the deadlines and it accumulates
pending activations
Aster4 does 5 states:
1: is a cycle, long enough to cope a little more than 2 periods
2-5: like aster1, they meets all the wcet and deadlines
the debug pattern is something like
WDDEEeIeIeI
W wcet violated
D deadline miss event
E endcycle with automatic reactivation due to pending activations
e normal endcycle
I normal reactivation event
 
 
*/
 
 
#include <kernel/kern.h>
#include <semaphore.h>
#include "edfact.h"
 
PID p1,p2,p3,p4;
 
sem_t sem;
 
#define ASTER_LIM 77
 
TASK aster1(void *arg)
{
int i = 10;
int y = 10+exec_shadow;
 
printf_xy(1,y,WHITE,"%d", exec_shadow);
while (i < ASTER_LIM) {
puts_xy(i,y,WHITE,"*");
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
 
return 0;
}
 
TASK aster2(void *arg)
{
int i = 10;
int y = 10+exec_shadow;
int x;
 
printf_xy(1,y,WHITE,"%d", exec_shadow);
while (i < ASTER_LIM) {
puts_xy(i,y,WHITE,"*");
for(x=0; x<1000000; x++);
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
 
return 0;
}
 
TASK aster3(void *arg)
{
int i = 10;
int y = 10+exec_shadow;
 
printf_xy(1,y,WHITE,"%d", exec_shadow);
while (i < ASTER_LIM) {
puts_xy(i,y,WHITE,"*");
sem_wait(&sem);
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
 
return 0;
}
 
TASK aster4(void *arg)
{
int i = 10;
int y = 10+exec_shadow;
int x;
int flag = 0;
 
printf_xy(1,y,WHITE,"%d", exec_shadow);
while (i < ASTER_LIM) {
puts_xy(i,y,WHITE,"*");
 
switch (flag) {
case 0:
kern_printf("!");
for(x=0; x<5000000; x++) flag=1;
break;
case 1:
flag = 2;
break;
case 2:
flag = 3;
break;
case 3:
flag = 4;
break;
case 4:
flag = 0;
break;
}
 
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
 
return 0;
}
 
 
 
TASK clock()
{
printf_xy(50,19,WHITE,"PID miss wcet nact");
while(1) {
printf_xy(50,20,WHITE,"%3d %4d %4d %4d",
p1, EDFACT_get_dline_miss(p1),
EDFACT_get_wcet_miss(p1),
EDFACT_get_nact(p1));
printf_xy(50,21,WHITE,"%3d %4d %4d %4d",
p2, EDFACT_get_dline_miss(p2),
EDFACT_get_wcet_miss(p2),
EDFACT_get_nact(p2));
printf_xy(50,22,WHITE,"%3d %4d %4d %4d",
p3, EDFACT_get_dline_miss(p3),
EDFACT_get_wcet_miss(p3),
EDFACT_get_nact(p3));
printf_xy(50,23,WHITE,"%3d %4d %4d %4d",
p4, EDFACT_get_dline_miss(p4),
EDFACT_get_wcet_miss(p4),
EDFACT_get_nact(p4));
}
}
 
int main(int argc, char **argv)
{
NRT_TASK_MODEL n;
 
HARD_TASK_MODEL m;
 
kern_printf("\nCtrl-C = end demo\n");
 
hard_task_default_model(m);
hard_task_def_mit(m,200000);
hard_task_def_group(m,1);
 
sem_init(&sem,0,0);
 
hard_task_def_wcet(m,2000);
p1 = task_create("1",aster1,&m,NULL);
if (p1 == -1) {
perror("Aster.C(main): Could not create task <aster> ...");
sys_end();
}
 
hard_task_def_wcet(m,2000);
p2 = task_create("1",aster2,&m,NULL);
if (p2 == -1) {
perror("Aster.C(main): Could not create task <aster> ...");
sys_end();
}
 
hard_task_def_wcet(m,2000);
p3 = task_create("1",aster3,&m,NULL);
if (p3 == -1) {
perror("Aster.C(main): Could not create task <aster> ...");
sys_end();
}
 
hard_task_def_mit(m,20000);
hard_task_def_wcet(m,500);
p4 = task_create("1",aster4,&m,NULL);
if (p4 == -1) {
perror("Aster.C(main): Could not create task <aster> ...");
sys_end();
}
 
group_activate(1);
 
nrt_task_default_model(n);
task_activate(task_create("Clock",clock,&n,NULL));
return 0;
}
 
/advdemos/trunk/edfact/edfact.h
0,0 → 1,152
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* Massimiliano Giorgi <massy@gandalf.sssup.it>
* Luca Abeni <luca@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/**
------------
CVS : $Id: edfact.h,v 1.1.1.1 2004-05-24 17:54:51 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2004-05-24 17:54:51 $
------------
 
This file contains the server EDFACT (EDF with pending activations)
 
Title:
EDFACT
 
Task Models Accepted:
HARD_TASK_MODEL - Hard Tasks (only Periodic)
wcet field and mit field must be != 0. They are used to set the wcet
and period of the tasks.
periodicity field can be only PERIODIC
drel field is ignored
Guest Models Accepted:
JOB_TASK_MODEL - a single guest task activation
Identified by an absolute deadline and a period.
period field is ignored
 
Description:
This module schedule his tasks following the classic EDF scheme.
The task guarantee is based on the factor utilization approach.
The tasks scheduled are only periodic.
All the task are put in a queue and the scheduling is based on the
deadline value.
NO GUARANTEE is performed on guest tasks. The guarantee must be performed
by the level that inserts guest tasks in the EDF level.
If a task miss a deadline a counter is incremented.
If a task exausts the wcet a counter is incremented
No ZOMBIE support!!!!!!
 
Exceptions raised:
XUNVALID_GUEST XUNVALID_TASK
some primitives are not implemented:
task_sleep, task_delay, guest_endcycle, guest_sleep, guest_delay
 
XACTIVATION
If a task is actiated through task_activate or guest_activate more than
one time
Restrictions & special features:
- This level doesn't manage the main task.
- At init time we have to specify:
. guarantee check
(when all task are created the system will check that the task_set
will not use more than the available bandwidth)
- A function to return the used bandwidth of the level is provided.
- Functions to return and reset the nact, wcet and dline miss counters
 
**/
 
/*
* Copyright (C) 2001 Paolo Gai
*
* 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
*
*/
 
 
#ifndef __EDFACT_H__
#define __EDFACT_H__
 
#include <ll/ll.h>
#include <kernel/config.h>
#include <sys/types.h>
#include <kernel/types.h>
 
 
 
 
 
 
 
 
/*+ flags... +*/
#define EDFACT_ENABLE_GUARANTEE 1 /*+ Task Guarantee enabled +*/
#define EDFACT_ENABLE_ALL 1
 
#define EDFACT_FAILED_GUARANTEE 8 /*+ used in the module, unsettabl
in EDF_register_level... +*/
 
 
 
 
 
#define ELASTIC_HARD_PCLASS 0x0600
 
#define EDFACT_LEVELNAME "EDFACT base"
#define EDFACT_LEVEL_CODE 166
#define EDFACT_LEVEL_VERSION 1
 
 
/*+ Registration function:
int flags Options to be used in this level instance...
 
returns the level number at which the module has been registered.
+*/
LEVEL EDFACT_register_level(int flags);
 
/*+ Returns the used bandwidth of a level +*/
bandwidth_t EDFACT_usedbandwidth(LEVEL l);
 
/*+ returns respectively the number of dline, wcet or nact; -1 if error +*/
int EDFACT_get_dline_miss(PID p);
int EDFACT_get_wcet_miss(PID p);
int EDFACT_get_nact(PID p);
 
/*+ resets respectively the number of dline, wcet miss; -1 if error +*/
int EDFACT_reset_dline_miss(PID p);
int EDFACT_reset_wcet_miss(PID p);
 
#endif
 
/advdemos/trunk/edfact/makefile
0,0 → 1,16
#
#
#
 
ifndef BASE
BASE=../..
endif
include $(BASE)/config/config.mk
 
PROGS= testact
 
include $(BASE)/config/example.mk
 
testact:
make -f $(SUBMAKE) APP=testact INIT= OTHEROBJS="initfile.o edfact.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
/advdemos/trunk/edfact/readme
0,0 → 1,31
EDFACT Scheduling Module
------------------------
by Paolo Gai 2001
 
 
Pisa, 6, Jun 2001
 
This Module implements a EDF scheduler.
 
It is very similar to the EDF Module distributed with the kernel sources,
except that:
- It does not support hard sporadic tasks
- It does not raise a deadline exception
- It does not raise a wcet violation exception
- Instead of raising an exception, the module simply COUNTS deadline misses
and wcet exaustions..
 
Since a large part of the applications use only periodic tasks, this Module
can be a great improvement because the application will not hang up at
the first exception!!! (and this happens frequently when switching to a
slower PC :-( )
 
I also wrote a simple test to show how the module works...
 
To use the Module in your applications, simply copy the edfact.c and edfact.h
into your application directory, and register edfact instead of the
tradictional edf...
 
For bugs, questions and comments please write to pj@sssup.it
 
Paolo