[PATCH 03/12] score: Use thread queue lock for MrsP
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri May 27 13:50:32 UTC 2016
Replace the ISR lock in MRSP_Control with a thread queue. This
simplifies the Classic semaphore implementation. Only the lock part of
the thread queue is used.
---
cpukit/rtems/src/semobtain.c | 7 +++++++
cpukit/score/include/rtems/score/mrsp.h | 15 +++++++++------
cpukit/score/include/rtems/score/mrspimpl.h | 12 ++++++++----
3 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 06c2e10..1a73120 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -33,6 +33,13 @@ THREAD_QUEUE_OBJECT_ASSERT(
Core_control.semaphore.Wait_queue
);
+#if defined(RTEMS_SMP)
+THREAD_QUEUE_OBJECT_ASSERT(
+ Semaphore_Control,
+ Core_control.mrsp.Wait_queue
+);
+#endif
+
rtems_status_code rtems_semaphore_obtain(
rtems_id id,
rtems_option option_set,
diff --git a/cpukit/score/include/rtems/score/mrsp.h b/cpukit/score/include/rtems/score/mrsp.h
index 5958848..08a2427 100644
--- a/cpukit/score/include/rtems/score/mrsp.h
+++ b/cpukit/score/include/rtems/score/mrsp.h
@@ -20,9 +20,9 @@
#if defined(RTEMS_SMP)
#include <rtems/score/chain.h>
-#include <rtems/score/isrlock.h>
#include <rtems/score/scheduler.h>
#include <rtems/score/thread.h>
+#include <rtems/score/threadq.h>
#ifdef __cplusplus
extern "C" {
@@ -115,6 +115,14 @@ typedef struct {
*/
struct MRSP_Control {
/**
+ * @brief Lock to protect the resource dependency tree.
+ *
+ * This is a thread queue since this simplifies the Classic semaphore
+ * implementation. Only the lock part of the thread queue is used.
+ */
+ Thread_queue_Control Wait_queue;
+
+ /**
* @brief Basic resource control.
*/
Resource_Control Resource;
@@ -127,11 +135,6 @@ struct MRSP_Control {
Chain_Control Rivals;
/**
- * @brief Lock to protect the resource dependency tree.
- */
- ISR_LOCK_MEMBER( Lock )
-
- /**
* @brief The initial priority of the owner before it was elevated to the
* ceiling priority.
*/
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index 5a1fcda..cdeaff3 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -24,6 +24,7 @@
#include <rtems/score/resourceimpl.h>
#include <rtems/score/schedulerimpl.h>
#include <rtems/score/status.h>
+#include <rtems/score/threadqimpl.h>
#include <rtems/score/watchdogimpl.h>
#include <rtems/score/wkspace.h>
@@ -65,7 +66,10 @@ RTEMS_INLINE_ROUTINE void _MRSP_Acquire_critical(
Thread_queue_Context *queue_context
)
{
- _ISR_lock_Acquire( &mrsp->Lock, &queue_context->Lock_context );
+ _Thread_queue_Acquire_critical(
+ &mrsp->Wait_queue,
+ &queue_context->Lock_context
+ );
}
RTEMS_INLINE_ROUTINE void _MRSP_Release(
@@ -73,7 +77,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Release(
Thread_queue_Context *queue_context
)
{
- _ISR_lock_Release_and_ISR_enable( &mrsp->Lock, &queue_context->Lock_context );
+ _Thread_queue_Release( &mrsp->Wait_queue, &queue_context->Lock_context );
}
RTEMS_INLINE_ROUTINE bool _MRSP_Restore_priority_filter(
@@ -160,7 +164,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize(
_Resource_Initialize( &mrsp->Resource );
_Chain_Initialize_empty( &mrsp->Rivals );
- _ISR_lock_Initialize( &mrsp->Lock, "MrsP" );
+ _Thread_queue_Initialize( &mrsp->Wait_queue );
return STATUS_SUCCESSFUL;
}
@@ -438,7 +442,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Destroy(
)
{
_MRSP_Release( mrsp, queue_context );
- _ISR_lock_Destroy( &mrsp->Lock );
+ _Thread_queue_Destroy( &mrsp->Wait_queue );
_Workspace_Free( mrsp->ceiling_priorities );
}
--
1.8.4.5
More information about the devel
mailing list