20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: edf.c,v 1.7 2003-07-24 12:24:51 giacomo Exp $ |
CVS : $Id: edf.c,v 1.8 2003-09-29 16:24:36 giacomo Exp $ |
|
File: $File$ |
Revision: $Revision: 1.7 $ |
Last update: $Date: 2003-07-24 12:24:51 $ |
Revision: $Revision: 1.8 $ |
Last update: $Date: 2003-09-29 16:24:36 $ |
------------ |
|
This file contains the scheduling module EDF (Earliest Deadline First) |
62,7 → 62,7 |
#include <kernel/func.h> |
#include <kernel/trace.h> |
|
//#define EDFDEBUG |
//#define EDF_DEBUG |
#define edf_printf kern_printf |
|
/*+ Status used in the level +*/ |
77,8 → 77,6 |
#define EDF_FLAG_NORAISEEXC 2 |
#define EDF_FLAG_SLEEP 4 |
|
#undef EDFDEBUG |
|
/*+ the level redefinition for the Earliest Deadline First level +*/ |
typedef struct { |
level_des l; /*+ the standard level descriptor +*/ |
107,12 → 105,12 |
EDF_level_des *lev; |
struct timespec *temp; |
|
#ifdef EDFDEBUG |
edf_printf("$"); |
lev = (EDF_level_des *)level_table[proc_table[p].task_level]; |
|
#ifdef EDF_DEBUG |
edf_printf("(EDF:Dl TIMER:%d)",p); |
#endif |
|
lev = (EDF_level_des *)level_table[proc_table[p].task_level]; |
|
switch (proc_table[p].status) { |
case EDF_ZOMBIE: |
/* we finally put the task in the ready queue */ |
133,9 → 131,6 |
lev->deadline_timer[p] = kern_event_post(temp, |
EDF_timer_deadline, |
(void *)p); |
#ifdef EDFDEBUG |
edf_printf("(dline p%d ev%d %d.%d)",(int)p,(int)lev->deadline_timer[p],(int)temp->tv_sec,(int)temp->tv_nsec/1000); |
#endif |
event_need_reschedule(); |
break; |
|
150,10 → 145,6 |
|
default: |
/* else, a deadline miss occurred!!! */ |
#ifdef EDFDEBUG |
edf_printf("\nstatus %d\n", (int)proc_table[p].status); |
edf_printf("timer_deadline:AAARRRGGGHHH!!!"); |
#endif |
kern_raise(XDEADLINE_MISS,p); |
} |
} |
162,8 → 153,8 |
{ |
PID p = (PID) par; |
|
#ifdef EDFDEBUG |
edf_printf("AAARRRGGGHHH!!!"); |
#ifdef EDF_DEBUG |
edf_printf("(EDF:AAARRRGGGHHH!!!)"); |
#endif |
kern_raise(XDEADLINE_MISS,p); |
} |
172,11 → 163,6 |
static PID EDF_public_scheduler(LEVEL l) |
{ |
EDF_level_des *lev = (EDF_level_des *)(level_table[l]); |
|
#ifdef EDFDEBUG |
edf_printf("(s%d)", iq_query_first(&lev->ready)); |
#endif |
|
return iq_query_first(&lev->ready); |
} |
|
217,8 → 203,8 |
|
/* now we know that m is a valid model */ |
|
#ifdef EDFDEBUG |
edf_printf("(cr%d)", p); |
#ifdef EDF_DEBUG |
edf_printf("(EDF:PubCrt:%d)", p); |
#endif |
|
lev->period[p] = h->mit; |
247,8 → 233,8 |
|
EDF_level_des *lev = (EDF_level_des *)(level_table[l]); |
|
#ifdef EDFDEBUG |
edf_printf("(det%d)", p); |
#ifdef EDF_DEBUG |
edf_printf("(EDF:PubDet:%d)", p); |
#endif |
|
if (lev->flags & EDF_ENABLE_GUARANTEE) { |
260,8 → 246,8 |
{ |
EDF_level_des *lev = (EDF_level_des *)(level_table[l]); |
|
#ifdef EDFDEBUG |
edf_printf("(disp p%d %d.%d)",(int)p,(int)schedule_time.tv_sec,(int)schedule_time.tv_nsec/1000); |
#ifdef EDF_DEBUG |
edf_printf("(EDF:PubDsp:%d)",p); |
#endif |
|
/* the task state is set EXE by the scheduler() |
274,8 → 260,8 |
{ |
EDF_level_des *lev = (EDF_level_des *)(level_table[l]); |
|
#ifdef EDFDEBUG |
edf_printf("(epil p%d %d.%d)",p,(int)schedule_time.tv_sec,(int)schedule_time.tv_nsec/1000); |
#ifdef EDF_DEBUG |
edf_printf("(EDF:PubEpi:%d)",p); |
#endif |
|
/* check if the wcet is finished... */ |
296,8 → 282,8 |
EDF_level_des *lev = (EDF_level_des *)(level_table[l]); |
struct timespec *temp; |
|
#ifdef EDFDEBUG |
edf_printf("(act%d sleep%d)", p, lev->flag[p]&EDF_FLAG_SLEEP); |
#ifdef EDF_DEBUG |
edf_printf("(EDF:PubAct:%d)", p); |
#endif |
|
if (lev->flag[p] & EDF_FLAG_SLEEP) { |
332,9 → 318,6 |
lev->deadline_timer[p] = kern_event_post(temp, |
EDF_timer_deadline, |
(void *)p); |
#ifdef EDFDEBUG |
edf_printf("(dline p%d ev%d %d.%d)",p,(int)lev->deadline_timer[p],(int)temp->tv_sec,(int)temp->tv_nsec/1000); |
#endif |
} |
|
static void EDF_public_unblock(LEVEL l, PID p) |
366,14 → 349,14 |
{ |
EDF_level_des *lev = (EDF_level_des *)(level_table[l]); |
|
//task_message evaluation |
/* task_message evaluation */ |
switch((long)(m)) { |
|
//task_endcycle |
/* task_endcycle */ |
case (long)(NULL): |
|
#ifdef EDFDEBUG |
edf_printf("(ecyc p%d %d.%d)",p,(int)schedule_time.tv_sec,(int)schedule_time.tv_nsec/1000); |
#ifdef EDF_DEBUG |
edf_printf("(EDF:EndCyc:%d)",p); |
#endif |
|
/* the task has terminated his job before it consume the wcet. All OK! */ |
392,11 → 375,11 |
|
break; |
|
//task_disable |
/* task_disable */ |
case 1: |
|
#ifdef EDFDEBUG |
edf_printf("(disable%d)",p); |
#ifdef EDF_DEBUG |
edf_printf("(EDF:Dis:%d)",p); |
#endif |
|
/* Set the EDF_FLAG_SLEEP, in the next endcycle the task will |
480,9 → 463,6 |
{ |
EDF_level_des *lev = (EDF_level_des *)(level_table[l]); |
|
#ifdef EDFDEBUG |
edf_printf("EDF_guest_end: dline timer %d\n",lev->deadline_timer[p]); |
#endif |
if (proc_table[p].status == EDF_READY) |
iq_extract(p, &lev->ready); |
|