From 3d6ebde1acab61e7c8fce1a1ed51517f7c2bf7c6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 15 Oct 2021 11:21:31 +0200 Subject: score: Add SMP scheduler make/clean sticky This patch fixes the following broken behaviour: While a thread is scheduled on a helping scheduler, while it does not own a MrsP semaphore, if it obtains a MrsP semaphore, then no scheduler node using an idle thread and the ceiling priority of the semaphore is unblocked for the home scheduler. This could lead to priority inversion issues and is not in line with the MrsP protocol. Introduce two new scheduler operations which are only enabled if RTEMS_SMP is defined. The operations are used to make the scheduler node of the home scheduler sticky and to clean the sticky property. This helps to keep the sticky handing out of the frequently used priority update operation. Close #4532. --- cpukit/score/src/schedulerpriorityaffinitysmp.c | 39 +++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'cpukit/score/src/schedulerpriorityaffinitysmp.c') diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c index 4bbf2f6e17..648c243589 100644 --- a/cpukit/score/src/schedulerpriorityaffinitysmp.c +++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c @@ -12,8 +12,10 @@ * _Scheduler_priority_affinity_SMP_Remove_processor(), * _Scheduler_priority_affinity_SMP_Set_affinity(), * _Scheduler_priority_affinity_SMP_Unblock(), - * _Scheduler_priority_affinity_SMP_Update_priority(), and - * _Scheduler_priority_affinity_SMP_Withdraw_node(). + * _Scheduler_priority_affinity_SMP_Update_priority(), + * _Scheduler_priority_affinity_SMP_Withdraw_node(), + * _Scheduler_priority_affinity_SMP_Make_sticky(), and + * _Scheduler_priority_affinity_SMP_Clean_sticky(). */ /* @@ -512,6 +514,39 @@ void _Scheduler_priority_affinity_SMP_Withdraw_node( ); } +void _Scheduler_priority_affinity_SMP_Make_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +) +{ + _Scheduler_SMP_Make_sticky( + scheduler, + the_thread, + node, + _Scheduler_priority_SMP_Do_update, + _Scheduler_priority_affinity_SMP_Enqueue + ); +} + +void _Scheduler_priority_affinity_SMP_Clean_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +) +{ + _Scheduler_SMP_Clean_sticky( + scheduler, + the_thread, + node, + _Scheduler_SMP_Extract_from_scheduled, + _Scheduler_priority_SMP_Extract_from_ready, + _Scheduler_priority_affinity_SMP_Get_highest_ready, + _Scheduler_priority_SMP_Move_from_ready_to_scheduled, + _Scheduler_SMP_Allocate_processor_exact + ); +} + void _Scheduler_priority_affinity_SMP_Add_processor( const Scheduler_Control *scheduler, Thread_Control *idle -- cgit v1.2.3