From 238629f2f144807abd29e9fefc9d20746ae16b2c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 19 May 2014 15:26:55 -0500 Subject: Add SMP Priority Scheduler with Affinity This scheduler attempts to account for needed thread migrations caused as a side-effect of a thread state, affinity, or priority change operation. This scheduler has its own allocate_processor handler named _Scheduler_SMP_Allocate_processor_exact() because _Scheduler_SMP_Allocate_processor() attempts to prevent an executing thread from moving off its current CPU without considering affinity. Without this, the scheduler makes all the right decisions and then they are discarded at the end. ==Side Effects of Adding This Scheduler== Added Thread_Control * parameter to Scheduler_SMP_Get_highest_ready type so methods looking for the highest ready thread can filter by the processor on which the thread blocking resides. This allows affinity to be considered. Simple Priority SMP and Priority SMP ignore this parameter. + Added get_lowest_scheduled argument to _Scheduler_SMP_Enqueue_ordered(). + Added allocate_processor argument to the following methods: - _Scheduler_SMP_Block() - _Scheduler_SMP_Enqueue_scheduled_ordered() - _Scheduler_SMP_Enqueue_scheduled_ordered() + schedulerprioritysmpimpl.h is a new file with prototypes for methods which were formerly static in schedulerprioritysmp.c but now need to be public to be shared with this scheduler. NOTE: _Scheduler_SMP_Get_lowest_ready() appears to have a path which would allow it to return a NULL. Previously, _Scheduler_SMP_Enqueue_ordered() would have asserted on it. If it cannot return a NULL, _Scheduler_SMP_Get_lowest_ready() should have an assertions. --- cpukit/score/src/schedulersimplesmp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'cpukit/score/src/schedulersimplesmp.c') diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c index 029da67b7a..eb260efd09 100644 --- a/cpukit/score/src/schedulersimplesmp.c +++ b/cpukit/score/src/schedulersimplesmp.c @@ -64,12 +64,15 @@ static void _Scheduler_simple_SMP_Do_update( } static Thread_Control *_Scheduler_simple_SMP_Get_highest_ready( - Scheduler_Context *context + Scheduler_Context *context, + Thread_Control *thread ) { Scheduler_simple_SMP_Context *self = _Scheduler_simple_SMP_Get_self( context ); + (void) thread; + return (Thread_Control *) _Chain_First( &self->Ready ); } @@ -155,7 +158,8 @@ void _Scheduler_simple_SMP_Block( thread, _Scheduler_simple_SMP_Extract_from_ready, _Scheduler_simple_SMP_Get_highest_ready, - _Scheduler_simple_SMP_Move_from_ready_to_scheduled + _Scheduler_simple_SMP_Move_from_ready_to_scheduled, + _Scheduler_SMP_Allocate_processor ); } @@ -173,7 +177,9 @@ static void _Scheduler_simple_SMP_Enqueue_ordered( order, insert_ready, insert_scheduled, - _Scheduler_simple_SMP_Move_from_scheduled_to_ready + _Scheduler_simple_SMP_Move_from_scheduled_to_ready, + _Scheduler_SMP_Get_lowest_scheduled, + _Scheduler_SMP_Allocate_processor ); } @@ -220,7 +226,8 @@ static void _Scheduler_simple_SMP_Enqueue_scheduled_ordered( _Scheduler_simple_SMP_Get_highest_ready, insert_ready, insert_scheduled, - _Scheduler_simple_SMP_Move_from_ready_to_scheduled + _Scheduler_simple_SMP_Move_from_ready_to_scheduled, + _Scheduler_SMP_Allocate_processor ); } -- cgit v1.2.3