20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: nop.c,v 1.2 2002-11-11 08:32:06 pj Exp $ |
CVS : $Id: nop.c,v 1.3 2003-01-07 17:07:50 pj Exp $ |
|
File: $File$ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:32:06 $ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2003-01-07 17:07:50 $ |
------------ |
|
Binary Semaphores. see nop.h for more details... |
58,7 → 58,6 |
#include <ll/string.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <modules/codes.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
#include <kernel/func.h> |
80,40 → 79,21 |
/* Wait status for this library */ |
#define NOP_WAIT LIB_STATUS_BASE |
|
|
/*+ print resource protocol statistics...+*/ |
static void NOP_resource_status(RLEVEL r) |
static int NOP_res_register(RLEVEL l, PID p, RES_MODEL *r) |
{ |
kern_printf("No status for NOP module\n"); |
} |
|
|
static int NOP_level_accept_resource_model(RLEVEL l, RES_MODEL *r) |
{ |
/* priority inheritance works with all tasks without Resource parameters */ |
return -1; |
} |
|
static void NOP_res_register(RLEVEL l, PID p, RES_MODEL *r) |
{ |
/* never called!!! */ |
} |
|
static void NOP_res_detach(RLEVEL l, PID p) |
{ |
} |
|
static int NOP_level_accept_mutexattr(RLEVEL l, const mutexattr_t *a) |
{ |
if (a->mclass == NOP_MCLASS || a->mclass == (NOP_MCLASS | l) ) |
return 0; |
else |
return -1; |
} |
|
static int NOP_init(RLEVEL l, mutex_t *m, const mutexattr_t *a) |
{ |
NOP_mutex_t *p; |
|
if (a->mclass != NOP_MCLASS) |
return -1; |
|
p = (NOP_mutex_t *) kern_alloc(sizeof(NOP_mutex_t)); |
|
172,23 → 152,12 |
|
if (p->owner != NIL) { /* We must block exec task */ |
LEVEL l; /* for readableness only */ |
TIME tx; /* a dummy TIME for timespec operations */ |
struct timespec ty; /* a dummy timespec for timespec operations */ |
|
proc_table[exec_shadow].context = kern_context_save(); |
/* SAME AS SCHEDULER... manage the capacity event and the load_info */ |
ll_gettime(TIME_EXACT, &schedule_time); |
SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty); |
tx = TIMESPEC2USEC(&ty); |
proc_table[exec_shadow].avail_time -= tx; |
jet_update_slice(tx); |
if (cap_timer != NIL) { |
event_delete(cap_timer); |
cap_timer = NIL; |
} |
kern_epilogue_macro(); |
|
l = proc_table[exec_shadow].task_level; |
level_table[l]->task_extract(l,exec_shadow); |
level_table[l]->public_block(l,exec_shadow); |
|
/* we insert the task in the semaphore queue */ |
proc_table[exec_shadow].status = NOP_WAIT; |
256,7 → 225,7 |
p->owner = iq_getfirst(&p->blocked); |
if (p->owner != NIL) { |
l = proc_table[p->owner].task_level; |
level_table[l]->task_insert(l,p->owner); |
level_table[l]->public_unblock(l,p->owner); |
} |
|
scheduler(); |
265,7 → 234,7 |
return 0; |
} |
|
void NOP_register_module(void) |
RLEVEL NOP_register_module(void) |
{ |
RLEVEL l; /* the level that we register */ |
NOP_mutex_resource_des *m; /* for readableness only */ |
282,20 → 251,11 |
resource_table[l] = (resource_des *)m; |
|
/* fill the resource_des descriptor */ |
strncpy(m->m.r.res_name, NOP_MODULENAME, MAX_MODULENAME); |
m->m.r.res_code = NOP_MODULE_CODE; |
m->m.r.res_version = NOP_MODULE_VERSION; |
|
m->m.r.rtype = MUTEX_RTYPE; |
|
m->m.r.resource_status = NOP_resource_status; |
m->m.r.level_accept_resource_model = NOP_level_accept_resource_model; |
m->m.r.res_register = NOP_res_register; |
|
m->m.r.res_detach = NOP_res_detach; |
|
/* fill the mutex_resource_des descriptor */ |
m->m.level_accept_mutexattr = NOP_level_accept_mutexattr; |
m->m.init = NOP_init; |
m->m.destroy = NOP_destroy; |
m->m.lock = NOP_lock; |
302,5 → 262,6 |
m->m.trylock = NOP_trylock; |
m->m.unlock = NOP_unlock; |
|
return l; |
} |
|