diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 21:39:56 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-30 16:16:21 +0200 |
commit | 2581a563f9182dc2debdba97f33feee6d797e53a (patch) | |
tree | 97883371771f9a2905d159d8e11c0b2e9da0408c /cpukit/rtems/src/semobtain.c | |
parent | rtems: Simplify rtems_semaphore_delete() (diff) | |
download | rtems-2581a563f9182dc2debdba97f33feee6d797e53a.tar.bz2 |
score: Add semaphore variants
Diffstat (limited to 'cpukit/rtems/src/semobtain.c')
-rw-r--r-- | cpukit/rtems/src/semobtain.c | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c index 8cb195c5a2..93591b87c6 100644 --- a/cpukit/rtems/src/semobtain.c +++ b/cpukit/rtems/src/semobtain.c @@ -19,7 +19,6 @@ #endif #include <rtems/rtems/semimpl.h> -#include <rtems/rtems/attrimpl.h> #include <rtems/rtems/optionsimpl.h> #include <rtems/rtems/statusimpl.h> @@ -54,7 +53,6 @@ rtems_status_code rtems_semaphore_obtain( Semaphore_Control *the_semaphore; Thread_queue_Context queue_context; Thread_Control *executing; - rtems_attribute attribute_set; bool wait; Status_Control status; @@ -69,36 +67,40 @@ rtems_status_code rtems_semaphore_obtain( } executing = _Thread_Executing; - attribute_set = the_semaphore->attribute_set; wait = !_Options_Is_no_wait( option_set ); + + switch ( the_semaphore->variant ) { #if defined(RTEMS_SMP) - if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { - status = _MRSP_Seize( - &the_semaphore->Core_control.mrsp, - executing, - wait, - timeout, - &queue_context - ); - } else + case SEMAPHORE_VARIANT_MRSP: + status = _MRSP_Seize( + &the_semaphore->Core_control.mrsp, + executing, + wait, + timeout, + &queue_context + ); + break; #endif - if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) { - status = _CORE_mutex_Seize( - &the_semaphore->Core_control.mutex, - executing, - wait, - timeout, - &queue_context - ); - } else { - /* must be a counting semaphore */ - status = _CORE_semaphore_Seize( - &the_semaphore->Core_control.semaphore, - executing, - wait, - timeout, - &queue_context - ); + case SEMAPHORE_VARIANT_MUTEX: + status = _CORE_mutex_Seize( + &the_semaphore->Core_control.mutex, + executing, + wait, + timeout, + &queue_context + ); + break; + default: + _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING ); + status = _CORE_semaphore_Seize( + &the_semaphore->Core_control.semaphore, + _Semaphore_Get_operations( the_semaphore ), + executing, + wait, + timeout, + &queue_context + ); + break; } return _Status_Get( status ); |