diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-12-13 15:29:20 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-12-13 15:29:20 +0000 |
commit | 7d91d722baf1f1ff275fd31500526bb2fd6df632 (patch) | |
tree | 4200d45e53e783ea350265ba4267083b51566523 /c/src/exec/score/src/coremutexsurrender.c | |
parent | Corrected order of output. (diff) | |
download | rtems-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.c | 31 |
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; |