[rtems commit] score: Not set CPU in _Scheduler_Use_idle_thread()

Sebastian Huber sebh at rtems.org
Tue Nov 23 13:34:54 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Oct 18 09:07:07 2021 +0200

score: Not set CPU in _Scheduler_Use_idle_thread()

Do not set the CPU of the idle thread in _Scheduler_Use_idle_thread().  This
helps to use _Scheduler_Try_to_schedule_node() under more general conditions in
the future, for example in case the owner and user of a node are not the same.

Update #4531.

---

 cpukit/include/rtems/score/schedulerimpl.h | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/cpukit/include/rtems/score/schedulerimpl.h b/cpukit/include/rtems/score/schedulerimpl.h
index 1109933..ec51b6d 100644
--- a/cpukit/include/rtems/score/schedulerimpl.h
+++ b/cpukit/include/rtems/score/schedulerimpl.h
@@ -915,14 +915,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Thread_change_state(
 RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Use_idle_thread(
   Scheduler_Context         *context,
   Scheduler_Node            *node,
-  Per_CPU_Control           *cpu,
   Scheduler_Get_idle_thread  get_idle_thread
 )
 {
   Thread_Control *idle = ( *get_idle_thread )( context );
 
   _Scheduler_Node_set_idle_user( node, idle );
-  _Thread_Set_CPU( idle, cpu );
   return idle;
 }
 
@@ -999,12 +997,12 @@ _Scheduler_Try_to_schedule_node(
   } else if ( idle != NULL ) {
     action = SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE;
   } else {
-    _Scheduler_Use_idle_thread(
-      context,
-      node,
-      _Thread_Get_CPU( owner ),
-      get_idle_thread
-    );
+    Thread_Control *idle;
+    Thread_Control *user;
+
+    idle = _Scheduler_Use_idle_thread( context, node, get_idle_thread );
+    user = _Scheduler_Node_get_user( node );
+    _Thread_Set_CPU( idle, _Thread_Get_CPU( user ) );
   }
 
   _Thread_Scheduler_release_critical( owner, &lock_context );
@@ -1104,12 +1102,8 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Scheduler_Block_node(
     if ( is_scheduled && _Scheduler_Node_get_idle( node ) == NULL ) {
       Thread_Control *idle;
 
-      idle = _Scheduler_Use_idle_thread(
-        context,
-        node,
-        thread_cpu,
-        get_idle_thread
-      );
+      idle = _Scheduler_Use_idle_thread( context, node, get_idle_thread );
+      _Thread_Set_CPU( idle, thread_cpu );
       _Thread_Dispatch_update_heir( _Per_CPU_Get(), thread_cpu, idle );
     }
 



More information about the vc mailing list