[PATCH 18/30] score: Use scheduler instance specific locks

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Oct 31 08:51:49 UTC 2016


Update #2556.
---
 cpukit/score/include/rtems/score/mrspimpl.h      |  4 ++--
 cpukit/score/include/rtems/score/scheduler.h     |  5 +++++
 cpukit/score/include/rtems/score/schedulerimpl.h | 20 ++++++++++++++++----
 cpukit/score/src/scheduler.c                     | 16 ++++++++++++----
 4 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index deaacf2..92cc566 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -53,12 +53,12 @@ extern "C" {
 
 RTEMS_INLINE_ROUTINE void _MRSP_Giant_acquire( ISR_lock_Context *lock_context )
 {
-  _ISR_lock_Acquire( &_Scheduler_Lock, lock_context );
+  /* FIXME: MrsP protocol implementation will be reworked soon */
 }
 
 RTEMS_INLINE_ROUTINE void _MRSP_Giant_release( ISR_lock_Context *lock_context )
 {
-  _ISR_lock_Release( &_Scheduler_Lock, lock_context );
+  /* FIXME: MrsP protocol implementation will be reworked soon */
 }
 
 RTEMS_INLINE_ROUTINE void _MRSP_Acquire_critical(
diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h
index d13277a..07e415a 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -237,6 +237,11 @@ typedef struct {
  * this structure at the begin of its context structure.
  */
 typedef struct Scheduler_Context {
+  /**
+   * @brief Lock to protect this scheduler instance.
+   */
+  ISR_LOCK_MEMBER( Lock )
+
 #if defined(RTEMS_SMP)
   /**
    * @brief Count of processors owned by this scheduler instance.
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index ea32e00..25b961f 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -101,8 +101,6 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU(
   return _Scheduler_Get_by_CPU_index( cpu_index );
 }
 
-ISR_LOCK_DECLARE( extern, _Scheduler_Lock )
-
 /**
  * @brief Acquires the scheduler instance inside a critical section (interrupts
  * disabled).
@@ -116,8 +114,15 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Acquire_critical(
   ISR_lock_Context        *lock_context
 )
 {
+#if defined(RTEMS_SMP)
+  Scheduler_Context *context;
+
+  context = _Scheduler_Get_context( scheduler );
+  _ISR_lock_Acquire( &context->Lock, lock_context );
+#else
   (void) scheduler;
-  _ISR_lock_Acquire( &_Scheduler_Lock, lock_context );
+  (void) lock_context;
+#endif
 }
 
 /**
@@ -133,8 +138,15 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Release_critical(
   ISR_lock_Context        *lock_context
 )
 {
+#if defined(RTEMS_SMP)
+  Scheduler_Context *context;
+
+  context = _Scheduler_Get_context( scheduler );
+  _ISR_lock_Release( &context->Lock, lock_context );
+#else
   (void) scheduler;
-  _ISR_lock_Release( &_Scheduler_Lock, lock_context );
+  (void) lock_context;
+#endif
 }
 
 RTEMS_INLINE_ROUTINE Scheduler_Node *_Scheduler_Thread_get_node(
diff --git a/cpukit/score/src/scheduler.c b/cpukit/score/src/scheduler.c
index e7854e1..e5b9688 100644
--- a/cpukit/score/src/scheduler.c
+++ b/cpukit/score/src/scheduler.c
@@ -20,16 +20,24 @@
 
 #include <rtems/score/schedulerimpl.h>
 
-ISR_LOCK_DEFINE( , _Scheduler_Lock, "Scheduler" )
-
 void _Scheduler_Handler_initialization(void)
 {
-  size_t n = _Scheduler_Count;
+  size_t n;
   size_t i;
 
+  n = _Scheduler_Count;
+
   for ( i = 0 ; i < n ; ++i ) {
-    const Scheduler_Control *scheduler = &_Scheduler_Table[ i ];
+    const Scheduler_Control *scheduler;
+#if defined(RTEMS_SMP)
+    Scheduler_Context       *context;
+#endif
 
+    scheduler = &_Scheduler_Table[ i ];
+#if defined(RTEMS_SMP)
+    context = _Scheduler_Get_context( scheduler );
+#endif
+    _ISR_lock_Initialize( &context->Lock, "Scheduler" );
     ( *scheduler->Operations.initialize )( scheduler );
   }
 }
-- 
1.8.4.5




More information about the devel mailing list