From 351c14dfd00e1bdaced2823242532cab4bccb58c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 27 Sep 2016 11:33:36 +0200 Subject: score: Add new SMP scheduler helping protocol Update #2556. --- cpukit/score/src/schedulersimplesmp.c | 84 +++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 8 deletions(-) (limited to 'cpukit/score/src/schedulersimplesmp.c') diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c index 28410ea6c5..d8f576f15b 100644 --- a/cpukit/score/src/schedulersimplesmp.c +++ b/cpukit/score/src/schedulersimplesmp.c @@ -7,7 +7,7 @@ */ /* - * Copyright (c) 2013-2014 embedded brains GmbH. + * Copyright (c) 2013, 2016 embedded brains GmbH. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -49,10 +49,10 @@ void _Scheduler_simple_SMP_Node_initialize( Priority_Control priority ) { - Scheduler_SMP_Node *the_node; + Scheduler_SMP_Node *smp_node; - the_node = _Scheduler_SMP_Node_downcast( node ); - _Scheduler_SMP_Node_initialize( scheduler, the_node, the_thread, priority ); + smp_node = _Scheduler_SMP_Node_downcast( node ); + _Scheduler_SMP_Node_initialize( scheduler, smp_node, the_thread, priority ); } static void _Scheduler_simple_SMP_Do_update( @@ -61,12 +61,12 @@ static void _Scheduler_simple_SMP_Do_update( Priority_Control new_priority ) { - Scheduler_SMP_Node *the_node; + Scheduler_SMP_Node *smp_node; (void) context; - the_node = _Scheduler_SMP_Node_downcast( node ); - _Scheduler_SMP_Node_update_priority( the_node, new_priority ); + smp_node = _Scheduler_SMP_Node_downcast( node ); + _Scheduler_SMP_Node_update_priority( smp_node, new_priority ); } static Scheduler_Node *_Scheduler_simple_SMP_Get_highest_ready( @@ -296,6 +296,25 @@ Thread_Control *_Scheduler_simple_SMP_Unblock( ); } +static bool _Scheduler_simple_SMP_Do_ask_for_help( + Scheduler_Context *context, + Thread_Control *the_thread, + Scheduler_Node *node +) +{ + return _Scheduler_SMP_Ask_for_help( + context, + the_thread, + node, + _Scheduler_SMP_Insert_priority_lifo_order, + _Scheduler_simple_SMP_Insert_ready_lifo, + _Scheduler_SMP_Insert_scheduled_lifo, + _Scheduler_simple_SMP_Move_from_scheduled_to_ready, + _Scheduler_SMP_Get_lowest_scheduled, + _Scheduler_SMP_Allocate_processor_lazy + ); +} + Thread_Control *_Scheduler_simple_SMP_Update_priority( const Scheduler_Control *scheduler, Thread_Control *thread, @@ -313,7 +332,56 @@ Thread_Control *_Scheduler_simple_SMP_Update_priority( _Scheduler_simple_SMP_Enqueue_fifo, _Scheduler_simple_SMP_Enqueue_lifo, _Scheduler_simple_SMP_Enqueue_scheduled_fifo, - _Scheduler_simple_SMP_Enqueue_scheduled_lifo + _Scheduler_simple_SMP_Enqueue_scheduled_lifo, + _Scheduler_simple_SMP_Do_ask_for_help + ); +} + +bool _Scheduler_simple_SMP_Ask_for_help( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +) +{ + Scheduler_Context *context = _Scheduler_Get_context( scheduler ); + + return _Scheduler_simple_SMP_Do_ask_for_help( context, the_thread, node ); +} + +void _Scheduler_simple_SMP_Reconsider_help_request( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +) +{ + Scheduler_Context *context = _Scheduler_Get_context( scheduler ); + + _Scheduler_SMP_Reconsider_help_request( + context, + the_thread, + node, + _Scheduler_simple_SMP_Extract_from_ready + ); +} + +void _Scheduler_simple_SMP_Withdraw_node( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Thread_Scheduler_state next_state +) +{ + Scheduler_Context *context = _Scheduler_Get_context( scheduler ); + + _Scheduler_SMP_Withdraw_node( + context, + the_thread, + node, + next_state, + _Scheduler_simple_SMP_Extract_from_ready, + _Scheduler_simple_SMP_Get_highest_ready, + _Scheduler_simple_SMP_Move_from_ready_to_scheduled, + _Scheduler_SMP_Allocate_processor_lazy ); } -- cgit v1.2.3