Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 37 → Rev 38

/shark/trunk/kernel/modules/nopm.c
20,11 → 20,11
 
/**
------------
CVS : $Id: nopm.c,v 1.2 2002-11-11 08:32:06 pj Exp $
CVS : $Id: nopm.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 $
------------
 
See modules/nopm.h.
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>
138,40 → 137,23
#define NOPM_WAIT LIB_STATUS_BASE
 
 
/*+ print resource protocol statistics...+*/
static void NOPM_resource_status(RLEVEL r)
{
kern_printf("No status for NOPM module\n");
}
 
 
static int NOPM_level_accept_resource_model(RLEVEL l, RES_MODEL *r)
static int NOPM_res_register(RLEVEL l, PID p, RES_MODEL *r)
{
/* priority inheritance works with all tasks without Resource parameters */
return -1;
}
 
static void NOPM_res_register(RLEVEL l, PID p, RES_MODEL *r)
{
/* never called!!! */
}
 
static void NOPM_res_detach(RLEVEL l, PID p)
{
}
 
static int NOPM_level_accept_mutexattr(RLEVEL l, const mutexattr_t *a)
{
if (a->mclass == NOPM_MCLASS || a->mclass == (NOPM_MCLASS | l) )
return 0;
else
return -1;
}
 
static int NOPM_init(RLEVEL l, mutex_t *m, const mutexattr_t *a)
{
NOPM_mutex_t *p;
 
if (a->mclass != NOPM_MCLASS)
return -1;
 
p = (NOPM_mutex_t *) kern_alloc(sizeof(NOPM_mutex_t));
 
/* control if there is enough memory; no control on init on a
234,23 → 216,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 = NOPM_WAIT;
333,7 → 304,7
break;
} else if (proc_table[e].status == NOPM_WAIT) {
l = proc_table[e].task_level;
level_table[l]->task_insert(l,e);
level_table[l]->public_unblock(l,e);
p->counter++;
break;
}
348,7 → 319,7
return 0;
}
 
void NOPM_register_module(void)
RLEVEL NOPM_register_module(void)
{
RLEVEL l; /* the level that we register */
NOPM_mutex_resource_des *m; /* for readableness only */
365,20 → 336,11
resource_table[l] = (resource_des *)m;
 
/* fill the resource_des descriptor */
strncpy(m->m.r.res_name, NOPM_MODULENAME, MAX_MODULENAME);
m->m.r.res_code = NOPM_MODULE_CODE;
m->m.r.res_version = NOPM_MODULE_VERSION;
 
m->m.r.rtype = MUTEX_RTYPE;
 
m->m.r.resource_status = NOPM_resource_status;
m->m.r.level_accept_resource_model = NOPM_level_accept_resource_model;
m->m.r.res_register = NOPM_res_register;
 
m->m.r.res_detach = NOPM_res_detach;
 
/* fill the mutex_resource_des descriptor */
m->m.level_accept_mutexattr = NOPM_level_accept_mutexattr;
m->m.init = NOPM_init;
m->m.destroy = NOPM_destroy;
m->m.lock = NOPM_lock;
385,5 → 347,6
m->m.trylock = NOPM_trylock;
m->m.unlock = NOPM_unlock;
 
return l;
}