[PATCH] score: Simplify SMP get lowest scheduled

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Oct 27 07:03:31 UTC 2017


There is no need to pass in the order relation since the scheduled
threads reside on an already ordered chain.  The caller will decide what
to do with the lowest scheduled thread.
---
 .../score/include/rtems/score/schedulersmpimpl.h   | 11 +++-----
 cpukit/score/src/scheduleredfsmp.c                 |  5 ++--
 cpukit/score/src/schedulerpriorityaffinitysmp.c    | 30 +++++++++-------------
 3 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/cpukit/score/include/rtems/score/schedulersmpimpl.h b/cpukit/score/include/rtems/score/schedulersmpimpl.h
index 3afa6b2a0c..3194ee39a0 100644
--- a/cpukit/score/include/rtems/score/schedulersmpimpl.h
+++ b/cpukit/score/include/rtems/score/schedulersmpimpl.h
@@ -286,8 +286,7 @@ typedef Scheduler_Node *( *Scheduler_SMP_Get_highest_ready )(
 
 typedef Scheduler_Node *( *Scheduler_SMP_Get_lowest_scheduled )(
   Scheduler_Context *context,
-  Scheduler_Node    *filter,
-  Chain_Node_order   order
+  Scheduler_Node    *filter
 );
 
 typedef void ( *Scheduler_SMP_Extract )(
@@ -615,8 +614,7 @@ static inline Thread_Control *_Scheduler_SMP_Preempt(
 
 static inline Scheduler_Node *_Scheduler_SMP_Get_lowest_scheduled(
   Scheduler_Context *context,
-  Scheduler_Node    *filter,
-  Chain_Node_order   order
+  Scheduler_Node    *filter
 )
 {
   Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
@@ -625,7 +623,6 @@ static inline Scheduler_Node *_Scheduler_SMP_Get_lowest_scheduled(
     (Scheduler_Node *) _Chain_Last( scheduled );
 
   (void) filter;
-  (void) order;
 
   _Assert( &lowest_scheduled->Node.Chain != _Chain_Tail( scheduled ) );
   _Assert(
@@ -725,7 +722,7 @@ static inline bool _Scheduler_SMP_Enqueue_ordered(
   bool            needs_help;
   Scheduler_Node *lowest_scheduled;
 
-  lowest_scheduled = ( *get_lowest_scheduled )( context, node, order );
+  lowest_scheduled = ( *get_lowest_scheduled )( context, node );
 
   if ( ( *order )( &node->Node.Chain, &lowest_scheduled->Node.Chain ) ) {
     _Scheduler_SMP_Enqueue_to_scheduled(
@@ -1207,7 +1204,7 @@ static inline bool _Scheduler_SMP_Ask_for_help(
   ISR_lock_Context  lock_context;
   bool              success;
 
-  lowest_scheduled = ( *get_lowest_scheduled )( context, node, order );
+  lowest_scheduled = ( *get_lowest_scheduled )( context, node );
 
   _Thread_Scheduler_acquire_critical( thread, &lock_context );
 
diff --git a/cpukit/score/src/scheduleredfsmp.c b/cpukit/score/src/scheduleredfsmp.c
index bd6ce82068..3a1b1a934e 100644
--- a/cpukit/score/src/scheduleredfsmp.c
+++ b/cpukit/score/src/scheduleredfsmp.c
@@ -226,8 +226,7 @@ static inline Scheduler_EDF_SMP_Node *_Scheduler_EDF_SMP_Get_scheduled(
 
 static inline Scheduler_Node *_Scheduler_EDF_SMP_Get_lowest_scheduled(
   Scheduler_Context *context,
-  Scheduler_Node    *filter_base,
-  Chain_Node_order   order
+  Scheduler_Node    *filter_base
 )
 {
   Scheduler_EDF_SMP_Node *filter;
@@ -249,7 +248,7 @@ static inline Scheduler_Node *_Scheduler_EDF_SMP_Get_lowest_scheduled(
     }
   }
 
-  return _Scheduler_SMP_Get_lowest_scheduled( context, filter_base, order );
+  return _Scheduler_SMP_Get_lowest_scheduled( context, filter_base );
 }
 
 static inline void _Scheduler_EDF_SMP_Insert_ready(
diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c
index 03db3e9a26..6caf00c3a0 100644
--- a/cpukit/score/src/schedulerpriorityaffinitysmp.c
+++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c
@@ -210,8 +210,7 @@ void _Scheduler_priority_affinity_SMP_Block(
  */
 static Scheduler_Node * _Scheduler_priority_affinity_SMP_Get_lowest_scheduled(
   Scheduler_Context *context,
-  Scheduler_Node    *filter_base,
-  Chain_Node_order   order
+  Scheduler_Node    *filter_base
 )
 {
   Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
@@ -230,20 +229,6 @@ static Scheduler_Node * _Scheduler_priority_affinity_SMP_Get_lowest_scheduled(
 
     node = (Scheduler_priority_affinity_SMP_Node *) chain_node;
 
-    /*
-     * If we didn't find a thread which is of equal or lower importance
-     * than filter thread is, then we can't schedule the filter thread
-     * to execute.
-     */
-    if (
-      (*order)(
-        &node->Base.Base.Base.Node.Chain,
-        &filter->Base.Base.Base.Node.Chain
-      )
-    ) {
-      break;
-    }
-
     /* cpu_index is the processor number thread is executing on */
     thread = _Scheduler_Node_get_owner( &node->Base.Base.Base );
     cpu_index = _Per_CPU_Get_index( _Thread_Get_CPU( thread ) );
@@ -309,8 +294,7 @@ static void _Scheduler_priority_affinity_SMP_Check_for_migrations(
     lowest_scheduled =
       _Scheduler_priority_affinity_SMP_Get_lowest_scheduled(
         context,
-        highest_ready,
-        _Scheduler_SMP_Insert_priority_lifo_order
+        highest_ready
       );
 
     /*
@@ -322,9 +306,19 @@ static void _Scheduler_priority_affinity_SMP_Check_for_migrations(
      * considering affinity. But now we have to consider that thread's
      * affinity as we look to place it.
      */
+
     if ( lowest_scheduled == NULL )
       break;
 
+    if (
+      _Scheduler_SMP_Insert_priority_lifo_order(
+        &lowest_scheduled->Node.Chain,
+        &highest_ready->Node.Chain
+      )
+    ) {
+      break;
+    }
+
     /*
      * But if we found a thread which is lower priority than one
      * in the ready set, then we need to swap them out.
-- 
2.12.3



More information about the devel mailing list