[PATCH 06/27] score: Simplify _Scheduler_Exchange_idle_thread()

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Nov 15 17:12:38 UTC 2021


Remove superfluous idle parameter.

Update #4531.
---
 cpukit/include/rtems/score/schedulerimpl.h    | 16 +++++++++-------
 cpukit/include/rtems/score/schedulersmpimpl.h | 12 ++----------
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/cpukit/include/rtems/score/schedulerimpl.h b/cpukit/include/rtems/score/schedulerimpl.h
index 1e83f75891..7319cc4e4c 100644
--- a/cpukit/include/rtems/score/schedulerimpl.h
+++ b/cpukit/include/rtems/score/schedulerimpl.h
@@ -1042,22 +1042,24 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Release_idle_thread(
  * @brief Exchanges an idle thread from the scheduler node that uses it
  *      right now to another scheduler node.
  *
- * @param needs_idle The scheduler node that needs an idle thread.
- * @param uses_idle The scheduler node that used the idle thread.
- * @param idle The idle thread that is exchanged.
+ * @param needs_idle is the scheduler node that needs an idle thread.
+ *
+ * @param uses_idle is the scheduler node that used the idle thread.
  */
 RTEMS_INLINE_ROUTINE void _Scheduler_Exchange_idle_thread(
   Scheduler_Node *needs_idle,
-  Scheduler_Node *uses_idle,
-  Thread_Control *idle
+  Scheduler_Node *uses_idle
 )
 {
-  uses_idle->idle = NULL;
+  _Scheduler_Node_set_idle_user(
+    needs_idle,
+    _Scheduler_Node_get_idle( uses_idle )
+  );
   _Scheduler_Node_set_user(
     uses_idle,
     _Scheduler_Node_get_owner( uses_idle )
   );
-  _Scheduler_Node_set_idle_user( needs_idle, idle );
+  uses_idle->idle = NULL;
 }
 
 /**
diff --git a/cpukit/include/rtems/score/schedulersmpimpl.h b/cpukit/include/rtems/score/schedulersmpimpl.h
index f4ee72696f..a1a048d4ed 100644
--- a/cpukit/include/rtems/score/schedulersmpimpl.h
+++ b/cpukit/include/rtems/score/schedulersmpimpl.h
@@ -840,11 +840,7 @@ static inline void _Scheduler_SMP_Enqueue_to_scheduled(
     ( *insert_scheduled )( context, node, priority );
     ( *move_from_scheduled_to_ready )( context, lowest_scheduled );
 
-    _Scheduler_Exchange_idle_thread(
-      node,
-      lowest_scheduled,
-      _Scheduler_Node_get_idle( lowest_scheduled )
-    );
+    _Scheduler_Exchange_idle_thread( node, lowest_scheduled );
   } else {
     _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK );
     _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED );
@@ -1020,11 +1016,7 @@ static inline bool _Scheduler_SMP_Enqueue_scheduled(
       ( *insert_ready )( context, node, insert_priority );
       ( *move_from_ready_to_scheduled )( context, highest_ready );
 
-      _Scheduler_Exchange_idle_thread(
-        highest_ready,
-        node,
-        _Scheduler_Node_get_idle( node )
-      );
+      _Scheduler_Exchange_idle_thread( highest_ready, node );
       return false;
     } else {
       _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK );
-- 
2.26.2



More information about the devel mailing list