Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 3 → Rev 38

/shark/trunk/kernel/modules/pc.c
20,11 → 20,11
 
/**
------------
CVS : $Id: pc.c,v 1.1.1.1 2002-03-29 14:12:52 pj Exp $
CVS : $Id: pc.c,v 1.2 2003-01-07 17:07:50 pj Exp $
 
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2002-03-29 14:12:52 $
Revision: $Revision: 1.2 $
Last update: $Date: 2003-01-07 17:07:50 $
------------
 
Priority Ceiling protocol. see pc.h for more details...
57,7 → 57,6
#include <ll/string.h>
#include <ll/stdio.h>
#include <kernel/const.h>
#include <modules/codes.h>
#include <sys/types.h>
#include <kernel/var.h>
#include <kernel/func.h>
153,7 → 152,7
}
 
 
 
#if 0
/*+ print resource protocol statistics...+*/
static void PC_resource_status(RLEVEL r)
{
172,23 → 171,24
// in the future: print the status of the blocked semaphores!
 
}
#endif
 
static int PC_res_register(RLEVEL l, PID p, RES_MODEL *r)
{
PC_mutex_resource_des *m = (PC_mutex_resource_des *)(resource_table[l]);
PC_RES_MODEL *pc;
 
static int PC_level_accept_resource_model(RLEVEL l, RES_MODEL *r)
{
if (r->rclass == PC_RCLASS || r->rclass == (PC_RCLASS | l) )
return 0;
else
if (r->rclass != PC_RCLASS)
return -1;
}
if (r->level && r->level !=l)
return -1;
 
static void PC_res_register(RLEVEL l, PID p, RES_MODEL *r)
{
PC_mutex_resource_des *m = (PC_mutex_resource_des *)(resource_table[l]);
PC_RES_MODEL *pc = (PC_RES_MODEL *)r;
pc = (PC_RES_MODEL *)r;
 
m->priority[p] = pc->priority;
m->nlocked[p] = 0;
 
return 0;
}
 
static void PC_res_detach(RLEVEL l, PID p)
203,18 → 203,13
m->priority[p] = MAX_DWORD;
}
 
static int PC_level_accept_mutexattr(RLEVEL l, const mutexattr_t *a)
{
if (a->mclass == PC_MCLASS || a->mclass == (PC_MCLASS | l) )
return 0;
else
return -1;
}
 
static int PC_init(RLEVEL l, mutex_t *m, const mutexattr_t *a)
{
PC_mutex_t *p;
 
if (a->mclass != PC_MCLASS)
return -1;
 
p = (PC_mutex_t *) kern_alloc(sizeof(PC_mutex_t));
 
/* control if there is enough memory; no control on init on a
403,7 → 398,7
return 0;
}
 
void PC_register_module(void)
RLEVEL PC_register_module(void)
{
RLEVEL l; /* the level that we register */
PC_mutex_resource_des *m; /* for readableness only */
421,20 → 416,11
resource_table[l] = (resource_des *)m;
 
/* fill the resource_des descriptor */
strncpy(m->m.r.res_name, PC_MODULENAME, MAX_MODULENAME);
m->m.r.res_code = PC_MODULE_CODE;
m->m.r.res_version = PC_MODULE_VERSION;
 
m->m.r.rtype = MUTEX_RTYPE;
 
m->m.r.resource_status = PC_resource_status;
m->m.r.level_accept_resource_model = PC_level_accept_resource_model;
m->m.r.res_register = PC_res_register;
 
m->m.r.res_detach = PC_res_detach;
 
/* fill the mutex_resource_des descriptor */
m->m.level_accept_mutexattr = PC_level_accept_mutexattr;
m->m.init = PC_init;
m->m.destroy = PC_destroy;
m->m.lock = PC_lock;
447,6 → 433,8
 
m->mlist = NULL;
 
return l;
 
}
 
/*+ This function gets the ceiling of a PC mutex, and it have to be called
461,11 → 449,6
 
r = resource_table[mutex->mutexlevel];
 
if (r->rtype != MUTEX_RTYPE ||
r->res_code != PC_MODULE_CODE ||
r->res_version != PC_MODULE_VERSION)
return -1;
 
if (ceiling)
*ceiling = ((PC_mutex_t *)mutex->opt)->ceiling;
else
486,11 → 469,6
 
r = resource_table[mutex->mutexlevel];
 
if (r->rtype != MUTEX_RTYPE ||
r->res_code != PC_MODULE_CODE ||
r->res_version != PC_MODULE_VERSION)
return -1;
 
if (old_ceiling)
*old_ceiling = ((PC_mutex_t *)mutex->opt)->ceiling;