Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 37 → Rev 38

/shark/trunk/include/kernel/descr.h
21,11 → 21,11
 
/**
------------
CVS : $Id: descr.h,v 1.2 2002-11-11 08:36:01 pj Exp $
CVS : $Id: descr.h,v 1.3 2003-01-07 17:12:19 pj Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2002-11-11 08:36:01 $
Revision: $Revision: 1.3 $
Last update: $Date: 2003-01-07 17:12:19 $
------------
 
Kernel main data structures
130,8 → 130,6
int sigpending; /*+ The signal pending mask +*/
int sigwaiting; /*+ The signal waiting mask +*/
 
struct timespec request_time;
/*+ Last request time for the task +*/
int avail_time; /*+ the time the task can execute before a
timer fire. see also the control field
and bits related in model.h +*/
193,133 → 191,107
All the informations that depends on the particular module are put
in the level module files.
 
The initialization of a level is splitted in two parts:
- the registration -> called before the system initialization, typically
AFTER the resource registration
- the level_init -> called during the system initialization,
BEFORE the resource_init(s)
Here a small description of the various functions:
 
-------------------------------------------------------------------
- PUBLIC Functions:
on one side, a module should export an interface to the Generic
Kernel, giving a set of functions that the Generic Kernel can use
to ask a service to the module. That is, the Public Functions are
called ONLY by the Generic Kernel.
 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- PRIVATE Functions: on the other side, a module can export an
interface to the public part of the same or of another
module. That is, Private Functions are called ONLY by Public and
Private Functions.
-------------------------------------------------------------------
 
typedef struct {
char level_name[MAX_LEVELNAME]; /*+ for statistical pourposes +*/
WORD level_code; /*+ level identification code +*/
BYTE level_version; /*+ level version +*/
int (*private_insert )(LEVEL l, PID p, TASK_MODEL *m);
Inserts a task into the internal module data structure.
void (*private_extract )(LEVEL l, PID p);
Removes a task from the internal module data structure.
 
/* LEVEL CALLS */
int (*level_accept_task_model)(LEVEL l, TASK_MODEL *m);
/*+ models that a task can manage. returns
0 if the level can manage the model,
-1 if not +*/
int (*private_eligible)(LEVEL l, PID p);
A task inserted into the internal module data structure needs to be
scheduled. returns 0 if it can be scheduled, -1 if not.
 
int (*level_accept_guest_model)(LEVEL l, TASK_MODEL *m);
/*+ models that a task can manage as guest
tasks. returns
0 if the level can manage the model,
-1 if not +*/
void (*private_dispatch)(LEVEL l, PID p, int nostop);
A task inserted into the internal module data structure has been dispatched.
 
void (*level_status)(LEVEL l);/*+ print level statistics... +*/
void (*private_epilogue)(LEVEL l, PID p);
A task inserted into the internal module data structure has been preempted.
 
PID (*level_scheduler)(LEVEL l);
/*+ the level scheduler returns a task
chosen among those belonging to the
level +*/
 
int (*level_guarantee)(LEVEL l, bandwidth_t *freebandwidth);
/*+ 0 if the level is guaranteed, -1 if not
no guarantee if (*f)()=null
the function updates the parameter
(see guarantee() ) +*/
 
/* TASK CALLS */
int (*task_create)(LEVEL l, PID p, TASK_MODEL *m);
/*+ the task p is created into the level
returns 0->ok, -1->error +*/
void (*task_detach)(LEVEL l, PID p);
/*+ there is an error in the task_create
after the task call task_create.
The function delete all the informations
about the task in the level.
For the resources levels there is the
res_detach: res_detach is called also
when killing a task +*/
int (*task_eligible)(LEVEL l, PID p);
/*+ correctness control when a task is
chosen by a level scheduler (used with
aperiodic servers) 0->ok, -1->no +*/
void (*task_dispatch)(LEVEL l, PID p, int nostop);
/*+ a task go in the EXEC status (called
by dispatch() ) +*/
void (*task_epilogue)(LEVEL l, PID p);
/*+ a task has finished the current slice+*/
PID (*public_scheduler)(LEVEL l);
returns a task to schedule, or -1 if no tasks are ready
 
void (*task_activate)(LEVEL l, PID p);
/*+ the task is activated... +*/
int (*public_guarantee)(LEVEL l, bandwidth_t *freebandwidth);
returns 0 if the level is guaranteed, -1 if not
no guarantee if (*f)()=null
the function updates the parameter freebandwidth (see guarantee() )
int (*public_create )(LEVEL l, PID p, TASK_MODEL *m);
the task p is created into the module
returns 0->ok, -1->error
 
void (*task_insert)(LEVEL l, PID p);
/*+ opposite to task_extract +*/
void (*task_extract)(LEVEL l, PID p);
/*+ remove the task from the "ready" (if any)
queue +*/
void (*public_detach )(LEVEL l, PID p);
there is an error in the public_create. The function removes all the
informations about the task in the module.
 
void (*task_endcycle)(LEVEL l, PID p);
/*+ the (periodic) task finish the cycle +*/
void (*task_end)(LEVEL l, PID p);
/*+ the task is killed; we have to remove
it from the level queues, test if it
is in the exec state, etc... it can
modify the state of the task (-> FREE,
ZOMBIE...), but
cannot call the scheduler directly (it
is called by the task_makefree.
Note: the task can be in a state
different from those managed by the
level because the task may be blocked.
the res_detach is in any case called
AFTER the task_end. +*/
void (*public_end )(LEVEL l, PID p);
the task has been killed, or it ended regularly
 
void (*task_sleep)(LEVEL l, PID p);
/*+ this function will fall asleep the
task in the EXE state. +*/
int (*public_eligible )(LEVEL l, PID p);
A task needs to be scheduled. returns 0 if it can be scheduled, -1 if not.
void (*public_dispatch )(LEVEL l, PID p, int nostop);
A task has been dispatched.
 
void (*public_epilogue )(LEVEL l, PID p);
A task has been preempted (or its capacity is exausted).
 
/* guest CALLS:
these functions are called from an Aperiodic Server Level for the task
that are inserted in the local queues */
int (*guest_create)(LEVEL l, PID p, TASK_MODEL *m);
/*+ the task is already created in another
level and it is inserted in the current
level; returns 0->ok, -1->error +*/
void (*guest_detach)(LEVEL l, PID p);
/*+ there is an error in a task creation
of a task made by an aperiodic server
The function delete all the informations
about the task in the level. +*/
void (*guest_dispatch)(LEVEL l, PID p, int nostop);
/*+ a task belonging to another level but
inserted in the current level go in the
EXEC status (called by dispatch() ) +*/
void (*guest_epilogue)(LEVEL l, PID p);
/*+ a task has finished the current slice+*/
void (*public_activate )(LEVEL l, PID p);
A task has been activated.
 
void (*guest_activate)(LEVEL l, PID p);
/*+ the task is activated... +*/
void (*public_unblock )(LEVEL l, PID p);
void (*public_block )(LEVEL l, PID p);
A task has been unblocked/blocked on a synchronization point
(e.g. a semaphore, a mailbox, a nanosleep).
 
void (*guest_insert)(LEVEL l, PID p);
/*+ remove the task from the "ready" (if any)
queue +*/
void (*guest_extract)(LEVEL l, PID p);
/*+ opposite to guest_insert +*/
int (*public_message )(LEVEL l, PID p, void *m);
A task sent a message m to the module.
 
If the message has value NULL the
behavior should be the task_endcycle primitive behavior.
 
void (*guest_endcycle)(LEVEL l, PID p);
/*+ the task finish the cycle +*/
void (*guest_end)(LEVEL l, PID p);
/*+ the task is killed +*/
The function returns an integer to the user.
 
void (*guest_sleep)(LEVEL l, PID p);
If you want to avoid the call to public_epilogue, after public_message,
just write exec = exec_shadow = -1; in your public_message code.
 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
 
typedef struct {
void (*private_insert )(LEVEL l, PID p, TASK_MODEL *m);
void (*private_extract )(LEVEL l, PID p);
int (*private_eligible)(LEVEL l, PID p);
void (*private_dispatch)(LEVEL l, PID p, int nostop);
void (*private_epilogue)(LEVEL l, PID p);
 
PID (*public_scheduler)(LEVEL l);
int (*public_guarantee)(LEVEL l, bandwidth_t *freebandwidth);
int (*public_create )(LEVEL l, PID p, TASK_MODEL *m);
void (*public_detach )(LEVEL l, PID p);
void (*public_end )(LEVEL l, PID p);
int (*public_eligible )(LEVEL l, PID p);
void (*public_dispatch )(LEVEL l, PID p, int nostop);
void (*public_epilogue )(LEVEL l, PID p);
void (*public_activate )(LEVEL l, PID p);
void (*public_unblock )(LEVEL l, PID p);
void (*public_block )(LEVEL l, PID p);
int (*public_message )(LEVEL l, PID p, void *m);
} level_des;
 
 
344,27 → 316,18
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
 
typedef struct {
char res_name[MAX_MODULENAME];/*+ for statistical pourposes +*/
WORD res_code; /*+ resource module identification code +*/
BYTE res_version; /*+ resource module version +*/
 
int rtype; /*+ resource module extented interface
code (see model.h) +*/
 
void (*resource_status)(); /*+ print resource protocol statistics...+*/
int (*res_register)(RLEVEL l, PID p, RES_MODEL *r);
/*+ When the system knows that a
resource model can be registered
by a level, it calls this
function. It registers all the
information about the task and the
model. returns 0 if the model
can be handled, -1 otherwise+*/
 
int (*level_accept_resource_model)(RLEVEL l, RES_MODEL *r);
/*+ this function is called when the process
is created. it returns 0 if the RES_MODEL
can be managed by the level,-1 if not+*/
 
void (*res_register)(RLEVEL l, PID p, RES_MODEL *r);
/*+ When the system knows that a resource
model can be registered by a level,
it calls this function. It registers all
the information about the task and the
model. +*/
 
void (*res_detach)(RLEVEL l, PID p);
/*+ this function is called when the task
is killed or some error is occurred
411,13 → 374,10
typedef struct {
resource_des r;
 
int (*level_accept_mutexattr)(RLEVEL l, const mutexattr_t *a);
/*+ this function is called when a mutex
is created. it returns 0 if the
mutexattr_t
can be managed by the level,-1 if not+*/
 
int (*init) (RLEVEL l, mutex_t *m, const mutexattr_t *a);
/*+ this function is called when a mutex is created. it returns
>=0 if the mutexattr_t can be managed by the level (=0 Ok, an
error otherwise), -1 otherwise +*/
int (*destroy)(RLEVEL l, mutex_t *m);
int (*lock) (RLEVEL l, mutex_t *m);
int (*trylock)(RLEVEL l, mutex_t *m);