File indexing completed on 2025-05-11 08:24:26
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/score/chain.h>
0043 #include <rtems/score/isr.h>
0044 #include <rtems/score/coremsgimpl.h>
0045 #include <rtems/score/threadimpl.h>
0046 #include <rtems/score/statesimpl.h>
0047
0048 Status_Control _CORE_message_queue_Seize(
0049 CORE_message_queue_Control *the_message_queue,
0050 Thread_Control *executing,
0051 void *buffer,
0052 size_t *size_p,
0053 bool wait,
0054 Thread_queue_Context *queue_context
0055 )
0056 {
0057 CORE_message_queue_Buffer *the_message;
0058
0059 the_message = _CORE_message_queue_Get_pending_message( the_message_queue );
0060 if ( the_message != NULL ) {
0061 the_message_queue->number_of_pending_messages -= 1;
0062
0063 *size_p = the_message->size;
0064 executing->Wait.count =
0065 _CORE_message_queue_Get_message_priority( the_message );
0066 _CORE_message_queue_Copy_buffer( the_message->buffer, buffer, *size_p );
0067
0068 #if !defined(RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND)
0069
0070
0071
0072
0073 _CORE_message_queue_Free_message_buffer(the_message_queue, the_message);
0074 _CORE_message_queue_Release( the_message_queue, queue_context );
0075 return STATUS_SUCCESSFUL;
0076 #else
0077 {
0078 Thread_queue_Heads *heads;
0079 Thread_Control *the_thread;
0080
0081
0082
0083
0084
0085
0086
0087
0088 heads = the_message_queue->Wait_queue.Queue.heads;
0089 if ( heads == NULL ) {
0090 _CORE_message_queue_Free_message_buffer(
0091 the_message_queue,
0092 the_message
0093 );
0094 _CORE_message_queue_Release( the_message_queue, queue_context );
0095 return STATUS_SUCCESSFUL;
0096 }
0097
0098 the_thread = ( *the_message_queue->operations->surrender )(
0099 &the_message_queue->Wait_queue.Queue,
0100 heads,
0101 NULL,
0102 queue_context
0103 );
0104
0105
0106
0107
0108
0109
0110 _CORE_message_queue_Insert_message(
0111 the_message_queue,
0112 the_message,
0113 the_thread->Wait.return_argument_second.immutable_object,
0114 (size_t) the_thread->Wait.option,
0115 (CORE_message_queue_Submit_types) the_thread->Wait.count
0116 );
0117 _Thread_queue_Resume(
0118 &the_message_queue->Wait_queue.Queue,
0119 the_thread,
0120 queue_context
0121 );
0122 return STATUS_SUCCESSFUL;
0123 }
0124 #endif
0125 }
0126
0127 if ( !wait ) {
0128 _CORE_message_queue_Release( the_message_queue, queue_context );
0129 return STATUS_UNSATISFIED;
0130 }
0131
0132 executing->Wait.return_argument_second.mutable_object = buffer;
0133 executing->Wait.return_argument = size_p;
0134
0135
0136 _Thread_queue_Context_set_thread_state(
0137 queue_context,
0138 STATES_WAITING_FOR_MESSAGE
0139 );
0140 _Thread_queue_Enqueue(
0141 &the_message_queue->Wait_queue.Queue,
0142 the_message_queue->operations,
0143 executing,
0144 queue_context
0145 );
0146 return _Thread_Wait_get_status( executing );
0147 }