From 7ae4f56929a46375fd0e2ca39fe2a2d662abdda1 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 18 Oct 2021 09:07:07 +0200 Subject: 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 1109933e69..ec51b6d097 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 ); } -- cgit v1.2.3