20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: pi.c,v 1.2 2003-01-07 17:07:50 pj Exp $ |
CVS : $Id: pi.c,v 1.3 2003-11-05 15:04:14 giacomo Exp $ |
|
File: $File$ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-01-07 17:07:50 $ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2003-11-05 15:04:14 $ |
------------ |
|
Priority Inhertitance protocol. see pi.h for more details... |
139,16 → 139,17 |
static int PI_destroy(RLEVEL l, mutex_t *m) |
{ |
// PI_mutex_resource_des *lev = (PI_mutex_resource_des *)(resource_table[l]); |
|
SYS_FLAGS f; |
|
if ( ((PI_mutex_t *)m->opt)->nblocked) |
return (EBUSY); |
|
kern_cli(); |
f = kern_fsave(); |
if (m->opt) { |
kern_free(m->opt,sizeof(PI_mutex_t)); |
m->opt = NULL; |
} |
kern_sti(); |
kern_frestore(f); |
|
return 0; |
} |
166,9 → 167,11 |
{ |
PI_mutex_resource_des *lev = (PI_mutex_resource_des *)(resource_table[l]); |
PI_mutex_t *p; |
SYS_FLAGS f; |
// return 0; |
kern_cli(); |
|
f = kern_fsave(); |
|
p = (PI_mutex_t *)m->opt; |
if (!p) { |
/* if the mutex is not initialized, initialize it! */ |
180,7 → 183,7 |
|
if (p->owner == exec_shadow) { |
/* the task already owns the mutex */ |
kern_sti(); |
kern_frestore(f); |
return (EDEADLK); |
} |
|
196,7 → 199,7 |
kern_context_load(proc_table[exec_shadow].context); |
|
/* ... and reaquire the cli() before the test... */ |
kern_cli(); |
kern_frestore(f); |
} |
|
/* the mutex is free, We can lock it! */ |
204,7 → 207,7 |
|
p->owner = exec_shadow; |
|
kern_sti(); |
kern_frestore(f); |
|
return 0; |
} |
212,8 → 215,9 |
static int PI_trylock(RLEVEL l, mutex_t *m) |
{ |
PI_mutex_t *p; |
SYS_FLAGS f; |
|
kern_cli(); |
f = kern_fsave(); |
|
p = (PI_mutex_t *)m->opt; |
if (!p) { |
225,7 → 229,7 |
|
if (p->owner != NIL) { |
/* a task already owns the mutex */ |
kern_sti(); |
kern_frestore(f); |
return (EBUSY); |
} |
else { |
235,7 → 239,7 |
|
p->owner = exec_shadow; |
|
kern_sti(); |
kern_frestore(f); |
return 0; |
} |
} |
245,6 → 249,7 |
PI_mutex_resource_des *lev; |
PI_mutex_t *p; |
int i, j; |
|
// return 0; |
p = (PI_mutex_t *)m->opt; |
if (!p) |
252,7 → 257,6 |
|
if (p->owner != exec_shadow) { |
/* the mutex is owned by another task!!! */ |
kern_sti(); |
return (EPERM); |
} |
|