[PATCH] mrsp: Change error status for a nested seize

Gedare Bloom gedare at rtems.org
Wed Jan 20 15:57:09 UTC 2021


seems good

On Wed, Jan 20, 2021 at 2:36 AM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> Return STATUS_DEADLOCK (RTEMS_INCORRECT_STATE) to indicate a nested
> seize since this is a kind of deadlock.  This status code is also used
> for other deadlocks.
>
> Update #4217.
> ---
>  cpukit/include/rtems/score/mrspimpl.h | 30 +++++++++++++++++----------
>  testsuites/smptests/smpmrsp01/init.c  |  2 +-
>  2 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/cpukit/include/rtems/score/mrspimpl.h
> b/cpukit/include/rtems/score/mrspimpl.h
> index be4a934436..4af7d0311d 100644
> --- a/cpukit/include/rtems/score/mrspimpl.h
> +++ b/cpukit/include/rtems/score/mrspimpl.h
> @@ -391,18 +391,26 @@ RTEMS_INLINE_ROUTINE Status_Control
> _MRSP_Wait_for_ownership(
>  }
>
>  /**
> - * @brief Seizes the MrsP control.
> + * @brief Seizes the MrsP mutex.
>   *
> - * @param[in, out] mrsp The MrsP control to seize the control of.
> - * @param[in, out] executing The currently executing thread.
> - * @param wait Indicates whether the calling thread is willing to wait.
> - * @param queue_context The thread queue context.
> + * @param[in, out] mrsp is the MrsP mutex to seize.
>   *
> - * @retval STATUS_SUCCESSFUL The operation succeeded.
> - * @retval STATUS_MUTEX_CEILING_VIOLATED The wait priority of the
> executing
> - *      thread exceeds the ceiling priority.
> - * @retval STATUS_UNAVAILABLE The executing thread is already the owner of
> - *      the MrsP control.  Seizing it is not possible.
> + * @param[in, out] executing is the currently executing thread.
> + *
> + * @param wait shall be true, if the executing thread is willing to wait,
> + *   otherwise it shall be false.
> + *
> + * @param[in, out] queue_context is the thread queue context.
> + *
> + * @retval STATUS_SUCCESSFUL The requested operation was successful.
> + *
> + * @retval STATUS_UNAVAILABLE Seizing the mutex was not immmediately
> possible.
> + *
> + * @retval STATUS_DEADLOCK The executing thread was already the owner of
> + *   the mutex.
> + *
> + * @retval STATUS_MUTEX_CEILING_VIOLATED The current priority of the
> executing
> + *   thread exceeds the ceiling priority of the mutex.
>   */
>  RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize(
>    MRSP_Control         *mrsp,
> @@ -422,7 +430,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize(
>      status = _MRSP_Claim_ownership( mrsp, executing, queue_context );
>    } else if ( owner == executing ) {
>      _MRSP_Release( mrsp, queue_context );
> -    status = STATUS_UNAVAILABLE;
> +    status = STATUS_DEADLOCK;
>    } else if ( wait ) {
>      status = _MRSP_Wait_for_ownership( mrsp, executing, queue_context );
>    } else {
> diff --git a/testsuites/smptests/smpmrsp01/init.c
> b/testsuites/smptests/smpmrsp01/init.c
> index da3426ee00..11535763ca 100644
> --- a/testsuites/smptests/smpmrsp01/init.c
> +++ b/testsuites/smptests/smpmrsp01/init.c
> @@ -765,7 +765,7 @@ static void test_mrsp_nested_obtain_error(test_context
> *ctx)
>    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>
>    sc = rtems_semaphore_obtain(id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
> -  rtems_test_assert(sc == RTEMS_UNSATISFIED);
> +  rtems_test_assert(sc == RTEMS_INCORRECT_STATE);
>
>    sc = rtems_semaphore_release(id);
>    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> --
> 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/20210120/6bec37a8/attachment.html>


More information about the devel mailing list