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> |
* (see the web pages for full authors list) |
* Giacomo Guidi <giacomo@gandalf.sssup.it> |
* [Hard Reservation] |
* |
* 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,19 → 112,14 |
|
if (/* 1 */ TIMESPEC_A_LT_B(&lev->cbs_dline[p], 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 ... */ |
|
/* 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 */ |
132,20 → 127,16 |
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) |
{ |
/* Only one time due to hard reservation */ |
if (proc_table[p].avail_time < 0) |
|
if (proc_table[p].avail_time < 0) { |
ADDUSEC2TIMESPEC(lev->period[p], &lev->cbs_dline[p]); |
proc_table[p].avail_time += proc_table[p].wcet; |
} |
|
} |
|
161,14 → 152,9 |
|
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 */ |
175,6 → 161,7 |
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 |
181,11 → 168,15 |
the activation incrementing nact... */ |
lev->nact[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], |
/* 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], |
HCBS_timer_reactivate, |
(void *)p); |
} |
|
/* tracer stuff */ |
trc_logevent(TRC_INTACTIVATION,&p); |
197,17 → 188,13 |
static void HCBS_timer_zombie(void *par) |
{ |
PID p = (PID) par; |
HCBS_level_des *lev; |
|
lev = (HCBS_level_des *)level_table[proc_table[p].task_level]; |
|
/* we finally put the task in the ready queue */ |
|
/* we finally put the task in the free 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) |
{ |
308,7 → 295,7 |
|
return -1; |
} |
|
|
return 0; |
} |
|
326,7 → 313,6 |
/* 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 */ |
333,9 → 319,6 |
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; |
346,7 → 329,7 |
HCBS_timer_reactivate, |
(void *)p); |
} |
|
|
} |
else |
/* the task has been preempted. it returns into the ready queue by |
361,6 → 344,7 |
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; |
} |
390,7 → 374,6 |
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) |
416,19 → 399,18 |
|
static int HCBS_public_message(LEVEL l, PID p, void *m) |
{ |
|
HCBS_command_message *msg; |
HCBS_level_des *lev = (HCBS_level_des *)(level_table[l]); |
HCBS_command_message *msg; |
|
switch((long)(m)) { |
|
/* task_endcycle */ |
case (long)(NULL): |
|
/* check if the wcet is finished... */ |
HCBS_avail_time_check(lev, p); |
|
if (lev->flag[p] & HCBS_OVERLOAD) { |
lev->nact[p]++; |
if (!(lev->flag[p] & HCBS_APERIODIC) && lev->flag[p] & HCBS_OVERLOAD) { |
lev->flag[p] &= ~HCBS_OVERLOAD; |
lev->nact[p]++; |
} |
|
if (lev->nact[p]) { |
451,7 → 433,8 |
|
break; |
|
case 1: |
/* task_disable */ |
case (1): |
|
lev->flag[p] |= HCBS_SLEEP; |
|
485,10 → 468,12 |
break; |
} |
|
break; |
|
} |
|
return 0; |
|
|
} |
|
static void HCBS_public_end(LEVEL l, PID p) |
501,7 → 486,7 |
level_table[ lev->scheduling_level ]-> |
private_extract(lev->scheduling_level,p); |
|
/* and free the allocated bandwidth */ |
/* free the allocated bandwidth */ |
lev->U -= (MAX_BANDWIDTH/lev->period[p]) * proc_table[p].wcet; |
|
/* we delete the reactivation timer */ |