Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 228 → Rev 317

/shark/trunk/kernel/modules/pc.c
20,11 → 20,11
 
/**
------------
CVS : $Id: pc.c,v 1.3 2003-09-12 10:10:41 giacomo Exp $
CVS : $Id: pc.c,v 1.4 2003-11-05 15:04:14 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.3 $
Last update: $Date: 2003-09-12 10:10:41 $
Revision: $Revision: 1.4 $
Last update: $Date: 2003-11-05 15:04:14 $
------------
 
Priority Ceiling protocol. see pc.h for more details...
236,16 → 236,17
static int PC_destroy(RLEVEL l, mutex_t *m)
{
// PC_mutex_resource_des *lev = (PC_mutex_resource_des *)(resource_table[l]);
SYS_FLAGS f;
 
if ( ((PC_mutex_t *)m->opt)->nblocked)
return (EBUSY);
 
kern_cli();
f = kern_fsave();
if (m->opt) {
kern_free(m->opt,sizeof(PC_mutex_t));
m->opt = NULL;
}
kern_sti();
kern_frestore(f);
 
return 0;
}
255,25 → 256,26
{
PC_mutex_resource_des *lev = (PC_mutex_resource_des *)(resource_table[l]);
PC_mutex_t *p;
SYS_FLAGS f;
 
kern_cli();
f = kern_fsave();
 
p = (PC_mutex_t *)m->opt;
if (!p) {
/* if the mutex is not initialized, return an error! */
kern_sti();
kern_frestore(f);
return (EINVAL);
}
 
if (p->owner == exec_shadow) {
/* the task already owns the mutex */
kern_sti();
kern_frestore(f);
return (EDEADLK);
}
 
if (p->ceiling > lev->priority[exec_shadow]) {
/* see POSIX standard p. 258 */
kern_sti();
kern_frestore(f);
return (EINVAL);
}
 
295,7 → 297,7
kern_context_load(proc_table[exec_shadow].context);
 
/* ... and reaquire the cli() before the test... */
kern_cli();
f = kern_fsave();
}
 
/* the mutex is free, We can lock it! */
306,7 → 308,7
 
PC_insert(lev, p);
 
kern_sti();
kern_frestore(f);
 
return 0;
}
315,31 → 317,32
{
PC_mutex_resource_des *lev = (PC_mutex_resource_des *)(resource_table[l]);
PC_mutex_t *p;
SYS_FLAGS f;
 
kern_cli();
f = kern_fsave();
 
p = (PC_mutex_t *)m->opt;
if (!p) {
/* if the mutex is not initialized, return an error! */
kern_sti();
kern_frestore(f);
return (EINVAL);
}
 
if (p->owner == exec_shadow) {
/* the task already owns the mutex */
kern_sti();
kern_frestore(f);
return (EDEADLK);
}
 
if (p->ceiling < lev->priority[exec_shadow]) {
/* see POSIX standard p. 258 */
kern_sti();
kern_frestore(f);
return (EINVAL);
}
 
while (!PC_accept(lev, lev->priority[exec_shadow])) {
/* a task already owns the mutex */
kern_sti();
kern_frestore(f);
return (EBUSY);
}
 
351,7 → 354,7
 
PC_insert(lev, p);
 
kern_sti();
kern_frestore(f);
 
return 0;
}
368,7 → 371,6
 
if (p->owner != exec_shadow) {
/* the mutex is owned by another task!!! */
kern_sti();
return (EPERM);
}