diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 14:59:30 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 16:17:00 +0200 |
commit | 62c528e633758302f30aa714838b51613f03f9e7 (patch) | |
tree | dda69197e96e7cb301e8a71556821437439b76b1 /cpukit/rtems/src/semobtain.c | |
parent | rtems: _Message_queue_Get_interrupt_disable() (diff) | |
download | rtems-62c528e633758302f30aa714838b51613f03f9e7.tar.bz2 |
rtems: _Semaphore_Get_interrupt_disable()
Use _Objects_Get_local() for _Semaphore_Get_interrupt_disable() to get
rid of the location parameter. Move remote object handling to semaphore
MPCI support.
Diffstat (limited to 'cpukit/rtems/src/semobtain.c')
-rw-r--r-- | cpukit/rtems/src/semobtain.c | 126 |
1 files changed, 52 insertions, 74 deletions
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c index e3d6f3c20d..b3dcd3c96c 100644 --- a/cpukit/rtems/src/semobtain.c +++ b/cpukit/rtems/src/semobtain.c @@ -18,18 +18,10 @@ #include "config.h" #endif -#include <rtems/system.h> -#include <rtems/rtems/status.h> -#include <rtems/rtems/support.h> -#include <rtems/rtems/attrimpl.h> -#include <rtems/score/isr.h> -#include <rtems/rtems/optionsimpl.h> #include <rtems/rtems/semimpl.h> -#include <rtems/score/coremuteximpl.h> -#include <rtems/score/coresemimpl.h> #include <rtems/score/threadimpl.h> - -#include <rtems/score/interr.h> +#include <rtems/rtems/attrimpl.h> +#include <rtems/rtems/optionsimpl.h> THREAD_WAIT_QUEUE_OBJECT_ASSERT( Semaphore_Control, @@ -47,76 +39,62 @@ rtems_status_code rtems_semaphore_obtain( rtems_interval timeout ) { - Semaphore_Control *the_semaphore; - Objects_Locations location; - ISR_lock_Context lock_context; - Thread_Control *executing; - rtems_attribute attribute_set; - bool wait; - - the_semaphore = _Semaphore_Get_interrupt_disable( - id, - &location, - &lock_context - ); - switch ( location ) { - - case OBJECTS_LOCAL: - executing = _Thread_Executing; - attribute_set = the_semaphore->attribute_set; - wait = !_Options_Is_no_wait( option_set ); -#if defined(RTEMS_SMP) - if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { - MRSP_Status mrsp_status; - - mrsp_status = _MRSP_Seize( - &the_semaphore->Core_control.mrsp, - executing, - wait, - timeout, - &lock_context - ); - return _Semaphore_Translate_MRSP_status_code( mrsp_status ); - } else -#endif - if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) { - _CORE_mutex_Seize( - &the_semaphore->Core_control.mutex, - executing, - wait, - timeout, - &lock_context - ); - return _Semaphore_Translate_core_mutex_return_code( - executing->Wait.return_code ); - } + Semaphore_Control *the_semaphore; + ISR_lock_Context lock_context; + Thread_Control *executing; + rtems_attribute attribute_set; + bool wait; - /* must be a counting semaphore */ - _CORE_semaphore_Seize( - &the_semaphore->Core_control.semaphore, - executing, - id, - wait, - timeout, - &lock_context - ); - return _Semaphore_Translate_core_semaphore_return_code( - executing->Wait.return_code ); + the_semaphore = _Semaphore_Get_interrupt_disable( id, &lock_context ); + if ( the_semaphore == NULL ) { #if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: - return _Semaphore_MP_Send_request_packet( - SEMAPHORE_MP_OBTAIN_REQUEST, - id, - option_set, - timeout - ); + _Semaphore_MP_Obtain( id, option_set, timeout ); +#else + return RTEMS_INVALID_ID; #endif + } - case OBJECTS_ERROR: - break; + executing = _Thread_Executing; + attribute_set = the_semaphore->attribute_set; + wait = !_Options_Is_no_wait( option_set ); +#if defined(RTEMS_SMP) + if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { + MRSP_Status mrsp_status; + mrsp_status = _MRSP_Seize( + &the_semaphore->Core_control.mrsp, + executing, + wait, + timeout, + &lock_context + ); + return _Semaphore_Translate_MRSP_status_code( mrsp_status ); + } else +#endif + if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) { + _CORE_mutex_Seize( + &the_semaphore->Core_control.mutex, + executing, + wait, + timeout, + &lock_context + ); + return _Semaphore_Translate_core_mutex_return_code( + executing->Wait.return_code + ); } - return RTEMS_INVALID_ID; + /* must be a counting semaphore */ + _CORE_semaphore_Seize( + &the_semaphore->Core_control.semaphore, + executing, + id, + wait, + timeout, + &lock_context + ); + return _Semaphore_Translate_core_semaphore_return_code( + executing->Wait.return_code + ); } |