Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1179 → Rev 1180

/demos/trunk/first/cbsstar.c
20,11 → 20,11
 
/*
------------
CVS : $Id: cbsstar.c,v 1.5 2003-06-18 08:13:01 trimarchi Exp $
CVS : $Id: cbsstar.c,v 1.6 2003-08-01 13:20:38 trimarchi Exp $
 
File: $File$
Revision: $Revision: 1.5 $
Last update: $Date: 2003-06-18 08:13:01 $
Revision: $Revision: 1.6 $
Last update: $Date: 2003-08-01 13:20:38 $
------------
 
Read CBSSTAR.h for general details.
70,13 → 70,20
#include "cbsstar.h"
#include <ll/string.h>
 
#define ACTIVE 1
#define NOACTIVE 0
#define INIT 2
 
#define CBSSTAR_IDLE APER_STATUS_BASE
/*
* DEBUG stuffs begin
*/
 
#ifdef CBSSTAR_DEBUG_OLD
//#define CBSSTAR_DEBUG
int event_monitor;
#ifdef CBSSTAR_DEBUG
 
 
static __inline__ void fake_printf(char *fmt, ...) {}
 
//#define cbsstar_printf kern_printf
87,8 → 94,8
#define cbsstar_printf2 fake_printf
#define cbsstar_printf3 fake_printf
 
#if 0
void cbsstar_printq(IQUEUE *q)
#if 0
void cbsstar_printq(QQUEUE *q)
{
PID p;
kern_printf("[");
104,7 → 111,7
static __inline__ void cbsstar_printq(QQUEUE *q) {}
#endif
 
#if 0
#if 0
static __inline__ void cbsstar_printblob(int x) { if (x) cputc('±'); else cputc('Û'); }
#else
static __inline__ void cbsstar_printblob(int x) {}
115,19 → 122,22
/*
* DEBUG stuffs end
*/
/*+ Status used in the level +*/
#define CBSSTAR_WAIT APER_STATUS_BASE /*+ waiting the service +*/
 
 
/* this structure contains the status for a single budget */
struct budget_struct {
TIME Q; /* budget */
TIME T; /* period */
 
struct timespec dline; /* deadline */
int dline_timer; /* oslib event for budget reactivation*/
int avail; /* current budget */
 
PID current; /* the task currently put in execution */
 
int flags;
IQUEUE tasks; /* a FIFO queue for the tasks handled
using the budget */
};
142,14 → 152,80
int tb[MAX_PROC]; /* link task->budget (used in guest_end) */
 
bandwidth_t U; /*+ the used bandwidth by the server +*/
 
int cap_lev;
 
PID on_shadow;
 
LEVEL scheduling_level;
 
} CBSSTAR_level_des;
 
 
static void CBSSTAR_deadline_timer_hardreservation(void *a)
{
struct budget_struct *b = a;
struct timespec t;
//kern_printf("*********** %d", b->dline_timer);
b->dline_timer=NIL;
/* we modify the deadline according to rule 4 ... */
/* there is a while because if the wcet is << than the system tick
we need to postpone the deadline many times */
if (b->avail<=0) {
b->avail += b->Q;
if (b->avail>b->Q) b->avail=b->Q;
 
//kern_printf("budget recharge %d", b);
}
if (b->avail>0) b->flags=ACTIVE;
/* avail may be <0 because a task executed via a shadow fo many time
b->current == NIL only if the prec task was finished and there
was not any other task to be put in the ready queue
... we are now activating the next task */
if (b->current == NIL && b->flags) {
if (iq_query_first(&(b->tasks)) != NIL) {
//struct timespec t;
CBSSTAR_level_des *lev;
PID p;
JOB_TASK_MODEL job;
//kern_gettime(&t);
//TIMESPEC_ASSIGN(&b->dline, &schedule_time);
//ADDUSEC2TIMESPEC(b->T, &b->dline);
kern_gettime(&t);
TIMESPEC_ASSIGN(&b->dline, &t);
ADDUSEC2TIMESPEC(b->T, &b->dline);
 
p = iq_getfirst(&(b->tasks));
b->current=p;
lev = (CBSSTAR_level_des *)(level_table[proc_table[p].task_level]);
//kern_printf("reinsert task p = %d lev = %d ",p,proc_table[p].task_level);
/* and, finally, we reinsert the task in the master level */
job_task_default_model(job, b->dline);
job_task_def_noexc(job);
//kern_printf("(CR:iact p%d %ld.%ld av=%d)",p,b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail);
//kern_printf("**");
level_table[ lev->scheduling_level ]->
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job);
event_need_reschedule();
}
} else
if (b->current !=NIL && b->avail>0) {
kern_printf("(cap&nil ");
}
if (b->flags==NOACTIVE && b->dline_timer!=NIL){
kern_gettime(&t);
TIMESPEC_ASSIGN(&b->dline, &t);
ADDUSEC2TIMESPEC(b->T, &b->dline);
b->dline_timer=kern_event_post(&b->dline, CBSSTAR_deadline_timer_hardreservation, b);
event_monitor=b->dline_timer;
//kern_printf("(dline hard %ld.%ld ev %d)",b->dline.tv_sec,b->dline.tv_nsec/1000, b->dline_timer);
}
}
static void CBSSTAR_activation(CBSSTAR_level_des *lev,
PID p,
struct timespec *acttime)
156,7 → 232,6
{
JOB_TASK_MODEL job;
struct budget_struct *b = &lev->b[lev->tb[p]];
 
/* we have to check if the deadline and the wcet are correct before
activating a new task or an old task... */
 
172,22 → 247,17
t3.tv_nsec = (t % 1000000) * 1000;
 
SUBTIMESPEC(&b->dline, acttime, &t2);
 
if (/* 1 */ TIMESPEC_A_LT_B(&b->dline, acttime) ||
/* 2 */ TIMESPEC_A_GT_B(&t3, &t2) ) {
/* if (TIMESPEC_A_LT_B(&lev->cbs_dline[p], acttime) )
kern_printf("$");
else
kern_printf("(Ûdline%d.%d act%d.%d wcet%d per%d avail%dÛ)",
lev->cbs_dline[p].tv_sec,lev->cbs_dline[p].tv_nsec/1000,
acttime->tv_sec, acttime->tv_nsec/1000,
proc_table[p].wcet, lev->period[p], proc_table[p].avail_time);
*/ /* we modify the deadline ... */
TIMESPEC_ASSIGN(&b->dline, acttime);
ADDUSEC2TIMESPEC(b->T, &b->dline);
/* and the capacity */
}
/* and the capacity */
if (b->flags==INIT) {
b->avail = b->Q;
b->flags=ACTIVE;
}
 
 
#ifdef CBSSTAR_DEBUG
194,28 → 264,43
cbsstar_printf3("±%d±",lev->tb[p]);
cbsstar_printblob(lev->tb[p]);
#endif
}
//}
//#endif
 
/* record the current task inserted in the master module */
b->current = p;
 
#ifdef CBSSTAR_DEBUG
cbsstar_printf("(C:iact p%d %ld.%ld av=%d)",p,b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail);
#endif
//kern_printf("Pid %d, Act %d, Dd %d", p,acttime->tv_nsec/1000,(b->dline).tv_nsec/1000);
//#ifdef CBSSTAR_DEBUG
//kern_printf("(CA:iact p%d %ld.%ld av=%d at=%ld.%ld)",p,b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail, acttime->tv_sec, acttime->tv_nsec/1000);
//#endif
/* and, finally, we reinsert the task in the master level */
job_task_default_model(job, b->dline);
job_task_def_noexc(job);
level_table[ lev->scheduling_level ]->
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job);
//b->dline_timer=kern_event_post(&b->dline, CBSSTAR_deadline_timer_hardreservation, b);
}
 
 
static void CBSSTAR_account_capacity(CBSSTAR_level_des *lev, PID p)
{
struct timespec ty;
TIME tx;
struct budget_struct *b = &lev->b[lev->tb[p]];
TIME t;
struct timespec t2,t3, acttime;
 
if (lev->cap_lev!=NIL && b->current==p) {
kern_event_delete(lev->cap_lev);
lev->cap_lev=NIL;
}
 
kern_gettime(&acttime);
t = (b->T * b->avail) / b->Q;
t3.tv_sec = t / 1000000;
t3.tv_nsec = (t % 1000000) * 1000;
 
SUBTIMESPEC(&b->dline, &acttime, &t2);
SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty);
tx = TIMESPEC2USEC(&ty);
lev->b[lev->tb[p]].avail -= tx;
223,6 → 308,25
#ifdef CBSSTAR_DEBUG
cbsstar_printf2("(C:cap p%d av=%d)", p, lev->b[lev->tb[p]].avail);
#endif
if (lev->b[lev->tb[p]].avail<=0 || TIMESPEC_A_GT_B(&t3, &t2)) lev->b[lev->tb[p]].flags=NOACTIVE;
 
if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time) ) {
/* we modify the deadline ... */
TIMESPEC_ASSIGN(&b->dline, &schedule_time);
ADDUSEC2TIMESPEC(b->T, &b->dline);
}
 
//if (b->flags==NOACTIVE && b->dline_timer!=NIL)
// kern_printf("flags %d, dline_timer %d", b->flags, b->dline_timer);
if (b->flags==NOACTIVE && b->dline_timer==NIL) {
b->dline_timer=kern_event_post(&b->dline, CBSSTAR_deadline_timer_hardreservation, b);
event_monitor=b->dline_timer;
//kern_printf("(dline %ld.%ld ev %d)",b->dline.tv_sec,b->dline.tv_nsec/1000, b->dline_timer);
}
 
}
 
 
243,6 → 347,15
return 0;
}
 
static void capacity_handler(void *l)
{
//kern_printf("!");
CBSSTAR_level_des *lev =l;
lev->cap_lev=NIL;
event_need_reschedule();
}
 
static int CBSSTAR_private_eligible(LEVEL l, PID p)
{
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
250,7 → 363,7
JOB_TASK_MODEL job;
 
#ifdef CBSSTAR_DEBUG
cbsstar_printf("(C:eli %d",p);
//kern_printf("(C:eli %d",p);
#endif
 
/* we have to check if the deadline and the wcet are correct...
259,32 → 372,45
schedule_time > CBSSTAR_deadline; in this case (not covered in the
article because if there is only the standard scheduling policy
this never apply) we reassign the deadline */
 
if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time) ) {
if (b->current==p) {
if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time)) {
if (lev->cap_lev!=NIL) {
kern_event_delete(lev->cap_lev);
lev->cap_lev=NIL;
}
/* we kill the current activation */
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level, p);
 
/* we modify the deadline ... */
/* we modify the deadline ... */
TIMESPEC_ASSIGN(&b->dline, &schedule_time);
ADDUSEC2TIMESPEC(b->T, &b->dline);
 
/* and the capacity */
b->avail = b->Q;
b->flags=ACTIVE;
 
#ifdef CBSSTAR_DEBUG
cbsstar_printf2(" %ld.%ld av=%d)",b->dline.tv_sec,b->dline.tv_nsec/1000, b->Q);
cbsstar_printf3("±%d±",lev->tb[p]);
cbsstar_printblob(lev->tb[p]);
#endif
if (b->dline_timer!=NIL) {
kern_event_delete(b->dline_timer);
b->dline_timer=NIL;
}
//#ifdef CBSSTAR_DEBUG
//kern_printf(" %ld.%ld av=%d)",b->dline.tv_sec,b->dline.tv_nsec/1000, b->Q);
//cbsstar_printf3("±%d±",lev->tb[p]);
//cbsstar_printblob(lev->tb[p]);
//#endif
 
/* and, finally, we reinsert the task in the master level */
job_task_default_model(job, b->dline);
job_task_def_noexc(job);
//kern_printf("(CE:iact p%d %ld.%ld av=%d)",p,b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail);
level_table[ lev->scheduling_level ]->
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job);
 
//kern_printf("task %d, avail %d", p, b->avail);
return -1;
}
}
}
#ifdef CBSSTAR_DEBUG
cbsstar_printf(")");
#endif
292,7 → 418,6
return 0;
}
 
 
static void CBSSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m)
{
/* A task has been activated for some reason. Basically, the task is
315,7 → 440,7
 
lev->tb[p] = budget->b;
 
if (lev->b[budget->b].current == NIL) {
if (lev->b[budget->b].current == NIL && lev->b[budget->b].flags ) {
/* This is the first task in the budget,
the task have to be inserted into the master module */
struct timespec t;
326,10 → 451,10
master module, so the task is inserted at the end of the budget
queue */
iq_insertlast(p,&lev->b[budget->b].tasks);
#ifdef CBSSTAR_DEBUG
cbsstar_printf(" ilast");
cbsstar_printq(&lev->b[budget->b].tasks);
#endif
//#ifdef CBSSTAR_DEBUG
//kern_printf(" ilast flag %d task %d",lev->b[budget->b].flags,lev->b[budget->b].current);
// cbsstar_printq(&lev->b[budget->b].tasks);
//#endif
}
#ifdef CBSSTAR_DEBUG
cbsstar_printf(")");
340,18 → 465,19
{
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
 
#ifdef CBSSTAR_DEBUG
cbsstar_printf("(C:gend p%d c%d av=%d)", p, lev->b[lev->tb[p]].current, lev->b[lev->tb[p]].avail);
cbsstar_printq(&lev->b[lev->tb[p]].tasks);
#endif
//#ifdef CBSSTAR_DEBUG
//kern_printf("(C:gend p%d c%d av=%d)", p, lev->b[lev->tb[p]].current, lev->b[lev->tb[p]].avail);
//cbsstar_printq(&lev->b[lev->tb[p]].tasks);
//#endif
 
/* a task is removed from execution for some reasons. It must be
that it is the first in its budget queue (only the first task in
a budget queue is put into execution!) */
CBSSTAR_account_capacity(lev,p);
 
/* remove the task from execution (or from the ready queue) */
if (lev->b[lev->tb[p]].current == p) {
 
CBSSTAR_account_capacity(lev,p);
/* remove the task from the master module */
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level, p);
365,7 → 491,7
/* the buffer has no tasks! */
lev->b[lev->tb[p]].current = NIL;
}
else {
else if (lev->b[lev->tb[p]].flags) {
/* if so, insert the new task into the master module */
PID n;
struct timespec t;
372,33 → 498,29
kern_gettime(&t);
n = iq_getfirst(&lev->b[lev->tb[p]].tasks);
#ifdef CBSSTAR_DEBUG
cbsstar_printf("{p%d n%d}",p,n);
#endif
//#ifdef CBSSTAR_DEBUG
//kern_printf("{p%d n%d}",p,n);
//#endif
CBSSTAR_activation(lev,n,&t); // it modifies b[lev->tb[p]].current
}
else
lev->b[lev->tb[p]].current=NIL;
 
}
else
else {
iq_extract(p, &lev->b[lev->tb[p]].tasks);
}
}
 
static void capacity_handler()
{
//kern_printf("!");
event_need_reschedule();
}
 
 
static void CBSSTAR_private_dispatch(LEVEL l, PID p, int nostop)
{
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
struct timespec ty;
 
#ifdef CBSSTAR_DEBUG
cbsstar_printf("(C:gdisp p%d c%d av=%d)", p, lev->b[lev->tb[p]].current, lev->b[lev->tb[p]].avail);
cbsstar_printq(&lev->b[lev->tb[p]].tasks);
#endif
//#ifdef CBSSTAR_DEBUG
//kern_printf("(C:gdisp p%d c%d av=%d)", p, lev->b[lev->tb[p]].current, lev->b[lev->tb[p]].avail);
// cbsstar_printq(&lev->b[lev->tb[p]].tasks);
//#endif
 
/* the current task (that is the only one inserted in the master module
for the corresponding budget) is dispatched. Note that the current
413,8 → 535,9
if (!nostop) {
TIMESPEC_ASSIGN(&ty, &schedule_time);
ADDUSEC2TIMESPEC(lev->b[lev->tb[p]].avail,&ty);
lev->cap_lev = kern_event_post(&ty, capacity_handler, NULL);
lev->cap_lev = kern_event_post(&ty,capacity_handler, lev);
}
}
 
static void CBSSTAR_private_epilogue(LEVEL l, PID p)
422,65 → 545,47
CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
struct budget_struct *b = &lev->b[lev->tb[p]];
 
#ifdef CBSSTAR_DEBUG
cbsstar_printf("(C:gepi %d",p);
#endif
 
CBSSTAR_account_capacity(lev,p);
//#ifdef CBSSTAR_DEBUG
//kern_printf("(C:gepi %d %d",p, b->current);
//#endif
 
if (lev->cap_lev!=NIL)
kern_event_delete(lev->cap_lev);
lev->cap_lev=NIL;
if (p==b->current) {
CBSSTAR_account_capacity(lev,p);
 
/* we have to check if the capacity is still available */
if (b->avail > 0) {
/* there is capacity available, maybe it is simply a preemption;
the task have to return to the ready queue */
level_table[ lev->scheduling_level ]->
private_epilogue(lev->scheduling_level,p);
#ifdef CBSSTAR_DEBUG
cbsstar_printf(" *av=%d", b->avail);
#endif
} else {
 
/* The capacity is exausted; the deadline have to be postponed and
the task have to be reinserted in the master module */
JOB_TASK_MODEL job;
 
/* we kill the current activation */
level_table[ lev->scheduling_level ]->
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
we need to postpone the deadline many times */
while (b->avail <= 0) {
ADDUSEC2TIMESPEC(b->T, &b->dline);
b->avail += b->Q;
#ifdef CBSSTAR_DEBUG
cbsstar_printf("±%d±",b->avail);
#endif
// L'evento di capacità va cancellato perchè sarà ripristinato nella successiva dispatch
/* we have to check if the capacity is still available */
if (b->flags) {
/* there is capacity available, maybe it is simply a preemption;
the task have to return to the ready queue */
level_table[ lev->scheduling_level ]->
private_epilogue(lev->scheduling_level,p);
#ifdef CBSSTAR_DEBUG
//kern_printf("(ep *av=%d", b->avail);
#endif
} else {
/* we kill the current activation */
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level, p);
//kern_printf("extract");
iq_insertfirst(p, &b->tasks);
proc_table[p].status = CBSSTAR_IDLE;
b->current = NIL;
//kern_printf("budget finish %d", b);
}
 
#ifdef CBSSTAR_DEBUG
kern_printf(" %ld.%ld av=%d",b->dline.tv_sec,b->dline.tv_nsec/1000, b->avail);
#endif
/* and, finally, we reinsert the task in the master level */
job_task_default_model(job, b->dline);
job_task_def_noexc(job);
level_table[ lev->scheduling_level ]->
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job);
}
#ifdef CBSSTAR_DEBUG
cbsstar_printf(")");
cbsstar_printf(")");
#endif
}
 
}
 
/* Registration functions }*/
 
/* Registration functions */
 
/*+ Registration function:
int flags the init flags ... see CBSSTAR.h +*/
LEVEL CBSSTAR_register_level(int n, LEVEL master)
516,14 → 621,16
lev->b[i].Q = 0;
lev->b[i].T = 0;
NULL_TIMESPEC(&lev->b[i].dline);
lev->b[i].dline_timer = 0;
lev->b[i].dline_timer = NIL;
lev->b[i].avail = 0;
lev->b[i].current = -1;
lev->b[i].flags=INIT;
iq_init(&lev->b[i].tasks, &freedesc, 0);
}
 
lev->n = n;
lev->freebudgets = 0;
 
for (i=0; i<MAX_PROC; i++)
lev->tb[i] = NIL;
 
530,6 → 637,7
lev->U = 0;
lev->cap_lev=NIL;
lev->scheduling_level = master;
lev->on_shadow=NIL;
 
return l;
}
/demos/trunk/first/test7.c
18,11 → 18,11
 
/*
------------
CVS : $Id: test7.c,v 1.1 2003-06-18 08:16:00 trimarchi Exp $
CVS : $Id: test7.c,v 1.2 2003-08-01 13:20:38 trimarchi Exp $
 
File: $File$
Revision: $Revision: 1.1 $
Last update: $Date: 2003-06-18 08:16:00 $
Revision: $Revision: 1.2 $
Last update: $Date: 2003-08-01 13:20:38 $
------------
 
this test shows a set of 5 tasks (+main+dummy+keyboard driver).
70,8 → 70,8
#include "modules/cabs.h"
 
#include "modules/pi.h"
#include "modules/nop.h"
 
 
// --------------------------------------------------
// --------------------------------------------------
// Init Part
93,8 → 93,8
EDF_register_level(EDF_ENABLE_ALL);
 
cbsstar_level = CBSSTAR_register_level(3, 0);
mybudget = CBSSTAR_setbudget(cbsstar_level, 10000, 100000);
mybudget1 = CBSSTAR_setbudget(cbsstar_level, 10000, 70000);
mybudget = CBSSTAR_setbudget(cbsstar_level, 15000, 30000);
mybudget1 = CBSSTAR_setbudget(cbsstar_level, 14000, 56000);
posixstar_level = POSIXSTAR_register_level(mybudget, cbsstar_level, 3000,1);
posixstar_level1 = POSIXSTAR_register_level(mybudget1, cbsstar_level, 5000,1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
105,7 → 105,7
 
//SEM_register_module();
PI_register_module();
 
NOP_register_module();
return TICK;
}
 
159,10 → 159,10
for (i=0;i<5; i++) {
for (j=0; j<10; j++);
//sem_wait(&s);
mutex_lock(&s);
//mutex_lock(&s);
cputc('°');
cputs((char *)arg);
mutex_unlock(&s);
//mutex_unlock(&s);
//sem_post(&s);
}
 
183,7 → 183,7
nrt_task_default_model(m1);
nrt_task_def_group(m1, 1);
nrt_task_def_level(m1,2);
nrt_task_def_arg(m1,(void *)"#");
nrt_task_def_arg(m1,(void *)"A");
nrt_task_def_weight(m1,0);
p1a = task_create("a",star,&m1,NULL);
if (p1a == -1) {
191,49 → 191,95
sys_abort(-1);
}
nrt_task_def_level(m1,1);
nrt_task_def_arg(m1,(void *)"+");
nrt_task_def_arg(m1,(void *)"B");
nrt_task_def_group(m1, 1);
nrt_task_def_level(m1,2);
p1b = task_create("b", star, &m1, NULL);
p1b = task_create("b", star, &m1, NULL);
if (p1b == -1) {
perror("Could not create task b ...");
sys_end();
}
nrt_task_def_arg(m1,(void *)"1");
nrt_task_def_group(m1, 1);
nrt_task_def_level(m1,2);
 
p1c[5] = task_create("1", star, &m1, NULL);
if (p1c[5] == -1) {
perror("Could not create task b ...");
sys_end();
}
 
nrt_task_def_arg(m1,(void *)"Q");
nrt_task_def_arg(m1,(void *)"C");
nrt_task_def_group(m1, 1);
nrt_task_def_level(m1,3);
nrt_task_def_level(m1,2);
p1c[0] = task_create("c", star, &m1, NULL);
p1c[4] = task_create("c", star, &m1, NULL);
if (p1c[4] == -1) {
perror("Could not create task b ...");
sys_end();
}
 
nrt_task_def_arg(m1,(void *)"D");
nrt_task_def_group(m1, 1);
nrt_task_def_level(m1,2);
p1c[5] = task_create("d", star, &m1, NULL);
if (p1c[5] == -1) {
perror("Could not create task b ...");
sys_end();
}
nrt_task_def_arg(m1,(void *)"E");
nrt_task_def_group(m1, 1);
nrt_task_def_level(m1,2);
p1c[0] = task_create("e", star, &m1, NULL);
if (p1c[0] == -1) {
perror("Could not create task b ...");
sys_end();
}
 
nrt_task_def_arg(m1,(void *)"E");
p1c[1] = task_create("d", star, &m1, NULL);
nrt_task_def_arg(m1,(void *)"F");
p1c[1] = task_create("f", star, &m1, NULL);
if (p1c[1] == -1) {
perror("Could not create task b ...");
sys_end();
}
 
 
nrt_task_def_arg(m1,(void *)"R");
p1c[2] = task_create("e", star, &m1, NULL);
nrt_task_def_arg(m1,(void *)"G");
nrt_task_def_group(m1, 1);
nrt_task_def_level(m1,2);
p1c[2] = task_create("g", star, &m1, NULL);
if (p1c[2] == -1) {
perror("Could not create task b ...");
sys_end();
}
 
nrt_task_def_arg(m1,(void *)"H");
p1c[3] = task_create("h", star, &m1, NULL);
if (p1c[3] == -1) {
perror("Could not create task b ...");
sys_end();
}
nrt_task_def_arg(m1,(void *)"I");
p1c[4] = task_create("h", star, &m1, NULL);
if (p1c[4] == -1) {
perror("Could not create task b ...");
sys_end();
}
 
hard_task_default_model(m2);
hard_task_def_ctrl_jet(m2);
hard_task_def_mit(m2,50000); // the budget has dline 100,000!
hard_task_def_mit(m2,32000); // the budget has dline 100,000!
hard_task_def_wcet(m2, 3000);
hard_task_def_arg(m2,(void *)"Û");
hard_task_def_arg(m2,(void *)"X");
hard_task_def_group(m2,1);
hard_task_def_periodic(m2);
242,9 → 288,10
perror("Could not create task edf ...");
sys_end();
}
hard_task_def_mit(m2,6000); // the budget has dline 100,000!
 
hard_task_def_mit(m2,32000); // the budget has dline 100,000!
hard_task_def_wcet(m2, 3000);
hard_task_def_arg(m2,(void *)"A");
hard_task_def_arg(m2,(void *)"K");
p3 = task_create("3", edftask, &m2, NULL);
if (p3 == -1) {
perror("Could not create task edf ...");
252,7 → 299,7
}
 
cprintf("stars=%d", p2);
fineprg.tv_sec=550;
fineprg.tv_sec=140;
fineprg.tv_nsec=0;
kern_event_post(&fineprg,(void(*)(void *))sys_end, NULL);
group_activate(1);
263,6 → 310,11
char c='t';
PI_mutexattr_t a;
PI_mutexattr_default(a);
 
//NOP_mutexattr_t a;
//NOP_mutexattr_default(a);
 
 
mutex_init(&s,&a);
 
clear();
274,6 → 326,7
 
do {
//c =keyb_getch(BLOCK);
// cprintf("[]");
} while (c != ESC);
 
cprintf("ESC pressed!");
/demos/trunk/first/posixstar.c
18,11 → 18,11
 
/**
------------
CVS : $Id: posixstar.c,v 1.1 2003-06-18 08:13:02 trimarchi Exp $
CVS : $Id: posixstar.c,v 1.2 2003-08-01 13:20:38 trimarchi Exp $
 
File: $File$
Revision: $Revision: 1.1 $
Last update: $Date: 2003-06-18 08:13:02 $
Revision: $Revision: 1.2 $
Last update: $Date: 2003-08-01 13:20:38 $
------------
 
This file contains the scheduling module compatible with POSIX
128,7 → 128,8
 
if ((proc_table[p].control & CONTROL_CAP) &&
(proc_table[p].avail_time <= 0)) {
proc_table[p].avail_time += proc_table[p].wcet;
if (proc_table[p].avail_time<=0)
proc_table[p].avail_time += proc_table[p].wcet;
//kern_printf("RR policy");
iq_extract(p,&lev->ready[prio]);
iq_insertlast(p,&lev->ready[prio]);
142,7 → 143,7
if (lev->activated != NIL ) {
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level, lev->activated);
//kern_printf("CBS ext %d", lev->activated);
//kern_printf("CBS ext %d",p);
}
lev->activated = p;
149,10 → 150,7
if (p != NIL) {
BUDGET_TASK_MODEL b;
budget_task_default_model(b, lev->budget);
// viene inserito nel CBS
//#ifdef POSIXSTAR_DEBUG
//kern_printf("CBS Ins %d",p);
//#endif
//kern_printf("(Act %d",p);
level_table[ lev->scheduling_level ]->
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&b);
}
234,7 → 232,7
POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]);
 
//#ifdef POSIXSTAR_DEBUG
//kern_printf("PDisp:%d(%d)",p, lev->activated);
 
//#endif
/* the task state is set EXE by the scheduler()
241,9 → 239,12
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[lev->priority[p]]);
if (p==lev->activated) {
//if (!nostop) {
//kern_printf("PDisp:%d(%d)",p, lev->activated);
if (p==lev->activated)
level_table[lev->scheduling_level]->private_dispatch(lev->scheduling_level, p, nostop);
}
//} else
// kern_printf("PDisp:%d(%d)",p, lev->activated);
}
 
static void POSIXSTAR_public_epilogue(LEVEL l, PID p)
250,7 → 251,7
{
POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]);
//#ifdef POSIXSTAR_DEBUG
//kern_printf("PEpic:%d(%d)",p, lev->activated);
//kern_printf("PEpic:%d",p);
//#endif
if (p==lev->activated) {
if (lev->yielding) {
269,16 → 270,23
iq_insertlast(p,&lev->ready[lev->priority[p]]);
//level_table[lev->scheduling_level]->private_extract(lev->scheduling_level,p);
//lev->activated=NIL;
POSIXSTAR_private_scheduler(lev);
if (p==lev->activated)
level_table[lev->scheduling_level]->private_epilogue(lev->scheduling_level,p);
}
else {
//iq_insertfirst(p,&lev->ready[lev->priority[p]]);
level_table[lev->scheduling_level]->private_epilogue(lev->scheduling_level,p);
}
proc_table[p].status = POSIXSTAR_READY;
}
}
}
 
static void POSIXSTAR_internal_activate(POSIXSTAR_level_des *lev, PID p)
319,6 → 327,7
the task is */
 
/* Insert task in the coPOSIXect position */
//kern_printf("PU:%d", p);
proc_table[p].status = POSIXSTAR_READY;
iq_insertlast(p,&lev->ready[lev->priority[p]]);
POSIXSTAR_private_scheduler(lev);
325,7 → 334,9
}
 
static void POSIXSTAR_public_block(LEVEL l, PID p)
{
{
POSIXSTAR_level_des *lev = (POSIXSTAR_level_des *)(level_table[l]);
 
/* Extract the running task from the level
. we have already extract it from the ready queue at the dispatch time.
. the capacity event have to be removed by the generic kernel
338,6 → 349,9
//#ifdef POSIXSTAR_DEBUG
//kern_printf("PB:%d", p);
//#endif
iq_extract(p,&lev->ready[lev->priority[p]]);
POSIXSTAR_private_scheduler(lev);
}
 
static int POSIXSTAR_public_message(LEVEL l, PID p, void *m)
347,6 → 361,7
if (lev->nact[p] > 0) {
/* continue!!!! */
lev->nact[p]--;
iq_extract(p,&lev->ready[lev->priority[p]]);
iq_insertfirst(p,&lev->ready[lev->priority[p]]);
proc_table[p].status = POSIXSTAR_READY;
}
355,7 → 370,7
 
}
//#ifdef POSIXSTAR_DEBUG
//kern_printf("PM:%d",p);
kern_printf("PM:%d",p);
//#endif
//jet_update_endcycle(); /* Update the Jet data... */
//trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */
/demos/trunk/first/makefile
1,6 → 1,5
#
#
#
 
ifndef BASE
BASE=../..