From d9249c9bffe4238e3853996d1f0758d9f55fbe67 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 31 Aug 2021 11:03:57 +0200 Subject: score: Fix blocking message queue receive In order to ensure FIFO fairness across schedulers, the thread queue surrender operation must be used to dequeue a thread from the thread queue. The thread queue extract operation is intended for timeouts. Add _Thread_queue_Resume() which may be used to make extracted or surrendered threads ready again. Remove the now unused _Thread_queue_Extract_critical() function. Close #4509. --- cpukit/include/rtems/score/coremsgimpl.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'cpukit/include/rtems/score/coremsgimpl.h') diff --git a/cpukit/include/rtems/score/coremsgimpl.h b/cpukit/include/rtems/score/coremsgimpl.h index 161cf8f124..7f01769010 100644 --- a/cpukit/include/rtems/score/coremsgimpl.h +++ b/cpukit/include/rtems/score/coremsgimpl.h @@ -616,7 +616,8 @@ RTEMS_INLINE_ROUTINE Thread_Control *_CORE_message_queue_Dequeue_receiver( Thread_queue_Context *queue_context ) { - Thread_Control *the_thread; + Thread_queue_Heads *heads; + Thread_Control *the_thread; /* * If there are pending messages, then there can't be threads @@ -634,14 +635,18 @@ RTEMS_INLINE_ROUTINE Thread_Control *_CORE_message_queue_Dequeue_receiver( * There must be no pending messages if there is a thread waiting to * receive a message. */ - the_thread = _Thread_queue_First_locked( - &the_message_queue->Wait_queue, - the_message_queue->operations - ); - if ( the_thread == NULL ) { + heads = the_message_queue->Wait_queue.Queue.heads; + if ( heads == NULL ) { return NULL; } + the_thread = ( *the_message_queue->operations->surrender )( + &the_message_queue->Wait_queue.Queue, + heads, + NULL, + queue_context + ); + *(size_t *) the_thread->Wait.return_argument = size; the_thread->Wait.count = (uint32_t) submit_type; @@ -651,9 +656,8 @@ RTEMS_INLINE_ROUTINE Thread_Control *_CORE_message_queue_Dequeue_receiver( size ); - _Thread_queue_Extract_critical( + _Thread_queue_Resume( &the_message_queue->Wait_queue.Queue, - the_message_queue->operations, the_thread, queue_context ); -- cgit v1.2.3