[PATCH 3/3] score: Add barrier thread queue operations

Gedare Bloom gedare at rtems.org
Fri Feb 5 17:16:24 UTC 2021


On Fri, Feb 5, 2021 at 6:37 AM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> This fixes a missing decrement of the number of waiting threads during a
> barrier wait timeout.
>
> Close #4230.
>
Is this bug a problem that should be fixed on any open branch(es)?

Otherwise, the 3 patches look good.

---
>  cpukit/include/rtems/score/corebarrierimpl.h |  4 ++-
>  cpukit/score/src/corebarrierrelease.c        |  1 -
>  cpukit/score/src/corebarrierwait.c           | 30 ++++++++++++++++++++
>  3 files changed, 33 insertions(+), 2 deletions(-)
>
> diff --git a/cpukit/include/rtems/score/corebarrierimpl.h
> b/cpukit/include/rtems/score/corebarrierimpl.h
> index c2dfea8f9b..2317d748c1 100644
> --- a/cpukit/include/rtems/score/corebarrierimpl.h
> +++ b/cpukit/include/rtems/score/corebarrierimpl.h
> @@ -33,7 +33,9 @@ extern "C" {
>   * @{
>   */
>
> -#define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
> +extern const Thread_queue_Operations
> _CORE_barrier_Thread_queue_operations;
> +
> +#define CORE_BARRIER_TQ_OPERATIONS &_CORE_barrier_Thread_queue_operations
>
>  /**
>   *  @brief Initializes the core barrier.
> diff --git a/cpukit/score/src/corebarrierrelease.c
> b/cpukit/score/src/corebarrierrelease.c
> index 5d510107d6..1f03b24bac 100644
> --- a/cpukit/score/src/corebarrierrelease.c
> +++ b/cpukit/score/src/corebarrierrelease.c
> @@ -28,7 +28,6 @@ uint32_t _CORE_barrier_Do_flush(
>    Thread_queue_Context      *queue_context
>  )
>  {
> -  the_barrier->number_of_waiting_threads = 0;
>    return _Thread_queue_Flush_critical(
>      &the_barrier->Wait_queue.Queue,
>      CORE_BARRIER_TQ_OPERATIONS,
> diff --git a/cpukit/score/src/corebarrierwait.c
> b/cpukit/score/src/corebarrierwait.c
> index 3da9b05953..7651e20737 100644
> --- a/cpukit/score/src/corebarrierwait.c
> +++ b/cpukit/score/src/corebarrierwait.c
> @@ -23,6 +23,36 @@
>  #include <rtems/score/corebarrierimpl.h>
>  #include <rtems/score/statesimpl.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(
>    CORE_barrier_Control *the_barrier,
> --
> 2.26.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210205/73a79da0/attachment.html>


More information about the devel mailing list