[rtems commit] mrsp: Change error status for a nested seize
Sebastian Huber
sebh at rtems.org
Thu Jan 21 09:11:07 UTC 2021
Module: rtems
Branch: master
Commit: 8ee22b29751f7bd984f06695a6db0667757bcd07
Changeset: http://git.rtems.org/rtems/commit/?id=8ee22b29751f7bd984f06695a6db0667757bcd07
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Jan 20 10:31:18 2021 +0100
mrsp: Change error status for a nested seize
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 be4a934..4af7d03 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 da3426e..1153576 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);
More information about the vc
mailing list