20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: nop.c,v 1.3 2003-01-07 17:07:50 pj Exp $ |
CVS : $Id: nop.c,v 1.4 2003-11-05 15:04:14 giacomo Exp $ |
|
File: $File$ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2003-01-07 17:07:50 $ |
Revision: $Revision: 1.4 $ |
Last update: $Date: 2003-11-05 15:04:14 $ |
------------ |
|
Binary Semaphores. see nop.h for more details... |
116,16 → 116,17 |
static int NOP_destroy(RLEVEL l, mutex_t *m) |
{ |
// NOP_mutex_resource_des *lev = (NOP_mutex_resource_des *)(resource_table[l]); |
SYS_FLAGS f; |
|
if ( ((NOP_mutex_t *)m->opt)->owner != NIL) |
return (EBUSY); |
|
kern_cli(); |
f = kern_fsave(); |
if (m->opt) { |
kern_free(m->opt,sizeof(NOP_mutex_t)); |
m->opt = NULL; |
} |
kern_sti(); |
kern_frestore(f); |
|
return 0; |
} |
133,8 → 134,9 |
static int NOP_lock(RLEVEL l, mutex_t *m) |
{ |
NOP_mutex_t *p; |
SYS_FLAGS f; |
|
kern_cli(); |
f = kern_fsave(); |
|
p = (NOP_mutex_t *)m->opt; |
if (!p) { |
146,7 → 148,7 |
|
if (p->owner == exec_shadow) { |
/* the task already owns the mutex */ |
kern_sti(); |
kern_frestore(f); |
return (EDEADLK); |
} |
|
171,7 → 173,7 |
else { |
/* the mutex is free, We can lock it! */ |
p->owner = exec_shadow; |
kern_sti(); |
kern_frestore(f); |
} |
|
return 0; |
180,8 → 182,9 |
static int NOP_trylock(RLEVEL l, mutex_t *m) |
{ |
NOP_mutex_t *p; |
SYS_FLAGS f; |
|
kern_cli(); |
f = kern_fsave(); |
|
p = (NOP_mutex_t *)m->opt; |
if (!p) { |
193,13 → 196,13 |
|
if (p->owner != NIL) { |
/* a task already owns the mutex */ |
kern_sti(); |
kern_frestore(f); |
return (EBUSY); |
} |
else { |
/* the mutex is free, We can lock it! */ |
p->owner = exec_shadow; |
kern_sti(); |
kern_frestore(f); |
} |
|
return 0; |
215,7 → 218,6 |
|
if (p->owner != exec_shadow) { |
/* the mutex is owned by another task!!! */ |
kern_sti(); |
return (EPERM); |
} |
|