20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: cbs.c,v 1.2 2002-10-28 07:55:54 pj Exp $ |
CVS : $Id: cbs.c,v 1.3 2002-11-11 08:32:06 pj Exp $ |
|
File: $File$ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-10-28 07:55:54 $ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2002-11-11 08:32:06 $ |
------------ |
|
This file contains the aperiodic server CBS (Total Bandwidth Server) |
76,7 → 76,6 |
/*+ Status used in the level +*/ |
#define CBS_IDLE APER_STATUS_BASE /*+ waiting the activation +*/ |
#define CBS_ZOMBIE APER_STATUS_BASE+1 /*+ waiting the period end +*/ |
#define CBS_DELAY APER_STATUS_BASE+2 /*+ waiting the delay end +*/ |
|
/*+ task flags +*/ |
#define CBS_SAVE_ARRIVALS 1 |
188,7 → 187,6 |
switch (status) { |
case CBS_IDLE : return "CBS_Idle"; |
case CBS_ZOMBIE : return "CBS_Zombie"; |
case CBS_DELAY : return "CBS_Delay"; |
default : return "CBS_Unknown"; |
} |
} |
253,20 → 251,6 |
|
} |
|
/*+ this function is called when a task finish his delay +*/ |
static void CBS_timer_delay(void *par) |
{ |
PID p = (PID) par; |
CBS_level_des *lev; |
|
lev = (CBS_level_des *)level_table[proc_table[p].task_level]; |
|
CBS_activation(lev,p,&proc_table[p].timespec_priority); |
|
event_need_reschedule(); |
} |
|
|
/*+ this function is called when a killed or ended task reach the |
period end +*/ |
static void CBS_timer_zombie(void *par) |
278,7 → 262,7 |
|
/* we finally put the task in the ready queue */ |
proc_table[p].status = FREE; |
q_insertfirst(p,&freedesc); |
iq_insertfirst(p,&freedesc); |
|
/* and free the allocated bandwidth */ |
lev->U -= (MAX_BANDWIDTH/lev->period[p]) * proc_table[p].wcet; |
451,29 → 435,11 |
return 0; |
} |
|
#ifdef __TEST1__ |
extern int testactive; |
extern struct timespec s_stime[]; |
extern TIME s_curr[]; |
extern TIME s_PID[]; |
extern int useds; |
#endif |
|
static void CBS_task_dispatch(LEVEL l, PID p, int nostop) |
{ |
CBS_level_des *lev = (CBS_level_des *)(level_table[l]); |
level_table[ lev->scheduling_level ]-> |
guest_dispatch(lev->scheduling_level,p,nostop); |
|
#ifdef __TEST1__ |
if (testactive) |
{ |
TIMESPEC_ASSIGN(&s_stime[useds], &schedule_time); |
s_curr[useds] = proc_table[p].avail_time; |
s_PID[useds] = p; |
useds++; |
} |
#endif |
} |
|
static void CBS_task_epilogue(LEVEL l, PID p) |
639,32 → 605,6 |
lev->nact[p] = 0; |
} |
|
static void CBS_task_delay(LEVEL l, PID p, TIME usdelay) |
{ |
struct timespec wakeuptime; |
CBS_level_des *lev = (CBS_level_des *)(level_table[l]); |
|
/* check if the wcet is finished... */ |
CBS_avail_time_check(lev, p); |
|
level_table[ lev->scheduling_level ]-> |
guest_end(lev->scheduling_level,p); |
|
proc_table[p].status = CBS_DELAY; |
|
/* we need to delete this event if we kill the task while it is sleeping */ |
ll_gettime(TIME_EXACT, &wakeuptime); |
ADDUSEC2TIMESPEC(usdelay, &wakeuptime); |
|
/* the timespec_priority field is used to store the time at witch the delay |
timer raises */ |
TIMESPEC_ASSIGN(&proc_table[p].timespec_priority, &wakeuptime); |
proc_table[p].delay_timer = kern_event_post(&wakeuptime, |
CBS_timer_delay, |
(void *)p); |
} |
|
|
static int CBS_guest_create(LEVEL l, PID p, TASK_MODEL *m) |
{ kern_raise(XINVALID_GUEST,exec_shadow); return 0; } |
|
695,12 → 635,7 |
static void CBS_guest_sleep(LEVEL l, PID p) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
static void CBS_guest_delay(LEVEL l, PID p,DWORD tickdelay) |
{ kern_raise(XINVALID_GUEST,exec_shadow); } |
|
|
|
|
/* Registration functions */ |
|
/*+ Registration function: |
752,7 → 687,6 |
lev->l.task_endcycle = CBS_task_endcycle; |
lev->l.task_end = CBS_task_end; |
lev->l.task_sleep = CBS_task_sleep; |
lev->l.task_delay = CBS_task_delay; |
|
lev->l.guest_create = CBS_guest_create; |
lev->l.guest_detach = CBS_guest_detach; |
764,7 → 698,6 |
lev->l.guest_endcycle = CBS_guest_endcycle; |
lev->l.guest_end = CBS_guest_end; |
lev->l.guest_sleep = CBS_guest_sleep; |
lev->l.guest_delay = CBS_guest_delay; |
|
/* fill the CBS descriptor part */ |
for (i=0; i<MAX_PROC; i++) { |