File indexing completed on 2025-05-11 08:24:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #ifdef HAVE_CONFIG_H
0039 #include "config.h"
0040 #endif
0041
0042 #include <rtems/rtems/semimpl.h>
0043
0044 rtems_status_code rtems_semaphore_flush( rtems_id id )
0045 {
0046 Semaphore_Control *the_semaphore;
0047 Thread_queue_Context queue_context;
0048 uintptr_t flags;
0049 Semaphore_Variant variant;
0050
0051 the_semaphore = _Semaphore_Get( id, &queue_context );
0052
0053 if ( the_semaphore == NULL ) {
0054 #if defined(RTEMS_MULTIPROCESSING)
0055 if ( _Semaphore_MP_Is_remote( id ) ) {
0056 return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
0057 }
0058 #endif
0059
0060 return RTEMS_INVALID_ID;
0061 }
0062
0063 _Thread_queue_Acquire_critical(
0064 &the_semaphore->Core_control.Wait_queue,
0065 &queue_context
0066 );
0067 _Thread_queue_Context_set_MP_callout(
0068 &queue_context,
0069 _Semaphore_MP_Send_object_was_deleted
0070 );
0071 flags = _Semaphore_Get_flags( the_semaphore );
0072 variant = _Semaphore_Get_variant( flags );
0073
0074 switch ( variant ) {
0075 #if defined(RTEMS_SMP)
0076 case SEMAPHORE_VARIANT_MRSP:
0077 _Thread_queue_Release(
0078 &the_semaphore->Core_control.Wait_queue,
0079 &queue_context
0080 );
0081 return RTEMS_NOT_DEFINED;
0082 #endif
0083 default:
0084 _Assert(
0085 variant == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY
0086 || variant == SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING
0087 || variant == SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL
0088 || variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
0089 || variant == SEMAPHORE_VARIANT_COUNTING
0090 );
0091 _Thread_queue_Flush_critical(
0092 &the_semaphore->Core_control.Wait_queue.Queue,
0093 _Semaphore_Get_operations( flags ),
0094 _Thread_queue_Flush_status_unavailable,
0095 &queue_context
0096 );
0097 break;
0098 }
0099
0100 return RTEMS_SUCCESSFUL;
0101 }