Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 210 → Rev 211

/shark/trunk/kernel/modules/hardcbs.c
9,8 → 9,8
* Paolo Gai <pj@gandalf.sssup.it>
* Massimiliano Giorgi <massy@gandalf.sssup.it>
* Luca Abeni <luca@gandalf.sssup.it>
* Giacomo Guidi <giacomo@gandalf.sssup.it>
* [Hard Reservation]
* Giacomo Guidi <giacomo@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
89,8 → 89,8
} HCBS_level_des;
 
static void HCBS_activation(HCBS_level_des *lev,
PID p,
struct timespec *acttime)
PID p,
struct timespec *acttime)
{
JOB_TASK_MODEL job;
 
112,14 → 112,19
 
if (/* 1 */ TIMESPEC_A_LT_B(&lev->cbs_dline[p], acttime) ||
/* 2 */ TIMESPEC_A_GT_B(&t3, &t2) ) {
 
/* we modify the deadline ... */
/* 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(&lev->cbs_dline[p], acttime);
ADDUSEC2TIMESPEC(lev->period[p], &lev->cbs_dline[p]);
 
/* and the capacity */
proc_table[p].avail_time = proc_table[p].wcet;
 
}
 
/* and, finally, we reinsert the task in the master level */
127,16 → 132,20
job_task_def_noexc(job);
level_table[ lev->scheduling_level ]->
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job);
}
 
static void HCBS_reload(HCBS_level_des *lev, PID p)
{
 
proc_table[p].avail_time += proc_table[p].wcet;
}
 
static void HCBS_avail_time_check(HCBS_level_des *lev, PID p)
{
 
if (proc_table[p].avail_time < 0) {
/* Only one time due to hard reservation */
if (proc_table[p].avail_time < 0)
ADDUSEC2TIMESPEC(lev->period[p], &lev->cbs_dline[p]);
proc_table[p].avail_time += proc_table[p].wcet;
}
 
}
 
152,9 → 161,14
 
if (lev->flag[p] & HCBS_SLEEP && proc_table[p].status == HCBS_IDLE) {
proc_table[p].status = SLEEP;
proc_table[p].avail_time = proc_table[p].wcet;
NULL_TIMESPEC(&lev->cbs_dline[p]);
return;
}
 
/* Hard reservation avail_time reload */
HCBS_reload(lev, p);
 
if (proc_table[p].status == HCBS_IDLE) {
/* the task has finished the current activation and must be
reactivated */
161,7 → 175,6
HCBS_activation(lev,p,&lev->reactivation_time[p]);
 
event_need_reschedule();
 
}
else if (lev->flag[p] & HCBS_SAVE_ARRIVALS)
/* the task has not completed the current activation, so we save
168,15 → 181,11
the activation incrementing nact... */
lev->nact[p]++;
 
/* repost the event at the next period end...
For bandwidth hard reservation, an aperiodic
task is forced to generate a reactivate event */
if (!(lev->flag[p] & HCBS_APERIODIC)) {
ADDUSEC2TIMESPEC(lev->period[p], &lev->reactivation_time[p]);
lev->reactivation_timer[p] = kern_event_post(&lev->reactivation_time[p],
/* repost the event at the next period end... */
ADDUSEC2TIMESPEC(lev->period[p], &lev->reactivation_time[p]);
lev->reactivation_timer[p] = kern_event_post(&lev->reactivation_time[p],
HCBS_timer_reactivate,
(void *)p);
}
/* tracer stuff */
trc_logevent(TRC_INTACTIVATION,&p);
188,13 → 197,17
static void HCBS_timer_zombie(void *par)
{
PID p = (PID) par;
/* we finally put the task in the free queue */
HCBS_level_des *lev;
 
lev = (HCBS_level_des *)level_table[proc_table[p].task_level];
 
/* we finally put the task in the ready queue */
proc_table[p].status = FREE;
iq_insertfirst(p,&freedesc);
 
}
 
 
/* The on-line guarantee is enabled only if the appropriate flag is set... */
static int HCBS_public_guarantee(LEVEL l, bandwidth_t *freebandwidth)
{
295,7 → 308,7
 
return -1;
}
 
return 0;
}
 
313,6 → 326,7
/* check if the wcet is finished... */
if ( proc_table[p].avail_time <= 0) {
/* Set the overload flag */
lev->flag[p] |= HCBS_OVERLOAD;
 
/* we kill the current activation */
319,6 → 333,9
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level, p);
 
/* we modify the deadline according to rule 4 ... */
HCBS_avail_time_check(lev, p);
 
/* Hard Reservation: The avail_time will be reloaded in the
next reactivation event. The task is suspended */
proc_table[p].status = HCBS_IDLE;
329,7 → 346,7
HCBS_timer_reactivate,
(void *)p);
}
 
}
else
/* the task has been preempted. it returns into the ready queue by
344,7 → 361,6
struct timespec t;
 
if (lev->flag[p] & HCBS_SLEEP) {
/* disable HCBS_SLEEP flag */
lev->flag[p] &= ~HCBS_SLEEP;
if (proc_table[p].status != SLEEP) return;
}
374,6 → 390,7
HCBS_timer_reactivate,
(void *)p);
}
// kern_printf("act : %d %d |",lev->cbs_dline[p].tv_nsec/1000,p);
}
 
static void HCBS_public_unblock(LEVEL l, PID p)
399,18 → 416,19
 
static int HCBS_public_message(LEVEL l, PID p, void *m)
{
 
HCBS_level_des *lev = (HCBS_level_des *)(level_table[l]);
HCBS_command_message *msg;
HCBS_level_des *lev = (HCBS_level_des *)(level_table[l]);
 
switch((long)(m)) {
 
/* task_endcycle */
case (long)(NULL):
 
if (!(lev->flag[p] & HCBS_APERIODIC) && lev->flag[p] & HCBS_OVERLOAD) {
/* check if the wcet is finished... */
HCBS_avail_time_check(lev, p);
 
if (lev->flag[p] & HCBS_OVERLOAD) {
lev->nact[p]++;
lev->flag[p] &= ~HCBS_OVERLOAD;
lev->nact[p]++;
}
 
if (lev->nact[p]) {
433,8 → 451,7
 
break;
 
/* task_disable */
case (1):
case 1:
 
lev->flag[p] |= HCBS_SLEEP;
 
468,12 → 485,10
break;
}
 
break;
 
}
 
return 0;
 
}
 
static void HCBS_public_end(LEVEL l, PID p)
486,7 → 501,7
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level,p);
 
/* free the allocated bandwidth */
/* and free the allocated bandwidth */
lev->U -= (MAX_BANDWIDTH/lev->period[p]) * proc_table[p].wcet;
 
/* we delete the reactivation timer */