diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-21 10:21:26 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-24 09:22:36 +0100 |
commit | 3cbdf19eacf45a8e9faad284b71775a9d56872dd (patch) | |
tree | 1fe6c02e117ac4a09379da1403724d66fc97a58c /cpukit/score | |
parent | score: Remove _Objects_Open() (diff) | |
download | rtems-3cbdf19eacf45a8e9faad284b71775a9d56872dd.tar.bz2 |
score: Simplify core barrier
Use the number of threads which must arrive at the barrier to trip the
automatic release also to indicate if the barrier is a manual release
barrier.
Diffstat (limited to 'cpukit/score')
-rw-r--r-- | cpukit/score/src/corebarrier.c | 7 | ||||
-rw-r--r-- | cpukit/score/src/corebarrierwait.c | 17 |
2 files changed, 12 insertions, 12 deletions
diff --git a/cpukit/score/src/corebarrier.c b/cpukit/score/src/corebarrier.c index c9c9b04ed5..edb37d7087 100644 --- a/cpukit/score/src/corebarrier.c +++ b/cpukit/score/src/corebarrier.c @@ -23,13 +23,12 @@ #include <rtems/score/corebarrierimpl.h> void _CORE_barrier_Initialize( - CORE_barrier_Control *the_barrier, - CORE_barrier_Attributes *the_barrier_attributes + CORE_barrier_Control *the_barrier, + uint32_t maximum_count ) { - - the_barrier->Attributes = *the_barrier_attributes; the_barrier->number_of_waiting_threads = 0; + the_barrier->maximum_count = maximum_count; _Thread_queue_Object_initialize( &the_barrier->Wait_queue ); } diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c index 197e0cf405..078276bf05 100644 --- a/cpukit/score/src/corebarrierwait.c +++ b/cpukit/score/src/corebarrierwait.c @@ -61,21 +61,22 @@ Status_Control _CORE_barrier_Seize( Thread_queue_Context *queue_context ) { - uint32_t number_of_waiting_threads; + uint32_t new_number_of_waiting_threads; _CORE_barrier_Acquire_critical( the_barrier, queue_context ); - number_of_waiting_threads = the_barrier->number_of_waiting_threads; - ++number_of_waiting_threads; + /* + * In theory, this calculation can overflow. If this happens, then about 4 + * billion threads are accidentally released. Currently, the system limit + * for threads is a bit lower with three times OBJECTS_INDEX_MASK - 1. + */ + new_number_of_waiting_threads = the_barrier->number_of_waiting_threads + 1; - if ( - _CORE_barrier_Is_automatic( &the_barrier->Attributes ) - && number_of_waiting_threads == the_barrier->Attributes.maximum_count - ) { + if ( new_number_of_waiting_threads == the_barrier->maximum_count ) { _CORE_barrier_Surrender( the_barrier, queue_context ); return STATUS_BARRIER_AUTOMATICALLY_RELEASED; } else { - the_barrier->number_of_waiting_threads = number_of_waiting_threads; + the_barrier->number_of_waiting_threads = new_number_of_waiting_threads; _Thread_queue_Context_set_thread_state( queue_context, STATES_WAITING_FOR_BARRIER |