20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: posix.c,v 1.9 2004-05-17 15:03:52 anton Exp $ |
CVS : $Id: posix.c,v 1.10 2004-10-25 14:44:28 trimarchi Exp $ |
|
File: $File$ |
Revision: $Revision: 1.9 $ |
Last update: $Date: 2004-05-17 15:03:52 $ |
Revision: $Revision: 1.10 $ |
Last update: $Date: 2004-10-25 14:44:28 $ |
------------ |
|
This file contains the scheduling module compatible with POSIX |
65,10 → 65,15 |
#include <kernel/func.h> |
|
#include <tracer.h> |
#include <modules/comm_message.h> |
|
/*+ Status used in the level +*/ |
#define POSIX_READY MODULE_STATUS_BASE |
|
/*+ Use for change level in POSIX +*/ |
#define POSIX_CHANGE_LEVEL 1 |
|
|
/*+ the level redefinition for the Round Robin level +*/ |
typedef struct { |
level_des l; /*+ the standard level descriptor +*/ |
88,6 → 93,13 |
|
int yielding; /*+ equal to 1 when a sched_yield is called +*/ |
|
/* introduce for changing level in POSIX */ |
int flag[MAX_PROC]; |
|
int new_level[MAX_PROC]; |
int new_slice[MAX_PROC]; |
int new_control[MAX_PROC]; |
|
} POSIX_level_des; |
|
/* This is not efficient but very fair :-) |
176,6 → 188,8 |
lev->nact[p] = -1; |
} |
|
lev->flag[p] = 0; |
|
return 0; /* OK */ |
} |
|
193,6 → 207,20 |
{ |
POSIX_level_des *lev = (POSIX_level_des *)(level_table[l]); |
|
/* Change task level */ |
if (lev->flag[p] & POSIX_CHANGE_LEVEL) { |
|
STD_command_message msg; |
|
proc_table[p].status = SLEEP; |
proc_table[p].task_level = lev->new_level[p]; |
msg.command = STD_ACTIVATE_TASK; |
level_table[lev->new_level[p]] -> public_message(lev->new_level[p],p,&msg); |
|
return; |
|
} |
|
if (lev->yielding) { |
lev->yielding = 0; |
iq_insertlast(p,&lev->ready[lev->priority[p]]); |
251,6 → 279,7 |
*/ |
} |
|
#ifdef OLDVERSION |
static int POSIX_public_message(LEVEL l, PID p, void *m) |
{ |
POSIX_level_des *lev = (POSIX_level_des *)(level_table[l]); |
269,7 → 298,98 |
|
return 0; |
} |
#else |
static int POSIX_public_message(LEVEL l, PID p, void *m) |
{ |
POSIX_level_des *lev = (POSIX_level_des *)(level_table[l]); |
STD_command_message *msg; |
|
NRT_TASK_MODEL *nrt; |
|
/* Task Endcycle */ |
switch ((long)(m)) { |
|
case (long)(NULL): |
if (lev->nact[p] > 0) { |
/* continue!!!! */ |
lev->nact[p]--; |
iq_insertfirst(p,&lev->ready[lev->priority[p]]); |
proc_table[p].status = POSIX_READY; |
} else |
proc_table[p].status = SLEEP; |
|
jet_update_endcycle(); /* Update the Jet data... */ |
TRACER_LOGEVENT(FTrace_EVT_task_end_cycle,(unsigned short int)proc_table[p].context,(unsigned int)l); |
|
break; |
|
/* Task Disable */ |
case (long)(1): |
|
break; |
|
default: |
|
msg = (STD_command_message *)m; |
|
switch(msg->command) { |
case STD_SET_NEW_LEVEL: |
|
lev->flag[p] |= POSIX_CHANGE_LEVEL; |
lev->new_level[p] = (int)(msg->param); |
|
break; |
case STD_SET_NEW_MODEL: |
|
nrt = (NRT_TASK_MODEL *)(msg->param); |
|
lev->priority[p] = nrt->weight; |
|
if (nrt->slice) { |
lev->new_slice[p] = nrt->slice; |
} else { |
lev->new_slice[p] = 0; |
} |
|
if (nrt->policy == NRT_RR_POLICY) |
lev->new_control[p] |= CONTROL_CAP; |
|
if (nrt->arrivals == SAVE_ARRIVALS) |
lev->nact[p] = 0; |
else |
lev->nact[p] = -1; |
|
lev->flag[p] = 0; |
|
break; |
|
case STD_ACTIVATE_TASK: |
|
if (lev->new_slice[p]) { |
proc_table[p].avail_time = lev->new_slice[p]; |
proc_table[p].wcet = lev->new_slice[p]; |
} else { |
proc_table[p].avail_time = lev->slice; |
proc_table[p].wcet = lev->slice; |
} |
|
proc_table[p].control = lev->new_control[p]; |
|
POSIX_public_activate(l,p, NULL); |
|
break; |
|
} |
|
break; |
|
} |
|
return 0; |
} |
|
#endif |
|
static void POSIX_public_end(LEVEL l, PID p) |
{ |
POSIX_level_des *lev = (POSIX_level_des *)(level_table[l]); |