mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
score: Add barrier thread queue operations
This fixes a missing decrement of the number of waiting threads during a barrier wait timeout. Close #4230.
This commit is contained in:
@@ -33,7 +33,14 @@ extern "C" {
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
|
/**
|
||||||
|
* @brief These thread queue operations are used for core barriers.
|
||||||
|
*
|
||||||
|
* They are a specialization of ::_Thread_queue_Operations_FIFO. The only
|
||||||
|
* difference is that the extract operation decrements
|
||||||
|
* CORE_barrier_Control::number_of_waiting_threads.
|
||||||
|
*/
|
||||||
|
extern const Thread_queue_Operations _CORE_barrier_Thread_queue_operations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the core barrier.
|
* @brief Initializes the core barrier.
|
||||||
|
|||||||
@@ -28,10 +28,9 @@ uint32_t _CORE_barrier_Do_flush(
|
|||||||
Thread_queue_Context *queue_context
|
Thread_queue_Context *queue_context
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
the_barrier->number_of_waiting_threads = 0;
|
|
||||||
return _Thread_queue_Flush_critical(
|
return _Thread_queue_Flush_critical(
|
||||||
&the_barrier->Wait_queue.Queue,
|
&the_barrier->Wait_queue.Queue,
|
||||||
CORE_BARRIER_TQ_OPERATIONS,
|
&_CORE_barrier_Thread_queue_operations,
|
||||||
filter,
|
filter,
|
||||||
queue_context
|
queue_context
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,6 +23,36 @@
|
|||||||
#include <rtems/score/corebarrierimpl.h>
|
#include <rtems/score/corebarrierimpl.h>
|
||||||
#include <rtems/score/statesimpl.h>
|
#include <rtems/score/statesimpl.h>
|
||||||
#include <rtems/score/threadimpl.h>
|
#include <rtems/score/threadimpl.h>
|
||||||
|
#include <rtems/score/threadqops.h>
|
||||||
|
|
||||||
|
static void _CORE_barrier_Thread_queue_extract(
|
||||||
|
Thread_queue_Queue *queue,
|
||||||
|
Thread_Control *the_thread,
|
||||||
|
Thread_queue_Context *queue_context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CORE_barrier_Control *the_barrier;
|
||||||
|
|
||||||
|
the_barrier = RTEMS_CONTAINER_OF(
|
||||||
|
queue,
|
||||||
|
CORE_barrier_Control,
|
||||||
|
Wait_queue.Queue
|
||||||
|
);
|
||||||
|
--the_barrier->number_of_waiting_threads;
|
||||||
|
_Thread_queue_FIFO_extract(
|
||||||
|
&the_barrier->Wait_queue.Queue,
|
||||||
|
the_thread,
|
||||||
|
queue_context
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Thread_queue_Operations _CORE_barrier_Thread_queue_operations = {
|
||||||
|
.priority_actions = _Thread_queue_Do_nothing_priority_actions,
|
||||||
|
.enqueue = _Thread_queue_FIFO_enqueue,
|
||||||
|
.extract = _CORE_barrier_Thread_queue_extract,
|
||||||
|
.surrender = _Thread_queue_FIFO_surrender,
|
||||||
|
.first = _Thread_queue_FIFO_first
|
||||||
|
};
|
||||||
|
|
||||||
Status_Control _CORE_barrier_Seize(
|
Status_Control _CORE_barrier_Seize(
|
||||||
CORE_barrier_Control *the_barrier,
|
CORE_barrier_Control *the_barrier,
|
||||||
@@ -52,7 +82,7 @@ Status_Control _CORE_barrier_Seize(
|
|||||||
);
|
);
|
||||||
_Thread_queue_Enqueue(
|
_Thread_queue_Enqueue(
|
||||||
&the_barrier->Wait_queue.Queue,
|
&the_barrier->Wait_queue.Queue,
|
||||||
CORE_BARRIER_TQ_OPERATIONS,
|
&_CORE_barrier_Thread_queue_operations,
|
||||||
executing,
|
executing,
|
||||||
queue_context
|
queue_context
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user