Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 1118 → Rev 1117

/demos/trunk/auto/edfact.c
18,11 → 18,11
 
/**
------------
CVS : $Id: edfact.c,v 1.3 2002-11-11 08:19:19 pj Exp $
CVS : $Id: edfact.c,v 1.2 2002-10-28 08:17:15 pj Exp $
 
File: $File$
Revision: $Revision: 1.3 $
Last update: $Date: 2002-11-11 08:19:19 $
Revision: $Revision: 1.2 $
Last update: $Date: 2002-10-28 08:17:15 $
------------
**/
 
84,7 → 84,7
/*+ used to manage the JOB_TASK_MODEL and the
periodicity +*/
 
IQUEUE ready; /*+ the ready queue +*/
QUEUE ready; /*+ the ready queue +*/
 
int flags; /*+ the init flags... +*/
 
97,20 → 97,16
 
static void EDFACT_internal_activate(EDFACT_level_des *lev, PID p)
{
struct timespec *temp;
 
temp = iq_query_timespec(p, &lev->ready);
 
TIMESPEC_ASSIGN(temp,
TIMESPEC_ASSIGN(&proc_table[p].timespec_priority,
&proc_table[p].request_time);
ADDUSEC2TIMESPEC(lev->period[p], temp);
ADDUSEC2TIMESPEC(lev->period[p], &proc_table[p].timespec_priority);
 
TIMESPEC_ASSIGN(&lev->deadline_timespec[p],
temp);
&proc_table[p].timespec_priority);
 
/* Insert task in the correct position */
proc_table[p].status = EDFACT_READY;
iq_timespec_insert(p,&lev->ready);
q_timespec_insert(p,&lev->ready);
 
/* needed because when there is a wcet miss I disable CONTROL_CAP */
proc_table[p].control |= CONTROL_CAP;
138,9 → 134,9
switch (proc_table[p].status) {
case EDFACT_IDLE:
edfact_printf("I%d",p);
TIMESPEC_ASSIGN(&proc_table[p].request_time,
&proc_table[p].timespec_priority);
 
*iq_query_timespec(p, &lev->ready) = proc_table[p].request_time;
 
EDFACT_internal_activate(lev,p);
 
event_need_reschedule();
205,7 → 201,7
static void EDFACT_level_status(LEVEL l)
{
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
PID p = iq_query_first(&lev->ready);
PID p = lev->ready;
 
kern_printf("On-line guarantee : %s\n",
onoff(lev->flags & EDFACT_ENABLE_GUARANTEE));
221,10 → 217,10
proc_table[p].name,
"Period ",
lev->period[p],
iq_query_timespec(p, &lev->ready)->tv_sec,
iq_query_timespec(p, &lev->ready)->tv_nsec/1000,
proc_table[p].timespec_priority.tv_sec,
proc_table[p].timespec_priority.tv_nsec/1000,
EDFACT_status_to_a(proc_table[p].status));
p = iq_query_next(p, &lev->ready);
p = proc_table[p].next;
}
 
for (p=0; p<MAX_PROC; p++)
235,8 → 231,8
proc_table[p].name,
"Period ",
lev->period[p],
iq_query_timespec(p, &lev->ready)->tv_sec,
iq_query_timespec(p, &lev->ready)->tv_nsec/1000,
proc_table[p].timespec_priority.tv_sec,
proc_table[p].timespec_priority.tv_nsec/1000,
EDFACT_status_to_a(proc_table[p].status));
}
 
255,7 → 251,7
kern_printf(") ");
}
*/
return iq_query_first(&lev->ready);
return (PID)lev->ready;
}
 
/* The on-line guarantee is enabled only if the appropriate flag is set... */
352,7 → 348,7
/* 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);
q_extract(p, &lev->ready);
}
 
static void EDFACT_task_epilogue(LEVEL l, PID p)
368,7 → 364,7
}
 
/* the task it returns into the ready queue... */
iq_timespec_insert(p,&lev->ready);
q_timespec_insert(p,&lev->ready);
proc_table[p].status = EDFACT_READY;
}
 
401,7 → 397,7
 
/* Insert task in the coEDFect position */
proc_table[p].status = EDFACT_READY;
iq_timespec_insert(p,&lev->ready);
q_timespec_insert(p,&lev->ready);
}
 
static void EDFACT_task_extract(LEVEL l, PID p)
428,7 → 424,7
EDFACT_internal_activate(lev,p);
 
/* check if the deadline has already expired */
if (TIMESPEC_A_LT_B(iq_query_timespec(p, &lev->ready), &schedule_time)) {
if (TIMESPEC_A_LT_B(&proc_table[p].timespec_priority, &schedule_time)) {
/* count the deadline miss */
lev->dline_miss[p]++;
event_delete(lev->deadline_timer[p]);
454,7 → 450,7
 
/* we finally put the task in the ready queue */
proc_table[p].status = FREE;
iq_insertfirst(p,&freedesc);
q_insertfirst(p,&freedesc);
/* and free the allocated bandwidth */
lev->U -= (MAX_BANDWIDTH/lev->period[p]) * proc_table[p].wcet;
 
467,6 → 463,9
static void EDFACT_task_sleep(LEVEL l, PID p)
{ kern_raise(XINVALID_TASK,exec_shadow); }
 
static void EDFACT_task_delay(LEVEL l, PID p, TIME usdelay)
{ 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 EDFACT ready queue. */
479,7 → 478,7
/* if the EDFACT_guest_create is called, then the pclass must be a
valid pclass. */
 
TIMESPEC_ASSIGN(iq_query_timespec(p, &lev->ready), &job->deadline);
TIMESPEC_ASSIGN(&proc_table[p].timespec_priority, &job->deadline);
lev->deadline_timer[p] = -1;
lev->dline_miss[p] = 0;
513,7 → 512,7
/* 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);
q_extract(p, &lev->ready);
}
 
static void EDFACT_guest_epilogue(LEVEL l, PID p)
521,7 → 520,7
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);
q_timespec_insert(p,&lev->ready);
proc_table[p].status = EDFACT_READY;
}
 
530,12 → 529,12
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
/* Insert task in the correct position */
iq_timespec_insert(p,&lev->ready);
q_timespec_insert(p,&lev->ready);
proc_table[p].status = EDFACT_READY;
 
/* Set the deadline timer */
if (!(lev->flag[p] & EDFACT_FLAG_NORAISEEXC))
lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready),
lev->deadline_timer[p] = kern_event_post(&proc_table[p].timespec_priority,
EDFACT_timer_guest_deadline,
(void *)p);
 
546,7 → 545,7
EDFACT_level_des *lev = (EDFACT_level_des *)(level_table[l]);
 
/* Insert task in the correct position */
iq_timespec_insert(p,&lev->ready);
q_timespec_insert(p,&lev->ready);
proc_table[p].status = EDFACT_READY;
}
 
564,7 → 563,7
//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);
q_extract(p, &lev->ready);
//kern_printf("(g_end rdy extr)");
}
 
580,6 → 579,9
static void EDFACT_guest_sleep(LEVEL l, PID p)
{ kern_raise(XINVALID_GUEST,exec_shadow); }
 
static void EDFACT_guest_delay(LEVEL l, PID p, TIME usdelay)
{ kern_raise(XINVALID_GUEST,exec_shadow); }
 
/* Registration functions */
 
/*+ Registration function:
631,6 → 633,7
lev->l.task_endcycle = EDFACT_task_endcycle;
lev->l.task_end = EDFACT_task_end;
lev->l.task_sleep = EDFACT_task_sleep;
lev->l.task_delay = EDFACT_task_delay;
 
lev->l.guest_create = EDFACT_guest_create;
lev->l.guest_detach = EDFACT_guest_detach;
642,6 → 645,7
lev->l.guest_endcycle = EDFACT_guest_endcycle;
lev->l.guest_end = EDFACT_guest_end;
lev->l.guest_sleep = EDFACT_guest_sleep;
lev->l.guest_delay = EDFACT_guest_delay;
 
/* fill the EDFACT descriptor part */
for(i=0; i<MAX_PROC; i++) {
653,7 → 657,7
lev->nact[i] = 0;
}
 
iq_init(&lev->ready,&freedesc, 0);
lev->ready = NIL;
lev->flags = flags & 0x07;
lev->U = 0;
}