[rtems commit] score: Simplify CORE mutex seize

Sebastian Huber sebh at rtems.org
Tue Sep 27 05:40:02 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Sep 23 11:29:48 2016 +0200

score: Simplify CORE mutex seize

Rename _CORE_mutex_Seize_no_protocol_slow() in _CORE_mutex_Seize_slow().
Remove previous _CORE_mutex_Seize_slow() since the protocol handling is
now done in the thread queue operations.

---

 cpukit/score/include/rtems/score/coremuteximpl.h | 14 ++----
 cpukit/score/src/coremutexseize.c                | 59 ------------------------
 2 files changed, 3 insertions(+), 70 deletions(-)

diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index a30d1a8..d30e38d 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -93,14 +93,6 @@ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_locked(
 }
 
 Status_Control _CORE_mutex_Seize_slow(
-  CORE_mutex_Control   *the_mutex,
-  Thread_Control       *executing,
-  Thread_Control       *owner,
-  bool                  wait,
-  Thread_queue_Context *queue_context
-);
-
-Status_Control _CORE_mutex_Seize_no_protocol_slow(
   CORE_mutex_Control            *the_mutex,
   const Thread_queue_Operations *operations,
   Thread_Control                *executing,
@@ -171,8 +163,8 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize(
 
   return _CORE_mutex_Seize_slow(
     &the_mutex->Mutex,
+    CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
     executing,
-    owner,
     wait,
     queue_context
   );
@@ -251,7 +243,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_no_protocol(
     return status;
   }
 
-  return _CORE_mutex_Seize_no_protocol_slow(
+  return _CORE_mutex_Seize_slow(
     &the_mutex->Mutex,
     operations,
     executing,
@@ -444,7 +436,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize(
     return status;
   }
 
-  return _CORE_mutex_Seize_no_protocol_slow(
+  return _CORE_mutex_Seize_slow(
     &the_mutex->Recursive.Mutex,
     CORE_MUTEX_TQ_OPERATIONS,
     executing,
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index 89b5c56..01a5ffb 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -24,65 +24,6 @@
 #include <rtems/score/watchdog.h>
 
 Status_Control _CORE_mutex_Seize_slow(
-  CORE_mutex_Control   *the_mutex,
-  Thread_Control       *executing,
-  Thread_Control       *owner,
-  bool                  wait,
-  Thread_queue_Context *queue_context
-)
-{
-  if ( !wait ) {
-    _CORE_mutex_Release( the_mutex, queue_context );
-    return STATUS_UNAVAILABLE;
-  }
-
-#if !defined(RTEMS_SMP)
-  /*
-   * We must disable thread dispatching here since we enable the interrupts for
-   * priority inheritance mutexes.
-   */
-  _Thread_Dispatch_disable();
-
-  /*
-   * To enable interrupts here works only since exactly one executing thread
-   * exists and only threads are allowed to seize and surrender mutexes with
-   * the priority inheritance protocol.  On SMP configurations more than one
-   * executing thread may exist, so here we must not release the lock, since
-   * otherwise the current owner may be no longer the owner of the mutex
-   * once we released the lock.
-   */
-  _CORE_mutex_Release( the_mutex, queue_context );
-#endif
-
-#if defined(RTEMS_SMP)
-  _Thread_queue_Context_set_expected_level( queue_context, 1 );
-#else
-  _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
-  _CORE_mutex_Acquire_critical( the_mutex, queue_context );
-  _Thread_queue_Context_set_expected_level( queue_context, 2 );
-#endif
-
-  _Thread_queue_Context_set_deadlock_callout(
-    queue_context,
-    _Thread_queue_Deadlock_status
-  );
-
-  _Thread_queue_Enqueue_critical(
-    &the_mutex->Wait_queue.Queue,
-    CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
-    executing,
-    STATES_WAITING_FOR_MUTEX,
-    queue_context
-  );
-
-#if !defined(RTEMS_SMP)
-  _Thread_Dispatch_enable( _Per_CPU_Get() );
-#endif
-
-  return _Thread_Wait_get_status( executing );
-}
-
-Status_Control _CORE_mutex_Seize_no_protocol_slow(
   CORE_mutex_Control            *the_mutex,
   const Thread_queue_Operations *operations,
   Thread_Control                *executing,



More information about the vc mailing list