/demos/trunk/first/test1.c |
---|
18,11 → 18,11 |
/* |
------------ |
CVS : $Id: test1.c,v 1.1 2002-09-02 10:29:30 pj Exp $ |
CVS : $Id: test1.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2002-09-02 10:29:30 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
this test shows a set of 5 tasks (+main+dummy+keyboard driver). |
120,7 → 120,6 |
//keyb_def_ctrlC(kparms, NULL); |
//keyb_def_map(kparms,itaMap); |
KEYB_init(&kparms); |
__call_main__(mb); |
return (void *)0; |
229,11 → 228,9 |
{ |
char c; |
set_exchandler_grx(); |
clear(); |
cprintf("Hello, world!"); |
cprintf("Hello, world!\nPress ESC to end the demo...\n"); |
create1(); |
/demos/trunk/first/test2.c |
---|
18,11 → 18,11 |
/* |
------------ |
CVS : $Id: test2.c,v 1.1 2002-09-02 10:29:30 pj Exp $ |
CVS : $Id: test2.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2002-09-02 10:29:30 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
The purpose of this test is to show that two budgets with different |
224,8 → 224,6 |
{ |
char c; |
set_exchandler_grx(); |
cprintf("Hello, world!"); |
create1(); |
/demos/trunk/first/cbsstar.c |
---|
20,11 → 20,11 |
/* |
------------ |
CVS : $Id: cbsstar.c,v 1.3 2002-11-11 08:17:59 pj Exp $ |
CVS : $Id: cbsstar.c,v 1.4 2003-01-07 17:10:16 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2002-11-11 08:17:59 $ |
Revision: $Revision: 1.4 $ |
Last update: $Date: 2003-01-07 17:10:16 $ |
------------ |
Read CBSSTAR.h for general details. |
77,7 → 77,7 |
//#define CBSSTAR_DEBUG |
#ifdef CBSSTAR_DEBUF |
#ifdef CBSSTAR_DEBUG |
static __inline__ void fake_printf(char *fmt, ...) {} |
206,10 → 206,7 |
job_task_default_model(job, b->dline); |
job_task_def_noexc(job); |
level_table[ lev->scheduling_level ]-> |
guest_create(lev->scheduling_level, p, (TASK_MODEL *)&job); |
level_table[ lev->scheduling_level ]-> |
guest_activate(lev->scheduling_level, p); |
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
} |
228,35 → 225,8 |
} |
static int CBSSTAR_level_accept_task_model(LEVEL l, TASK_MODEL *m) |
{ |
return -1; |
} |
static int CBSSTAR_level_accept_guest_model(LEVEL l, TASK_MODEL *m) |
{ |
if (m->pclass == BUDGET_PCLASS || m->pclass == (BUDGET_PCLASS | l)) { |
return 0; |
} |
return -1; |
} |
static void CBSSTAR_level_status(LEVEL l) |
{ |
kern_printf("CBSSTAR level_status (level %d)\n", l); |
} |
static PID CBSSTAR_level_scheduler(LEVEL l) |
{ |
/* the CBSSTAR don't schedule anything... |
it's an EDF level or similar that do it! */ |
return NIL; |
} |
/* The on-line guarantee is enabled only if the appropriate flag is set... */ |
static int CBSSTAR_level_guarantee(LEVEL l, bandwidth_t *freebandwidth) |
static int CBSSTAR_public_guarantee(LEVEL l, bandwidth_t *freebandwidth) |
{ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
272,19 → 242,8 |
return 0; |
} |
static int CBSSTAR_task_create(LEVEL l, PID p, TASK_MODEL *m) |
static int CBSSTAR_private_eligible(LEVEL l, PID p) |
{ |
kern_raise(XINVALID_TASK,exec_shadow); |
return 0; /* OK, also if the task cannot be guaranteed... */ |
} |
static void CBSSTAR_task_detach(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
static int CBSSTAR_task_eligible(LEVEL l, PID p) |
{ |
/* this function is never called! ... maybe I should remove it? */ |
#if 0 |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
struct budget_struct *b = &lev->b[lev->tb[p]]; |
JOB_TASK_MODEL job; |
303,7 → 262,7 |
if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time) ) { |
/* we kill the current activation */ |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level, p); |
private_extract(lev->scheduling_level, p); |
/* we modify the deadline ... */ |
TIMESPEC_ASSIGN(&b->dline, &schedule_time); |
322,9 → 281,7 |
job_task_default_model(job, b->dline); |
job_task_def_noexc(job); |
level_table[ lev->scheduling_level ]-> |
guest_create(lev->scheduling_level, p, (TASK_MODEL *)&job); |
level_table[ lev->scheduling_level ]-> |
guest_activate(lev->scheduling_level, p); |
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
return -1; |
} |
332,35 → 289,10 |
cbsstar_printf(")"); |
#endif |
#endif |
return 0; |
} |
static void CBSSTAR_task_dispatch(LEVEL l, PID p, int nostop) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
static void CBSSTAR_task_epilogue(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
static void CBSSTAR_task_activate(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
static void CBSSTAR_task_insert(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
static void CBSSTAR_task_extract(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
static void CBSSTAR_task_endcycle(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
static void CBSSTAR_task_end(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
static void CBSSTAR_task_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
static int CBSSTAR_guest_create(LEVEL l, PID p, TASK_MODEL *m) |
static void CBSSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m) |
{ |
/* A task has been activated for some reason. Basically, the task is |
inserted in the queue if the queue is empty, otherwise the task is |
367,8 → 299,15 |
inserted into the master module, and an oslib event is posted. */ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
BUDGET_TASK_MODEL *budget = (BUDGET_TASK_MODEL *)m; |
BUDGET_TASK_MODEL *budget; |
if (m->pclass != BUDGET_PCLASS || |
(m->level != 0 && m->level != l)) { |
kern_raise(XINVALID_TASK, p); |
return; |
} |
budget = (BUDGET_TASK_MODEL *)m; |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf("(C:gcr %d b%d", p, budget->b); |
#endif |
379,7 → 318,7 |
/* This is the first task in the budget, |
the task have to be inserted into the master module */ |
struct timespec t; |
ll_gettime(TIME_EXACT, &t); |
kern_gettime(&t); |
CBSSTAR_activation(lev,p,&t); |
} else { |
/* The budget is not empty, another task is already into the |
394,11 → 333,9 |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(")"); |
#endif |
return 0; |
} |
static void CBSSTAR_guest_end(LEVEL l, PID p) |
static void CBSSTAR_private_extract(LEVEL l, PID p) |
{ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
416,7 → 353,7 |
if (lev->b[lev->tb[p]].current == p) { |
/* remove the task from the master module */ |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level, p); |
private_extract(lev->scheduling_level, p); |
#ifdef CBSSTAR_DEBUG |
cbsstar_printq(&lev->b[lev->tb[p]].tasks); |
432,7 → 369,7 |
PID n; |
struct timespec t; |
ll_gettime(TIME_EXACT, &t); |
kern_gettime(&t); |
n = iq_getfirst(&lev->b[lev->tb[p]].tasks); |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf("{p%d n%d}",p,n); |
444,7 → 381,7 |
iq_extract(p, &lev->b[lev->tb[p]].tasks); |
} |
static void CBSSTAR_guest_dispatch(LEVEL l, PID p, int nostop) |
static void CBSSTAR_private_dispatch(LEVEL l, PID p, int nostop) |
{ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
struct timespec ty; |
461,7 → 398,7 |
/* ... then, we dispatch it to the master level */ |
level_table[ lev->scheduling_level ]-> |
guest_dispatch(lev->scheduling_level,p,nostop); |
private_dispatch(lev->scheduling_level,p,nostop); |
/* ...and finally, we have to post a capacity event */ |
if (!nostop) { |
471,7 → 408,7 |
} |
} |
static void CBSSTAR_guest_epilogue(LEVEL l, PID p) |
static void CBSSTAR_private_epilogue(LEVEL l, PID p) |
{ |
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]); |
struct budget_struct *b = &lev->b[lev->tb[p]]; |
487,7 → 424,7 |
/* there is capacity available, maybe it is simply a preemption; |
the task have to return to the ready queue */ |
level_table[ lev->scheduling_level ]-> |
guest_epilogue(lev->scheduling_level,p); |
private_epilogue(lev->scheduling_level,p); |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf2(" *av=%d", b->avail); |
#endif |
498,7 → 435,7 |
/* we kill the current activation */ |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level, p); |
private_extract(lev->scheduling_level, p); |
/* we modify the deadline according to rule 4 ... */ |
/* there is a while because if the wcet is << than the system tick |
520,9 → 457,7 |
job_task_default_model(job, b->dline); |
job_task_def_noexc(job); |
level_table[ lev->scheduling_level ]-> |
guest_create(lev->scheduling_level, p, (TASK_MODEL *)&job); |
level_table[ lev->scheduling_level ]-> |
guest_activate(lev->scheduling_level, p); |
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job); |
} |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(")"); |
529,27 → 464,7 |
#endif |
} |
static void CBSSTAR_guest_detach(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
static void CBSSTAR_guest_activate(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
static void CBSSTAR_guest_insert(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
static void CBSSTAR_guest_extract(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
static void CBSSTAR_guest_endcycle(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
static void CBSSTAR_guest_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
/* Registration functions */ |
/*+ Registration function: |
565,56 → 480,21 |
#endif |
/* request an entry in the level_table */ |
l = level_alloc_descriptor(); |
l = level_alloc_descriptor(sizeof(CBSSTAR_level_des)); |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(" alloco descrittore %d %d\n",l,(int)sizeof(CBSSTAR_level_des)); |
#endif |
lev = (CBSSTAR_level_des *)level_table[l]; |
/* alloc the space needed for the CBSSTAR_level_des */ |
lev = (CBSSTAR_level_des *)kern_alloc(sizeof(CBSSTAR_level_des)); |
printk(" lev=%d\n",(int)lev); |
#ifdef CBSSTAR_DEBUG |
cbsstar_printf(" lev=%d\n",(int)lev); |
#endif |
/* update the level_table with the new entry */ |
level_table[l] = (level_des *)lev; |
/* fill the standard descriptor */ |
strncpy(lev->l.level_name, CBSSTAR_LEVELNAME, MAX_LEVELNAME); |
lev->l.level_code = CBSSTAR_LEVEL_CODE; |
lev->l.level_version = CBSSTAR_LEVEL_VERSION; |
lev->l.private_insert = CBSSTAR_private_insert; |
lev->l.private_extract = CBSSTAR_private_extract; |
lev->l.private_eligible = CBSSTAR_private_eligible; |
lev->l.private_dispatch = CBSSTAR_private_dispatch; |
lev->l.private_epilogue = CBSSTAR_private_epilogue; |
lev->l.level_accept_task_model = CBSSTAR_level_accept_task_model; |
lev->l.level_accept_guest_model = CBSSTAR_level_accept_guest_model; |
lev->l.level_status = CBSSTAR_level_status; |
lev->l.level_scheduler = CBSSTAR_level_scheduler; |
lev->l.level_guarantee = CBSSTAR_level_guarantee; |
lev->l.public_guarantee = CBSSTAR_public_guarantee; |
lev->l.task_create = CBSSTAR_task_create; |
lev->l.task_detach = CBSSTAR_task_detach; |
lev->l.task_eligible = CBSSTAR_task_eligible; |
lev->l.task_dispatch = CBSSTAR_task_dispatch; |
lev->l.task_epilogue = CBSSTAR_task_epilogue; |
lev->l.task_activate = CBSSTAR_task_activate; |
lev->l.task_insert = CBSSTAR_task_insert; |
lev->l.task_extract = CBSSTAR_task_extract; |
lev->l.task_endcycle = CBSSTAR_task_endcycle; |
lev->l.task_end = CBSSTAR_task_end; |
lev->l.task_sleep = CBSSTAR_task_sleep; |
lev->l.guest_create = CBSSTAR_guest_create; |
lev->l.guest_detach = CBSSTAR_guest_detach; |
lev->l.guest_dispatch = CBSSTAR_guest_dispatch; |
lev->l.guest_epilogue = CBSSTAR_guest_epilogue; |
lev->l.guest_activate = CBSSTAR_guest_activate; |
lev->l.guest_insert = CBSSTAR_guest_insert; |
lev->l.guest_extract = CBSSTAR_guest_extract; |
lev->l.guest_endcycle = CBSSTAR_guest_endcycle; |
lev->l.guest_end = CBSSTAR_guest_end; |
lev->l.guest_sleep = CBSSTAR_guest_sleep; |
/* fill the CBSSTAR descriptor part */ |
lev->b = (struct budget_struct *)kern_alloc(sizeof(struct budget_struct)*n); |
649,30 → 529,25 |
cbsstar_printf("(C:sbud)"); |
#endif |
if (lev->l.level_code == CBSSTAR_LEVEL_CODE && |
lev->l.level_version == CBSSTAR_LEVEL_VERSION) { |
if (lev->freebudgets != lev->n) { |
bandwidth_t b; |
b = (MAX_BANDWIDTH / T) * Q; |
if (lev->freebudgets != lev->n) { |
bandwidth_t b; |
b = (MAX_BANDWIDTH / T) * Q; |
/* really update lev->U, checking an overflow... */ |
if (Q< T && MAX_BANDWIDTH - lev->U > b) { |
int r = lev->freebudgets; // the return value |
/* really update lev->U, checking an overflow... */ |
if (Q< T && MAX_BANDWIDTH - lev->U > b) { |
int r = lev->freebudgets; // the return value |
lev->U += b; |
lev->freebudgets++; |
lev->b[r].Q = Q; |
lev->b[r].T = T; |
return r; |
} |
else |
return -2; |
lev->U += b; |
lev->freebudgets++; |
lev->b[r].Q = Q; |
lev->b[r].T = T; |
return r; |
} |
else |
return -1; |
return -2; |
} |
else |
return -3; |
return -1; |
} |
/demos/trunk/first/test3.c |
---|
18,11 → 18,11 |
/* |
------------ |
CVS : $Id: test3.c,v 1.1 2002-09-02 10:29:30 pj Exp $ |
CVS : $Id: test3.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2002-09-02 10:29:30 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
The purpose of this test is to show that two budgets with different |
199,8 → 199,6 |
{ |
KEY_EVT k; |
set_exchandler_grx(); |
sem_init(&s,0,1); |
k.flag = 0; |
/demos/trunk/first/test4.c |
---|
18,11 → 18,11 |
/* |
------------ |
CVS : $Id: test4.c,v 1.1 2002-09-02 10:29:30 pj Exp $ |
CVS : $Id: test4.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2002-09-02 10:29:30 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
The purpose of this test is to show that two budgets with different |
217,8 → 217,6 |
{ |
KEY_EVT k; |
set_exchandler_grx(); |
sem_init(&s,0,1); |
k.flag = 0; |
/demos/trunk/first/test5.c |
---|
18,11 → 18,11 |
/* |
------------ |
CVS : $Id: test5.c,v 1.1 2002-09-02 10:29:30 pj Exp $ |
CVS : $Id: test5.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2002-09-02 10:29:30 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
The purpose of this test is to show that two budgets with different |
234,8 → 234,6 |
{ |
KEY_EVT k; |
set_exchandler_grx(); |
sem_init(&s,0,1); |
k.flag = 0; |
/demos/trunk/first/test6.c |
---|
18,11 → 18,11 |
/* |
------------ |
CVS : $Id: test6.c,v 1.1 2002-09-02 10:29:30 pj Exp $ |
CVS : $Id: test6.c,v 1.2 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2002-09-02 10:29:30 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
this test shows a set of 5 tasks (+main+dummy+keyboard driver). |
229,8 → 229,6 |
{ |
char c; |
set_exchandler_grx(); |
clear(); |
cprintf("Hello, world!"); |
/demos/trunk/first/rmstar.c |
---|
18,11 → 18,11 |
/** |
------------ |
CVS : $Id: rmstar.c,v 1.3 2002-11-11 08:17:59 pj Exp $ |
CVS : $Id: rmstar.c,v 1.4 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2002-11-11 08:17:59 $ |
Revision: $Revision: 1.4 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
**/ |
66,7 → 66,7 |
//#define RMSTAR_DEBUG |
#ifdef RMSTAR_DEBUF |
#ifdef RMSTAR_DEBUG |
static __inline__ fake_printf(char *fmt, ...) {} |
131,7 → 131,7 |
if ((first = iq_query_first(&lev->ready)) != lev->activated) { |
if (lev->activated != NIL) |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level, lev->activated); |
private_extract(lev->scheduling_level, lev->activated); |
lev->activated = first; |
140,7 → 140,7 |
budget_task_default_model(b, lev->budget); |
level_table[ lev->scheduling_level ]-> |
guest_create(lev->scheduling_level, first, (TASK_MODEL *)&b); |
private_insert(lev->scheduling_level, first, (TASK_MODEL *)&b); |
} |
} |
} |
147,19 → 147,17 |
static void RMSTAR_timer_deadline(void *par); |
static void RMSTAR_internal_activate(RMSTAR_level_des *lev, PID p) |
static void RMSTAR_internal_activate(RMSTAR_level_des *lev, PID p, |
struct timespec *t) |
{ |
struct timespec temp; |
#ifdef RMSTAR_DEBUG |
rmstar_printf("(E:iact)"); |
#endif |
TIMESPEC_ASSIGN(&temp, &proc_table[p].request_time); |
ADDUSEC2TIMESPEC(lev->period[p], &temp); |
ADDUSEC2TIMESPEC(lev->period[p], t); |
*iq_query_timespec(p, &lev->ready) = temp; |
lev->deadline_timespec[p] = temp; |
*iq_query_timespec(p, &lev->ready) = *t; |
lev->deadline_timespec[p] = *t; |
/* Insert task in the correct position */ |
proc_table[p].status = RMSTAR_READY; |
172,18 → 170,6 |
RMSTAR_check_preemption(lev); |
} |
static char *RMSTAR_status_to_a(WORD status) |
{ |
if (status < MODULE_STATUS_BASE) |
return status_to_a(status); |
switch (status) { |
case RMSTAR_READY : return "RMSTAR_Ready"; |
case RMSTAR_IDLE : return "RMSTAR_Idle"; |
default : return "RMSTAR_Unknown"; |
} |
} |
static void RMSTAR_timer_deadline(void *par) |
{ |
PID p = (PID) par; |
201,10 → 187,8 |
// rmstar_printf2("I%d",p); |
#endif |
/* set the request time */ |
proc_table[p].request_time = *iq_query_timespec(p, &lev->ready); |
RMSTAR_internal_activate(lev,p,iq_query_timespec(p, &lev->ready)); |
RMSTAR_internal_activate(lev,p); |
event_need_reschedule(); |
break; |
243,104 → 227,20 |
kern_raise(XDEADLINE_MISS,p); |
} |
static int RMSTAR_level_accept_task_model(LEVEL l, TASK_MODEL *m) |
static int RMSTAR_public_create(LEVEL l, PID p, TASK_MODEL *m) |
{ |
#ifdef RMSTAR_DEBUG |
rmstar_printf("(E:lacct)"); |
#endif |
if (m->pclass == HARD_PCLASS || m->pclass == (HARD_PCLASS | l)) { |
HARD_TASK_MODEL *h = (HARD_TASK_MODEL *)m; |
if (h->wcet && h->mit && h->periodicity == PERIODIC) |
return 0; |
} |
return -1; |
} |
static int RMSTAR_level_accept_guest_model(LEVEL l, TASK_MODEL *m) |
{ |
#ifdef RMSTAR_DEBUG |
rmstar_printf("(E:laccg)"); |
#endif |
if (m->pclass == JOB_PCLASS || m->pclass == (JOB_PCLASS | l)) |
return 0; |
else |
return -1; |
} |
static char *onoff(int i) |
{ |
if (i) |
return "On "; |
else |
return "Off"; |
} |
static void RMSTAR_level_status(LEVEL l) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
PID p = iq_query_first(&lev->ready); |
struct timespec temp; |
kern_printf("Budget number : %u\n", lev->budget); |
kern_printf("Master level : %u\n", lev->scheduling_level); |
kern_printf("Active PID : %u\n", lev->activated); |
while (p != NIL) { |
if ((proc_table[p].pclass) == JOB_PCLASS) |
kern_printf("Pid: %2d (GUEST)\n", p); |
else { |
temp = *iq_query_timespec(p, &lev->ready); |
kern_printf("Pid: %2d Name: %10s %s: %9ld Dline: %9ld.%6ld Stat: %s\n", |
p, |
proc_table[p].name, |
"Period ", |
lev->period[p], |
temp.tv_sec, |
temp.tv_nsec/1000, |
RMSTAR_status_to_a(proc_table[p].status)); |
p = iq_query_next(p, &lev->ready); |
} |
} |
for (p=0; p<MAX_PROC; p++) |
if (proc_table[p].task_level == l |
&& proc_table[p].status != RMSTAR_READY |
&& proc_table[p].status != FREE ) { |
temp = *iq_query_timespec(p, &lev->ready); |
kern_printf("Pid: %2d Name: %10s %s: %9ld Dline: %9ld.%6ld Stat: %s\n", |
p, |
proc_table[p].name, |
"Period ", |
lev->period[p], |
temp.tv_sec, |
temp.tv_nsec/1000, |
RMSTAR_status_to_a(proc_table[p].status)); |
} |
} |
/* The scheduler only gets the first task in the queue */ |
static PID RMSTAR_level_scheduler(LEVEL l) |
{ |
//RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
return NIL; |
} |
static int RMSTAR_task_create(LEVEL l, PID p, TASK_MODEL *m) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
/* if the RMSTAR_task_create is called, then the pclass must be a |
valid pclass. */ |
HARD_TASK_MODEL *h = (HARD_TASK_MODEL *)m; |
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 */ |
#ifdef RMSTAR_DEBUG |
rmstar_printf("(E:tcr)"); |
#endif |
362,24 → 262,8 |
return 0; /* OK, also if the task cannot be guaranteed... */ |
} |
static void RMSTAR_task_detach(LEVEL l, PID p) |
static void RMSTAR_public_dispatch(LEVEL l, PID p, int nostop) |
{ |
#ifdef RMSTAR_DEBUG |
rmstar_printf2("(E:tdt)"); |
#endif |
} |
static int RMSTAR_task_eligible(LEVEL l, PID p) |
{ |
#ifdef RMSTAR_DEBUG |
rmstar_printf2("(E:eli)"); |
#endif |
return 0; /* if the task p is chosen, it is always eligible */ |
} |
static void RMSTAR_task_dispatch(LEVEL l, PID p, int nostop) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
#ifdef RMSTAR_DEBUG |
391,10 → 275,10 |
#endif |
level_table[ lev->scheduling_level ]-> |
guest_dispatch(lev->scheduling_level,p,nostop); |
private_dispatch(lev->scheduling_level,p,nostop); |
} |
static void RMSTAR_task_epilogue(LEVEL l, PID p) |
static void RMSTAR_public_epilogue(LEVEL l, PID p) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
416,14 → 300,15 |
#endif |
level_table[ lev->scheduling_level ]-> |
guest_epilogue(lev->scheduling_level,p); |
private_epilogue(lev->scheduling_level,p); |
proc_table[p].status = RMSTAR_READY; |
} |
static void RMSTAR_task_activate(LEVEL l, PID p) |
static void RMSTAR_public_activate(LEVEL l, PID p) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
struct timespec t; |
#ifdef RMSTAR_DEBUG |
rmstar_printf("(E:act)"); |
437,9 → 322,9 |
return; |
} |
ll_gettime(TIME_EXACT, &proc_table[p].request_time); |
kern_gettime(&t); |
RMSTAR_internal_activate(lev,p); |
RMSTAR_internal_activate(lev,p, &t); |
/* Set the deadline timer */ |
lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p], |
448,7 → 333,7 |
} |
static void RMSTAR_task_insert(LEVEL l, PID p) |
static void RMSTAR_public_unblock(LEVEL l, PID p) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
464,7 → 349,7 |
RMSTAR_check_preemption(lev); |
} |
static void RMSTAR_task_extract(LEVEL l, PID p) |
static void RMSTAR_public_block(LEVEL l, PID p) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
480,7 → 365,7 |
RMSTAR_check_preemption(lev); |
} |
static void RMSTAR_task_endcycle(LEVEL l, PID p) |
static int RMSTAR_public_message(LEVEL l, PID p, void *m) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
struct timespec temp; |
492,8 → 377,7 |
/* we call guest_end directly here because the same task may |
be reinserted in the queue before calling the preemption check! */ |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level,p); |
lev->activated = NIL; |
private_extract(lev->scheduling_level,p); lev->activated = NIL; |
iq_extract(p,&lev->ready); |
509,9 → 393,9 |
lev->nact[p]--; |
/* see also RMSTAR_timer_deadline */ |
ll_gettime(TIME_EXACT, &proc_table[p].request_time); |
kern_gettime(&temp); |
RMSTAR_internal_activate(lev,p); |
RMSTAR_internal_activate(lev,p,&temp); |
/* check if the deadline has already expired */ |
temp = *iq_query_timespec(p, &lev->ready); |
518,7 → 402,7 |
if (TIMESPEC_A_LT_B(&temp, &schedule_time)) { |
/* count the deadline miss */ |
lev->dline_miss[p]++; |
event_delete(lev->deadline_timer[p]); |
kern_event_delete(lev->deadline_timer[p]); |
} |
} |
534,14 → 418,19 |
RMSTAR_check_preemption(lev); |
/* when the deadline timer fire, it recognize the situation and set |
correctly all the stuffs (like reactivation, request_time, etc... ) */ |
correctly all the stuffs (like reactivation, etc... ) */ |
} |
#ifdef RMSTAR_DEBUG |
rmstar_printf(")"); |
#endif |
jet_update_endcycle(); /* Update the Jet data... */ |
trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */ |
return 0; |
} |
static void RMSTAR_task_end(LEVEL l, PID p) |
static void RMSTAR_public_end(LEVEL l, PID p) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
557,7 → 446,7 |
iq_insertfirst(p,&freedesc); |
if (lev->deadline_timer[p] != -1) { |
event_delete(lev->deadline_timer[p]); |
kern_event_delete(lev->deadline_timer[p]); |
} |
/* and finally, a preemption check! (it will also call guest_end) */ |
564,22 → 453,23 |
RMSTAR_check_preemption(lev); |
} |
static void RMSTAR_task_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
/* Guest Functions |
These functions manages a JOB_TASK_MODEL, that is used to put |
a guest task in the RMSTAR ready queue. */ |
static int RMSTAR_guest_create(LEVEL l, PID p, TASK_MODEL *m) |
static void RMSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
JOB_TASK_MODEL *job = (JOB_TASK_MODEL *)m; |
JOB_TASK_MODEL *job; |
/* if the RMSTAR_guest_create is called, then the pclass must be a |
valid pclass. */ |
if (m->pclass != JOB_PCLASS || (m->level != 0 && m->level != l) ) { |
kern_raise(XINVALID_TASK, p); |
return; |
} |
job = (JOB_TASK_MODEL *)m; |
*iq_query_timespec(p, &lev->ready) = job->deadline; |
lev->deadline_timer[p] = -1; |
589,8 → 479,12 |
if (job->noraiseexc) |
lev->flag[p] = RMSTAR_FLAG_NORAISEEXC; |
else |
else { |
lev->flag[p] = 0; |
lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready), |
RMSTAR_timer_guest_deadline, |
(void *)p); |
} |
lev->period[p] = job->period; |
*iq_query_priority(p, &lev->ready) = job->period; |
598,39 → 492,6 |
/* there is no bandwidth guarantee at this level, it is performed |
by the level that inserts guest tasks... */ |
return 0; /* OK, also if the task cannot be guaranteed... */ |
} |
static void RMSTAR_guest_detach(LEVEL l, PID p) |
{ |
/* the RMSTAR level doesn't introduce any dinamic allocated new field. |
No guarantee is performed on guest tasks... so we don't have to reset |
the NO_GUARANTEE FIELD */ |
} |
static void RMSTAR_guest_dispatch(LEVEL l, PID p, int nostop) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
level_table[ lev->scheduling_level ]-> |
guest_dispatch(lev->scheduling_level,p,nostop); |
} |
static void RMSTAR_guest_epilogue(LEVEL l, PID p) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
/* the task has been preempted. it returns into the ready queue... */ |
level_table[ lev->scheduling_level ]-> |
guest_epilogue(lev->scheduling_level,p); |
proc_table[p].status = RMSTAR_READY; |
} |
static void RMSTAR_guest_activate(LEVEL l, PID p) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
/* Insert task in the correct position */ |
iq_priority_insert(p,&lev->ready); |
proc_table[p].status = RMSTAR_READY; |
637,40 → 498,28 |
/* check for preemption */ |
RMSTAR_check_preemption(lev); |
/* Set the deadline timer */ |
if (!(lev->flag[p] & RMSTAR_FLAG_NORAISEEXC)) |
lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready), |
RMSTAR_timer_guest_deadline, |
(void *)p); |
} |
static void RMSTAR_guest_insert(LEVEL l, PID p) |
static void RMSTAR_private_dispatch(LEVEL l, PID p, int nostop) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
/* Insert task in the correct position */ |
iq_priority_insert(p,&lev->ready); |
proc_table[p].status = RMSTAR_READY; |
/* and check for preemption! */ |
RMSTAR_check_preemption(lev); |
level_table[ lev->scheduling_level ]-> |
private_dispatch(lev->scheduling_level,p,nostop); |
} |
static void RMSTAR_guest_extract(LEVEL l, PID p) |
static void RMSTAR_private_epilogue(LEVEL l, PID p) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
/* the task is blocked on a synchronization primitive. we have to |
remove it from the master module -and- from the local queue! */ |
iq_extract(p,&lev->ready); |
/* the task has been preempted. it returns into the ready queue... */ |
level_table[ lev->scheduling_level ]-> |
private_epilogue(lev->scheduling_level,p); |
/* and finally, a preemption check! (it will also call guest_end() */ |
RMSTAR_check_preemption(lev); |
proc_table[p].status = RMSTAR_READY; |
} |
static void RMSTAR_guest_end(LEVEL l, PID p) |
static void RMSTAR_private_extract(LEVEL l, PID p) |
{ |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
685,7 → 534,7 |
#ifdef RMSTAR_DEBUG |
// kern_printf("RMSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]); |
#endif |
event_delete(lev->deadline_timer[p]); |
kern_event_delete(lev->deadline_timer[p]); |
lev->deadline_timer[p] = NIL; |
} |
693,12 → 542,6 |
RMSTAR_check_preemption(lev); |
} |
static void RMSTAR_guest_endcycle(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
static void RMSTAR_guest_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
/* Registration functions */ |
/* Registration function: |
714,55 → 557,28 |
#endif |
/* request an entry in the level_table */ |
l = level_alloc_descriptor(); |
l = level_alloc_descriptor(sizeof(RMSTAR_level_des)); |
#ifdef RMSTAR_DEBUG |
printk(" alloco descrittore %d %d\n",l,(int)sizeof(RMSTAR_level_des)); |
#endif |
lev = (RMSTAR_level_des *)level_table[l]; |
/* alloc the space needed for the RMSTAR_level_des */ |
lev = (RMSTAR_level_des *)kern_alloc(sizeof(RMSTAR_level_des)); |
#ifdef RMSTAR_DEBUG |
printk(" lev=%d\n",(int)lev); |
#endif |
/* update the level_table with the new entry */ |
level_table[l] = (level_des *)lev; |
/* fill the standard descriptor */ |
strncpy(lev->l.level_name, RMSTAR_LEVELNAME, MAX_LEVELNAME); |
lev->l.level_code = RMSTAR_LEVEL_CODE; |
lev->l.level_version = RMSTAR_LEVEL_VERSION; |
lev->l.private_insert = RMSTAR_private_insert; |
lev->l.private_extract = RMSTAR_private_extract; |
lev->l.private_dispatch = RMSTAR_private_dispatch; |
lev->l.private_epilogue = RMSTAR_private_epilogue; |
lev->l.level_accept_task_model = RMSTAR_level_accept_task_model; |
lev->l.level_accept_guest_model = RMSTAR_level_accept_guest_model; |
lev->l.level_status = RMSTAR_level_status; |
lev->l.level_scheduler = RMSTAR_level_scheduler; |
lev->l.level_guarantee = NULL; |
lev->l.task_create = RMSTAR_task_create; |
lev->l.task_detach = RMSTAR_task_detach; |
lev->l.task_eligible = RMSTAR_task_eligible; |
lev->l.task_dispatch = RMSTAR_task_dispatch; |
lev->l.task_epilogue = RMSTAR_task_epilogue; |
lev->l.task_activate = RMSTAR_task_activate; |
lev->l.task_insert = RMSTAR_task_insert; |
lev->l.task_extract = RMSTAR_task_extract; |
lev->l.task_endcycle = RMSTAR_task_endcycle; |
lev->l.task_end = RMSTAR_task_end; |
lev->l.task_sleep = RMSTAR_task_sleep; |
lev->l.public_guarantee = NULL; |
lev->l.public_create = RMSTAR_public_create; |
lev->l.public_end = RMSTAR_public_end; |
lev->l.public_dispatch = RMSTAR_public_dispatch; |
lev->l.public_epilogue = RMSTAR_public_epilogue; |
lev->l.public_activate = RMSTAR_public_activate; |
lev->l.public_unblock = RMSTAR_public_unblock; |
lev->l.public_block = RMSTAR_public_block; |
lev->l.public_message = RMSTAR_public_message; |
lev->l.guest_create = RMSTAR_guest_create; |
lev->l.guest_detach = RMSTAR_guest_detach; |
lev->l.guest_dispatch = RMSTAR_guest_dispatch; |
lev->l.guest_epilogue = RMSTAR_guest_epilogue; |
lev->l.guest_activate = RMSTAR_guest_activate; |
lev->l.guest_insert = RMSTAR_guest_insert; |
lev->l.guest_extract = RMSTAR_guest_extract; |
lev->l.guest_endcycle = RMSTAR_guest_endcycle; |
lev->l.guest_end = RMSTAR_guest_end; |
lev->l.guest_sleep = RMSTAR_guest_sleep; |
/* fill the RMSTAR descriptor part */ |
for(i=0; i<MAX_PROC; i++) { |
lev->period[i] = 0; |
786,11 → 602,8 |
{ |
LEVEL l = proc_table[p].task_level; |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == RMSTAR_LEVEL_CODE && |
lev->l.level_version == RMSTAR_LEVEL_VERSION) |
return lev->dline_miss[p]; |
else |
return -1; |
return lev->dline_miss[p]; |
} |
int RMSTAR_get_wcet_miss(PID p) |
797,11 → 610,8 |
{ |
LEVEL l = proc_table[p].task_level; |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == RMSTAR_LEVEL_CODE && |
lev->l.level_version == RMSTAR_LEVEL_VERSION) |
return lev->wcet_miss[p]; |
else |
return -1; |
return lev->wcet_miss[p]; |
} |
int RMSTAR_get_nact(PID p) |
808,11 → 618,8 |
{ |
LEVEL l = proc_table[p].task_level; |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == RMSTAR_LEVEL_CODE && |
lev->l.level_version == RMSTAR_LEVEL_VERSION) |
return lev->nact[p]; |
else |
return -1; |
return lev->nact[p]; |
} |
int RMSTAR_reset_dline_miss(PID p) |
819,14 → 626,9 |
{ |
LEVEL l = proc_table[p].task_level; |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == RMSTAR_LEVEL_CODE && |
lev->l.level_version == RMSTAR_LEVEL_VERSION) |
{ |
lev->dline_miss[p] = 0; |
return 0; |
} |
else |
return -1; |
lev->dline_miss[p] = 0; |
return 0; |
} |
int RMSTAR_reset_wcet_miss(PID p) |
833,13 → 635,8 |
{ |
LEVEL l = proc_table[p].task_level; |
RMSTAR_level_des *lev = (RMSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == RMSTAR_LEVEL_CODE && |
lev->l.level_version == RMSTAR_LEVEL_VERSION) |
{ |
lev->wcet_miss[p] = 0; |
return 0; |
} |
else |
return -1; |
lev->wcet_miss[p] = 0; |
return 0; |
} |
/demos/trunk/first/testiq.c |
---|
18,11 → 18,11 |
/* |
------------ |
CVS : $Id: testiq.c,v 1.2 2002-11-11 08:17:59 pj Exp $ |
CVS : $Id: testiq.c,v 1.3 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:17:59 $ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
The purpose of this test is to show that two budgets with different |
246,8 → 246,6 |
{ |
KEY_EVT k; |
set_exchandler_grx(); |
sem_init(&s,0,1); |
k.flag = 0; |
/demos/trunk/first/rmstar.h |
---|
20,11 → 20,11 |
/** |
------------ |
CVS : $Id: rmstar.h,v 1.1 2002-09-02 10:29:30 pj Exp $ |
CVS : $Id: rmstar.h,v 1.2 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2002-09-02 10:29:30 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
Title: |
92,7 → 92,6 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include <modules/codes.h> |
/demos/trunk/first/edfstar.c |
---|
18,11 → 18,11 |
/** |
------------ |
CVS : $Id: edfstar.c,v 1.3 2002-11-11 08:17:59 pj Exp $ |
CVS : $Id: edfstar.c,v 1.4 2003-01-07 17:10:16 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2002-11-11 08:17:59 $ |
Revision: $Revision: 1.4 $ |
Last update: $Date: 2003-01-07 17:10:16 $ |
------------ |
**/ |
133,7 → 133,7 |
if ((first = iq_query_first(&lev->ready)) != lev->activated) { |
if (lev->activated != NIL) |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level, lev->activated); |
private_extract(lev->scheduling_level, lev->activated); |
lev->activated = first; |
142,7 → 142,7 |
budget_task_default_model(b, lev->budget); |
level_table[ lev->scheduling_level ]-> |
guest_create(lev->scheduling_level, first, (TASK_MODEL *)&b); |
private_insert(lev->scheduling_level, first, (TASK_MODEL *)&b); |
} |
} |
} |
149,19 → 149,17 |
static void EDFSTAR_timer_deadline(void *par); |
static void EDFSTAR_internal_activate(EDFSTAR_level_des *lev, PID p) |
static void EDFSTAR_internal_activate(EDFSTAR_level_des *lev, PID p, |
struct timespec *t) |
{ |
struct timespec temp; |
#ifdef EDFSTAR_DEBUG |
edfstar_printf("(E:iact)"); |
#endif |
TIMESPEC_ASSIGN(&temp, &proc_table[p].request_time); |
ADDUSEC2TIMESPEC(lev->period[p], &temp); |
ADDUSEC2TIMESPEC(lev->period[p], t); |
*iq_query_timespec(p, &lev->ready) = temp; |
lev->deadline_timespec[p] = temp; |
*iq_query_timespec(p, &lev->ready) = *t; |
lev->deadline_timespec[p] = *t; |
/* Insert task in the correct position */ |
proc_table[p].status = EDFSTAR_READY; |
174,18 → 172,6 |
EDFSTAR_check_preemption(lev); |
} |
static char *EDFSTAR_status_to_a(WORD status) |
{ |
if (status < MODULE_STATUS_BASE) |
return status_to_a(status); |
switch (status) { |
case EDFSTAR_READY : return "EDFSTAR_Ready"; |
case EDFSTAR_IDLE : return "EDFSTAR_Idle"; |
default : return "EDFSTAR_Unknown"; |
} |
} |
static void EDFSTAR_timer_deadline(void *par) |
{ |
PID p = (PID) par; |
203,10 → 189,8 |
// edfstar_printf2("I%d",p); |
#endif |
/* set the request time */ |
proc_table[p].request_time = *iq_query_timespec(p, &lev->ready); |
EDFSTAR_internal_activate(lev,p,iq_query_timespec(p, &lev->ready)); |
EDFSTAR_internal_activate(lev,p); |
event_need_reschedule(); |
break; |
245,104 → 229,21 |
kern_raise(XDEADLINE_MISS,p); |
} |
static int EDFSTAR_level_accept_task_model(LEVEL l, TASK_MODEL *m) |
static int EDFSTAR_public_create(LEVEL l, PID p, TASK_MODEL *m) |
{ |
#ifdef EDFSTAR_DEBUG |
edfstar_printf("(E:lacct)"); |
#endif |
if (m->pclass == HARD_PCLASS || m->pclass == (HARD_PCLASS | l)) { |
HARD_TASK_MODEL *h = (HARD_TASK_MODEL *)m; |
if (h->wcet && h->mit && h->periodicity == PERIODIC) |
return 0; |
} |
return -1; |
} |
static int EDFSTAR_level_accept_guest_model(LEVEL l, TASK_MODEL *m) |
{ |
#ifdef EDFSTAR_DEBUG |
edfstar_printf("(E:laccg)"); |
#endif |
if (m->pclass == JOB_PCLASS || m->pclass == (JOB_PCLASS | l)) |
return 0; |
else |
return -1; |
} |
static char *onoff(int i) |
{ |
if (i) |
return "On "; |
else |
return "Off"; |
} |
static void EDFSTAR_level_status(LEVEL l) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
PID p = iq_query_first(&lev->ready); |
struct timespec temp; |
kern_printf("Budget number : %u\n", lev->budget); |
kern_printf("Master level : %u\n", lev->scheduling_level); |
kern_printf("Active PID : %u\n", lev->activated); |
while (p != NIL) { |
if ((proc_table[p].pclass) == JOB_PCLASS) |
kern_printf("Pid: %2d (GUEST)\n", p); |
else { |
temp = *iq_query_timespec(p, &lev->ready); |
kern_printf("Pid: %2d Name: %10s %s: %9ld Dline: %9ld.%6ld Stat: %s\n", |
p, |
proc_table[p].name, |
"Period ", |
lev->period[p], |
temp.tv_sec, |
temp.tv_nsec/1000, |
EDFSTAR_status_to_a(proc_table[p].status)); |
p = iq_query_next(p, &lev->ready); |
} |
} |
for (p=0; p<MAX_PROC; p++) |
if (proc_table[p].task_level == l |
&& proc_table[p].status != EDFSTAR_READY |
&& proc_table[p].status != FREE ) { |
temp = *iq_query_timespec(p, &lev->ready); |
kern_printf("Pid: %2d Name: %10s %s: %9ld Dline: %9ld.%6ld Stat: %s\n", |
p, |
proc_table[p].name, |
"Period ", |
lev->period[p], |
temp.tv_sec, |
temp.tv_nsec/1000, |
EDFSTAR_status_to_a(proc_table[p].status)); |
} |
} |
/* The scheduler only gets the first task in the queue */ |
static PID EDFSTAR_level_scheduler(LEVEL l) |
{ |
//EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
/* if the EDFSTAR_task_create is called, then the pclass must be a |
valid pclass. */ |
HARD_TASK_MODEL *h; |
return NIL; |
} |
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 */ |
static int EDFSTAR_task_create(LEVEL l, PID p, TASK_MODEL *m) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
/* if the EDFSTAR_task_create is called, then the pclass must be a |
valid pclass. */ |
HARD_TASK_MODEL *h = (HARD_TASK_MODEL *)m; |
#ifdef EDFSTAR_DEBUG |
edfstar_printf("(E:tcr)"); |
#endif |
363,23 → 264,19 |
return 0; /* OK, also if the task cannot be guaranteed... */ |
} |
static void EDFSTAR_task_detach(LEVEL l, PID p) |
static int EDFSTAR_task_eligible(LEVEL l, PID p) |
{ |
#ifdef EDFSTAR_DEBUG |
edfstar_printf2("(E:tdt)"); |
#endif |
} |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
static int EDFSTAR_task_eligible(LEVEL l, PID p) |
{ |
#ifdef EDFSTAR_DEBUG |
edfstar_printf2("(E:eli)"); |
#endif |
return 0; /* if the task p is chosen, it is always eligible */ |
return level_table[ lev->scheduling_level ]-> |
private_eligible(lev->scheduling_level,p); |
} |
static void EDFSTAR_task_dispatch(LEVEL l, PID p, int nostop) |
static void EDFSTAR_public_dispatch(LEVEL l, PID p, int nostop) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
392,10 → 289,10 |
#endif |
level_table[ lev->scheduling_level ]-> |
guest_dispatch(lev->scheduling_level,p,nostop); |
private_dispatch(lev->scheduling_level,p,nostop); |
} |
static void EDFSTAR_task_epilogue(LEVEL l, PID p) |
static void EDFSTAR_public_epilogue(LEVEL l, PID p) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
417,14 → 314,15 |
#endif |
level_table[ lev->scheduling_level ]-> |
guest_epilogue(lev->scheduling_level,p); |
private_epilogue(lev->scheduling_level,p); |
proc_table[p].status = EDFSTAR_READY; |
} |
static void EDFSTAR_task_activate(LEVEL l, PID p) |
static void EDFSTAR_public_activate(LEVEL l, PID p) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
struct timespec t; |
#ifdef EDFSTAR_DEBUG |
edfstar_printf("(E:act)"); |
438,9 → 336,9 |
return; |
} |
ll_gettime(TIME_EXACT, &proc_table[p].request_time); |
kern_gettime(&t); |
EDFSTAR_internal_activate(lev,p); |
EDFSTAR_internal_activate(lev,p, &t); |
/* Set the deadline timer */ |
lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p], |
449,7 → 347,7 |
} |
static void EDFSTAR_task_insert(LEVEL l, PID p) |
static void EDFSTAR_public_unblock(LEVEL l, PID p) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
465,7 → 363,7 |
EDFSTAR_check_preemption(lev); |
} |
static void EDFSTAR_task_extract(LEVEL l, PID p) |
static void EDFSTAR_public_block(LEVEL l, PID p) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
481,7 → 379,7 |
EDFSTAR_check_preemption(lev); |
} |
static void EDFSTAR_task_endcycle(LEVEL l, PID p) |
static int EDFSTAR_public_message(LEVEL l, PID p, void *m) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
struct timespec temp; |
493,7 → 391,7 |
/* we call guest_end directly here because the same task may |
be reinserted in the queue before calling the preemption check! */ |
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level,p); |
private_extract(lev->scheduling_level,p); |
lev->activated = NIL; |
iq_extract(p,&lev->ready); |
510,9 → 408,9 |
lev->nact[p]--; |
/* see also EDFSTAR_timer_deadline */ |
ll_gettime(TIME_EXACT, &proc_table[p].request_time); |
kern_gettime(&temp); |
EDFSTAR_internal_activate(lev,p); |
EDFSTAR_internal_activate(lev,p, &temp); |
/* check if the deadline has already expired */ |
temp = *iq_query_timespec(p, &lev->ready); |
519,7 → 417,7 |
if (TIMESPEC_A_LT_B(&temp, &schedule_time)) { |
/* count the deadline miss */ |
lev->dline_miss[p]++; |
event_delete(lev->deadline_timer[p]); |
kern_event_delete(lev->deadline_timer[p]); |
} |
} |
535,14 → 433,19 |
EDFSTAR_check_preemption(lev); |
/* when the deadline timer fire, it recognize the situation and set |
correctly all the stuffs (like reactivation, request_time, etc... ) */ |
correctly all the stuffs (like reactivation, etc... ) */ |
} |
#ifdef EDFSTAR_DEBUG |
edfstar_printf(")"); |
#endif |
jet_update_endcycle(); /* Update the Jet data... */ |
trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */ |
return 0; |
} |
static void EDFSTAR_task_end(LEVEL l, PID p) |
static void EDFSTAR_public_end(LEVEL l, PID p) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
558,7 → 461,7 |
iq_insertfirst(p,&freedesc); |
if (lev->deadline_timer[p] != -1) { |
event_delete(lev->deadline_timer[p]); |
kern_event_delete(lev->deadline_timer[p]); |
} |
/* and finally, a preemption check! (it will also call guest_end) */ |
565,18 → 468,22 |
EDFSTAR_check_preemption(lev); |
} |
static void EDFSTAR_task_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_TASK,exec_shadow); } |
/* Guest Functions |
These functions manages a JOB_TASK_MODEL, that is used to put |
a guest task in the EDFSTAR ready queue. */ |
static int EDFSTAR_guest_create(LEVEL l, PID p, TASK_MODEL *m) |
static void EDFSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
JOB_TASK_MODEL *job = (JOB_TASK_MODEL *)m; |
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; |
/* if the EDFSTAR_guest_create is called, then the pclass must be a |
valid pclass. */ |
589,47 → 496,15 |
if (job->noraiseexc) |
lev->flag[p] = EDFSTAR_FLAG_NORAISEEXC; |
else |
else { |
lev->flag[p] = 0; |
lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready), |
EDFSTAR_timer_guest_deadline, |
(void *)p); |
} |
lev->period[p] = job->period; |
/* there is no bandwidth guarantee at this level, it is performed |
by the level that inserts guest tasks... */ |
return 0; /* OK, also if the task cannot be guaranteed... */ |
} |
static void EDFSTAR_guest_detach(LEVEL l, PID p) |
{ |
/* the EDFSTAR level doesn't introduce any dinamic allocated new field. |
No guarantee is performed on guest tasks... so we don't have to reset |
the NO_GUARANTEE FIELD */ |
} |
static void EDFSTAR_guest_dispatch(LEVEL l, PID p, int nostop) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
level_table[ lev->scheduling_level ]-> |
guest_dispatch(lev->scheduling_level,p,nostop); |
} |
static void EDFSTAR_guest_epilogue(LEVEL l, PID p) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
/* the task has been preempted. it returns into the ready queue... */ |
level_table[ lev->scheduling_level ]-> |
guest_epilogue(lev->scheduling_level,p); |
proc_table[p].status = EDFSTAR_READY; |
} |
static void EDFSTAR_guest_activate(LEVEL l, PID p) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
/* Insert task in the correct position */ |
iq_timespec_insert(p,&lev->ready); |
proc_table[p].status = EDFSTAR_READY; |
637,39 → 512,30 |
/* check for preemption */ |
EDFSTAR_check_preemption(lev); |
/* Set the deadline timer */ |
if (!(lev->flag[p] & EDFSTAR_FLAG_NORAISEEXC)) |
lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready), |
EDFSTAR_timer_guest_deadline, |
(void *)p); |
/* there is no bandwidth guarantee at this level, it is performed |
by the level that inserts guest tasks... */ |
} |
static void EDFSTAR_guest_insert(LEVEL l, PID p) |
static void EDFSTAR_private_dispatch(LEVEL l, PID p, int nostop) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
/* Insert task in the correct position */ |
iq_timespec_insert(p,&lev->ready); |
proc_table[p].status = EDFSTAR_READY; |
/* and check for preemption! */ |
EDFSTAR_check_preemption(lev); |
level_table[ lev->scheduling_level ]-> |
private_dispatch(lev->scheduling_level,p,nostop); |
} |
static void EDFSTAR_guest_extract(LEVEL l, PID p) |
static void EDFSTAR_private_epilogue(LEVEL l, PID p) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
/* the task is blocked on a synchronization primitive. we have to |
remove it from the master module -and- from the local queue! */ |
iq_extract(p,&lev->ready); |
/* the task has been preempted. it returns into the ready queue... */ |
level_table[ lev->scheduling_level ]-> |
private_epilogue(lev->scheduling_level,p); |
/* and finally, a preemption check! (it will also call guest_end() */ |
EDFSTAR_check_preemption(lev); |
proc_table[p].status = EDFSTAR_READY; |
} |
static void EDFSTAR_guest_end(LEVEL l, PID p) |
static void EDFSTAR_private_extract(LEVEL l, PID p) |
{ |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
684,7 → 550,7 |
#ifdef EDFSTAR_DEBUG |
// kern_printf("EDFSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]); |
#endif |
event_delete(lev->deadline_timer[p]); |
kern_event_delete(lev->deadline_timer[p]); |
lev->deadline_timer[p] = NIL; |
} |
692,12 → 558,6 |
EDFSTAR_check_preemption(lev); |
} |
static void EDFSTAR_guest_endcycle(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
static void EDFSTAR_guest_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
/* Registration functions */ |
/* Registration function: |
713,55 → 573,28 |
#endif |
/* request an entry in the level_table */ |
l = level_alloc_descriptor(); |
l = level_alloc_descriptor(sizeof(EDFSTAR_level_des)); |
#ifdef EDFSTAR_DEBUG |
printk(" alloco descrittore %d %d\n",l,(int)sizeof(EDFSTAR_level_des)); |
#endif |
lev = (EDFSTAR_level_des *)level_table[l]; |
/* alloc the space needed for the EDFSTAR_level_des */ |
lev = (EDFSTAR_level_des *)kern_alloc(sizeof(EDFSTAR_level_des)); |
#ifdef EDFSTAR_DEBUG |
printk(" lev=%d\n",(int)lev); |
#endif |
/* update the level_table with the new entry */ |
level_table[l] = (level_des *)lev; |
/* fill the standard descriptor */ |
strncpy(lev->l.level_name, EDFSTAR_LEVELNAME, MAX_LEVELNAME); |
lev->l.level_code = EDFSTAR_LEVEL_CODE; |
lev->l.level_version = EDFSTAR_LEVEL_VERSION; |
lev->l.private_insert = EDFSTAR_private_insert; |
lev->l.private_extract = EDFSTAR_private_extract; |
lev->l.private_dispatch = EDFSTAR_private_dispatch; |
lev->l.private_epilogue = EDFSTAR_private_epilogue; |
lev->l.level_accept_task_model = EDFSTAR_level_accept_task_model; |
lev->l.level_accept_guest_model = EDFSTAR_level_accept_guest_model; |
lev->l.level_status = EDFSTAR_level_status; |
lev->l.level_scheduler = EDFSTAR_level_scheduler; |
lev->l.level_guarantee = NULL; |
lev->l.task_create = EDFSTAR_task_create; |
lev->l.task_detach = EDFSTAR_task_detach; |
lev->l.task_eligible = EDFSTAR_task_eligible; |
lev->l.task_dispatch = EDFSTAR_task_dispatch; |
lev->l.task_epilogue = EDFSTAR_task_epilogue; |
lev->l.task_activate = EDFSTAR_task_activate; |
lev->l.task_insert = EDFSTAR_task_insert; |
lev->l.task_extract = EDFSTAR_task_extract; |
lev->l.task_endcycle = EDFSTAR_task_endcycle; |
lev->l.task_end = EDFSTAR_task_end; |
lev->l.task_sleep = EDFSTAR_task_sleep; |
lev->l.public_guarantee = NULL; |
lev->l.public_create = EDFSTAR_public_create; |
lev->l.public_end = EDFSTAR_public_end; |
lev->l.public_dispatch = EDFSTAR_public_dispatch; |
lev->l.public_epilogue = EDFSTAR_public_epilogue; |
lev->l.public_activate = EDFSTAR_public_activate; |
lev->l.public_unblock = EDFSTAR_public_unblock; |
lev->l.public_block = EDFSTAR_public_block; |
lev->l.public_message = EDFSTAR_public_message; |
lev->l.guest_create = EDFSTAR_guest_create; |
lev->l.guest_detach = EDFSTAR_guest_detach; |
lev->l.guest_dispatch = EDFSTAR_guest_dispatch; |
lev->l.guest_epilogue = EDFSTAR_guest_epilogue; |
lev->l.guest_activate = EDFSTAR_guest_activate; |
lev->l.guest_insert = EDFSTAR_guest_insert; |
lev->l.guest_extract = EDFSTAR_guest_extract; |
lev->l.guest_endcycle = EDFSTAR_guest_endcycle; |
lev->l.guest_end = EDFSTAR_guest_end; |
lev->l.guest_sleep = EDFSTAR_guest_sleep; |
/* fill the EDFSTAR descriptor part */ |
for(i=0; i<MAX_PROC; i++) { |
lev->period[i] = 0; |
785,11 → 618,8 |
{ |
LEVEL l = proc_table[p].task_level; |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == EDFSTAR_LEVEL_CODE && |
lev->l.level_version == EDFSTAR_LEVEL_VERSION) |
return lev->dline_miss[p]; |
else |
return -1; |
return lev->dline_miss[p]; |
} |
int EDFSTAR_get_wcet_miss(PID p) |
796,11 → 626,8 |
{ |
LEVEL l = proc_table[p].task_level; |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == EDFSTAR_LEVEL_CODE && |
lev->l.level_version == EDFSTAR_LEVEL_VERSION) |
return lev->wcet_miss[p]; |
else |
return -1; |
return lev->wcet_miss[p]; |
} |
int EDFSTAR_get_nact(PID p) |
807,11 → 634,8 |
{ |
LEVEL l = proc_table[p].task_level; |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == EDFSTAR_LEVEL_CODE && |
lev->l.level_version == EDFSTAR_LEVEL_VERSION) |
return lev->nact[p]; |
else |
return -1; |
return lev->nact[p]; |
} |
int EDFSTAR_reset_dline_miss(PID p) |
818,14 → 642,9 |
{ |
LEVEL l = proc_table[p].task_level; |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == EDFSTAR_LEVEL_CODE && |
lev->l.level_version == EDFSTAR_LEVEL_VERSION) |
{ |
lev->dline_miss[p] = 0; |
return 0; |
} |
else |
return -1; |
lev->dline_miss[p] = 0; |
return 0; |
} |
int EDFSTAR_reset_wcet_miss(PID p) |
832,13 → 651,8 |
{ |
LEVEL l = proc_table[p].task_level; |
EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]); |
if (lev->l.level_code == EDFSTAR_LEVEL_CODE && |
lev->l.level_version == EDFSTAR_LEVEL_VERSION) |
{ |
lev->wcet_miss[p] = 0; |
return 0; |
} |
else |
return -1; |
lev->wcet_miss[p] = 0; |
return 0; |
} |
/demos/trunk/first/edfstar.h |
---|
20,11 → 20,11 |
/** |
------------ |
CVS : $Id: edfstar.h,v 1.1 2002-09-02 10:29:30 pj Exp $ |
CVS : $Id: edfstar.h,v 1.2 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2002-09-02 10:29:30 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
Title: |
102,7 → 102,6 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include <modules/codes.h> |