summaryrefslogtreecommitdiffstats
path: root/c/src/exec/score/src/coremutexsurrender.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-12-13 15:29:20 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-12-13 15:29:20 +0000
commit7d91d722baf1f1ff275fd31500526bb2fd6df632 (patch)
tree4200d45e53e783ea350265ba4267083b51566523 /c/src/exec/score/src/coremutexsurrender.c
parentCorrected order of output. (diff)
downloadrtems-7d91d722baf1f1ff275fd31500526bb2fd6df632.tar.bz2
First attempt at adding simple binary semaphore in addition to the current
"mutex" and counting semaphore. This is at the request of Eric Norum and his EPICS porting effort.
Diffstat (limited to 'c/src/exec/score/src/coremutexsurrender.c')
-rw-r--r--c/src/exec/score/src/coremutexsurrender.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/c/src/exec/score/src/coremutexsurrender.c b/c/src/exec/score/src/coremutexsurrender.c
index fbd75fd8e8..7f5fc2e911 100644
--- a/c/src/exec/score/src/coremutexsurrender.c
+++ b/c/src/exec/score/src/coremutexsurrender.c
@@ -61,24 +61,31 @@ CORE_mutex_Status _CORE_mutex_Surrender(
* must be released by the thread which acquired them.
*/
- if ( !_Objects_Are_ids_equal(
- _Thread_Executing->Object.id, the_mutex->holder_id ) ) {
-
- switch ( the_mutex->Attributes.discipline ) {
- case CORE_MUTEX_DISCIPLINES_FIFO:
- case CORE_MUTEX_DISCIPLINES_PRIORITY:
- break;
- case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
- case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
- return( CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE );
- break;
+ if ( the_mutex->Attributes.allow_nesting ) {
+ if ( !_Objects_Are_ids_equal(
+ _Thread_Executing->Object.id, the_mutex->holder_id ) ) {
+
+ switch ( the_mutex->Attributes.discipline ) {
+ case CORE_MUTEX_DISCIPLINES_FIFO:
+ case CORE_MUTEX_DISCIPLINES_PRIORITY:
+ break;
+ case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
+ case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
+ return( CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE );
+ break;
+ }
}
}
+ /* XXX already unlocked -- not right status */
+
+ if ( !the_mutex->nest_count )
+ return( CORE_MUTEX_STATUS_SUCCESSFUL );
+
the_mutex->nest_count--;
if ( the_mutex->nest_count != 0 )
- return( CORE_MUTEX_STATUS_SUCCESSFUL );
+ return( CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED );
_Thread_Executing->resource_count--;
the_mutex->holder = NULL;