[rtems commit] score: Use owner of thread queue for CORE mutex

Sebastian Huber sebh at rtems.org
Mon May 30 14:17:59 UTC 2016


Module:    rtems
Branch:    master
Commit:    024bffc665768504f594f23c9a9a6fdcca2bab38
Changeset: http://git.rtems.org/rtems/commit/?id=024bffc665768504f594f23c9a9a6fdcca2bab38

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon May 30 15:00:32 2016 +0200

score: Use owner of thread queue for CORE mutex

---

 cpukit/score/include/rtems/score/coremutex.h     | 16 ++++++----------
 cpukit/score/include/rtems/score/coremuteximpl.h |  5 ++---
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/cpukit/score/include/rtems/score/coremutex.h b/cpukit/score/include/rtems/score/coremutex.h
index 2bde8b5..26bb539 100644
--- a/cpukit/score/include/rtems/score/coremutex.h
+++ b/cpukit/score/include/rtems/score/coremutex.h
@@ -47,17 +47,13 @@ extern "C" {
  *  The following defines the control block used to manage each mutex.
  */
 typedef struct {
-  /** This field is the Waiting Queue used to manage the set of tasks
-   *  which are blocked waiting to lock the mutex.
-   */
-  Thread_queue_Control    Wait_queue;
-
-  /** This element points to the thread which is currently holding this mutex.
-   *  The holder is the last thread to successfully lock the mutex and which
-   *  has not unlocked it.  If the thread is not locked, there is no holder.
+  /**
+   * @brief The thread queue of this mutex.
+   *
+   * The owner of the thread queue indicates the mutex owner.
    */
-  Thread_Control         *holder;
-}   CORE_mutex_Control;
+  Thread_queue_Control Wait_queue;
+} CORE_mutex_Control;
 
 /**
  * @brief The recursive mutex control.
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index 69311e4..decf770 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -40,7 +40,6 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Initialize(
 )
 {
   _Thread_queue_Initialize( &the_mutex->Wait_queue );
-  the_mutex->holder = NULL;
 }
 
 RTEMS_INLINE_ROUTINE void _CORE_mutex_Destroy( CORE_mutex_Control *the_mutex )
@@ -74,7 +73,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_CORE_mutex_Get_owner(
   const CORE_mutex_Control *the_mutex
 )
 {
-  return the_mutex->holder;
+  return the_mutex->Wait_queue.Queue.owner;
 }
 
 /**
@@ -126,7 +125,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Set_owner(
   Thread_Control     *owner
 )
 {
-  the_mutex->holder = owner;
+  the_mutex->Wait_queue.Queue.owner = owner;
 }
 
 RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_owner(



More information about the vc mailing list