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/semflush.c | |
parent | rtems: Simplify rtems_semaphore_delete() (diff) | |
download | rtems-2581a563f9182dc2debdba97f33feee6d797e53a.tar.bz2 |
score: Add semaphore variants
Diffstat (limited to 'cpukit/rtems/src/semflush.c')
-rw-r--r-- | cpukit/rtems/src/semflush.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/cpukit/rtems/src/semflush.c b/cpukit/rtems/src/semflush.c index 07d4aa98b4..f768bbd4a7 100644 --- a/cpukit/rtems/src/semflush.c +++ b/cpukit/rtems/src/semflush.c @@ -19,13 +19,11 @@ #endif #include <rtems/rtems/semimpl.h> -#include <rtems/rtems/attrimpl.h> rtems_status_code rtems_semaphore_flush( rtems_id id ) { Semaphore_Control *the_semaphore; Thread_queue_Context queue_context; - rtems_attribute attribute_set; the_semaphore = _Semaphore_Get( id, &queue_context ); @@ -39,38 +37,40 @@ rtems_status_code rtems_semaphore_flush( rtems_id id ) return RTEMS_INVALID_ID; } - attribute_set = the_semaphore->attribute_set; - + _Thread_queue_Acquire_critical( + &the_semaphore->Core_control.Wait_queue, + &queue_context.Lock_context + ); _Thread_queue_Context_set_MP_callout( &queue_context, _Semaphore_MP_Send_object_was_deleted ); + switch ( the_semaphore->variant ) { #if defined(RTEMS_SMP) - if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { - _ISR_lock_ISR_enable( &queue_context.Lock_context ); - return RTEMS_NOT_DEFINED; - } else + case SEMAPHORE_VARIANT_MRSP: + _Thread_queue_Release( + &the_semaphore->Core_control.Wait_queue, + &queue_context.Lock_context + ); + return RTEMS_NOT_DEFINED; #endif - if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) { - _CORE_mutex_Acquire_critical( - &the_semaphore->Core_control.mutex, - &queue_context - ); - _CORE_mutex_Flush( - &the_semaphore->Core_control.mutex, - _Thread_queue_Flush_status_unavailable, - &queue_context - ); - } else { - _CORE_semaphore_Acquire_critical( - &the_semaphore->Core_control.semaphore, - &queue_context - ); - _CORE_semaphore_Flush( - &the_semaphore->Core_control.semaphore, - &queue_context - ); + case SEMAPHORE_VARIANT_MUTEX: + _CORE_mutex_Flush( + &the_semaphore->Core_control.mutex, + _Thread_queue_Flush_status_unavailable, + &queue_context + ); + break; + default: + _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING ); + _CORE_semaphore_Flush( + &the_semaphore->Core_control.semaphore, + _Semaphore_Get_operations( the_semaphore ), + &queue_context + ); + break; } + return RTEMS_SUCCESSFUL; } |