From 72e0bdba4580072c33da09fcacbd3063dbc4f2c1 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 10 Oct 2016 14:50:19 +0200 Subject: score: Pass scheduler node to unblock operation Changed for consistency with other scheduler operations. Update #2556. --- cpukit/score/include/rtems/score/scheduler.h | 3 +- cpukit/score/include/rtems/score/schedulercbs.h | 17 ++------- cpukit/score/include/rtems/score/scheduleredf.h | 13 ++----- cpukit/score/include/rtems/score/schedulerimpl.h | 6 +++- .../score/include/rtems/score/schedulerpriority.h | 13 ++----- .../rtems/score/schedulerpriorityaffinitysmp.h | 11 ++---- .../include/rtems/score/schedulerprioritysmp.h | 3 +- cpukit/score/include/rtems/score/schedulersimple.h | 13 ++----- .../score/include/rtems/score/schedulersimplesmp.h | 3 +- .../score/include/rtems/score/schedulersmpimpl.h | 40 ++++++++++++---------- .../score/include/rtems/score/schedulerstrongapa.h | 3 +- cpukit/score/src/schedulercbsunblock.c | 15 ++++---- cpukit/score/src/scheduleredfunblock.c | 13 +++---- cpukit/score/src/schedulerpriorityaffinitysmp.c | 6 ++-- cpukit/score/src/schedulerprioritysmp.c | 4 ++- cpukit/score/src/schedulerpriorityunblock.c | 15 ++++---- cpukit/score/src/schedulersimplesmp.c | 4 ++- cpukit/score/src/schedulersimpleunblock.c | 5 ++- cpukit/score/src/schedulerstrongapa.c | 4 ++- testsuites/smptests/smpscheduler03/init.c | 13 +++++-- 20 files changed, 94 insertions(+), 110 deletions(-) diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h index eb8db7cbb3..ad04e7fa6e 100644 --- a/cpukit/score/include/rtems/score/scheduler.h +++ b/cpukit/score/include/rtems/score/scheduler.h @@ -79,7 +79,8 @@ typedef struct { /** @see _Scheduler_Unblock() */ Scheduler_Void_or_thread ( *unblock )( const Scheduler_Control *, - Thread_Control * + Thread_Control *, + Scheduler_Node * ); /** @see _Scheduler_Update_priority() */ diff --git a/cpukit/score/include/rtems/score/schedulercbs.h b/cpukit/score/include/rtems/score/schedulercbs.h index 02c7b53e12..ee8e40d399 100644 --- a/cpukit/score/include/rtems/score/schedulercbs.h +++ b/cpukit/score/include/rtems/score/schedulercbs.h @@ -146,23 +146,10 @@ typedef struct { */ extern Scheduler_CBS_Server _Scheduler_CBS_Server_list[]; -/** - * @brief Unblocks a thread from the queue. - * - * This routine adds @a the_thread to the scheduling decision, that is, - * adds it to the ready queue and updates any appropriate scheduling - * variables, for example the heir thread. It is checked whether the - * remaining budget is sufficient. If not, the thread continues as a - * new job in order to protect concurrent threads. - * - * @param[in] scheduler The scheduler instance. - * @param[in] the_thread will be unblocked. - * - * @note This has to be asessed as missed deadline of the current job. - */ Scheduler_Void_or_thread _Scheduler_CBS_Unblock( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); void _Scheduler_CBS_Release_job( diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h index 2ecf1a4eb2..65218e785a 100644 --- a/cpukit/score/include/rtems/score/scheduleredf.h +++ b/cpukit/score/include/rtems/score/scheduleredf.h @@ -144,19 +144,10 @@ void _Scheduler_EDF_Node_initialize( Priority_Control priority ); -/** - * @brief Adds @a the_thread to the scheduling decision. - * - * This routine adds @a the_thread to the scheduling decision, that is, - * adds it to the ready queue and updates any appropriate scheduling - * variables, for example the heir thread. - * - * @param[in] scheduler The scheduler instance. - * @param[in] the_thread will be unblocked. - */ Scheduler_Void_or_thread _Scheduler_EDF_Unblock( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); Scheduler_Void_or_thread _Scheduler_EDF_Update_priority( diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h index e630cc2e53..3108641365 100644 --- a/cpukit/score/include/rtems/score/schedulerimpl.h +++ b/cpukit/score/include/rtems/score/schedulerimpl.h @@ -363,7 +363,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread ) #if defined(RTEMS_SMP) needs_help = #endif - ( *scheduler->Operations.unblock )( scheduler, the_thread ); + ( *scheduler->Operations.unblock )( + scheduler, + the_thread, + _Thread_Scheduler_get_home_node( the_thread ) + ); #if defined(RTEMS_SMP) _Scheduler_Ask_for_help_if_necessary( needs_help ); diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h index 89912aac55..57855aa643 100644 --- a/cpukit/score/include/rtems/score/schedulerpriority.h +++ b/cpukit/score/include/rtems/score/schedulerpriority.h @@ -128,19 +128,10 @@ void _Scheduler_priority_Schedule( Thread_Control *the_thread ); -/** - * @brief Add @a the_thread to the scheduling decision. - * - * This routine adds @a the_thread to the scheduling decision, - * that is, adds it to the ready queue and - * updates any appropriate scheduling variables, for example the heir thread. - * - * @param[in] scheduler The scheduler instance. - * @param[in] the_thread will be unblocked - */ Scheduler_Void_or_thread _Scheduler_priority_Unblock( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); Scheduler_Void_or_thread _Scheduler_priority_Update_priority( diff --git a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h index bc3ea49d69..359c369dd0 100644 --- a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h +++ b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h @@ -92,17 +92,10 @@ void _Scheduler_priority_affinity_SMP_Block( Scheduler_Node *node ); -/** - * @brief SMP Priority Affinity Scheduler Unblock Operation - * - * This method is the unblock operation for this scheduler. - * - * @param[in] scheduler is the scheduler instance information - * @param[in] thread is the thread to unblock - */ Thread_Control *_Scheduler_priority_affinity_SMP_Unblock( const Scheduler_Control *scheduler, - Thread_Control *thread + Thread_Control *thread, + Scheduler_Node *node ); /** diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmp.h b/cpukit/score/include/rtems/score/schedulerprioritysmp.h index de37d34d0e..9042243c09 100644 --- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h +++ b/cpukit/score/include/rtems/score/schedulerprioritysmp.h @@ -113,7 +113,8 @@ void _Scheduler_priority_SMP_Block( Thread_Control *_Scheduler_priority_SMP_Unblock( const Scheduler_Control *scheduler, - Thread_Control *thread + Thread_Control *thread, + Scheduler_Node *node ); Thread_Control *_Scheduler_priority_SMP_Update_priority( diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h index 4ef0db8d6f..cd18650d68 100644 --- a/cpukit/score/include/rtems/score/schedulersimple.h +++ b/cpukit/score/include/rtems/score/schedulersimple.h @@ -104,19 +104,10 @@ void _Scheduler_simple_Block( Scheduler_Node *node ); -/** - * @brief Unblock a simple-priority-based thread. - * - * This routine adds @a the_thread to the scheduling decision, - * that is, adds it to the ready queue and - * updates any appropriate scheduling variables, for example the heir thread. - * - * @param[in] scheduler The scheduler instance. - * @param[in] the_thread is the thread that is to be unblocked - */ Scheduler_Void_or_thread _Scheduler_simple_Unblock( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); Scheduler_Void_or_thread _Scheduler_simple_Update_priority( diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h index db36b84857..2275237447 100644 --- a/cpukit/score/include/rtems/score/schedulersimplesmp.h +++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h @@ -96,7 +96,8 @@ void _Scheduler_simple_SMP_Block( Thread_Control *_Scheduler_simple_SMP_Unblock( const Scheduler_Control *scheduler, - Thread_Control *thread + Thread_Control *thread, + Scheduler_Node *node ); Thread_Control *_Scheduler_simple_SMP_Update_priority( diff --git a/cpukit/score/include/rtems/score/schedulersmpimpl.h b/cpukit/score/include/rtems/score/schedulersmpimpl.h index f797735c76..0f82161993 100644 --- a/cpukit/score/include/rtems/score/schedulersmpimpl.h +++ b/cpukit/score/include/rtems/score/schedulersmpimpl.h @@ -924,22 +924,21 @@ static inline void _Scheduler_SMP_Block( static inline Thread_Control *_Scheduler_SMP_Unblock( Scheduler_Context *context, Thread_Control *thread, + Scheduler_Node *node, Scheduler_SMP_Update update, Scheduler_SMP_Enqueue enqueue_fifo ) { - Scheduler_SMP_Node *node; - bool is_scheduled; - bool unblock; - Thread_Control *needs_help; + Scheduler_SMP_Node_state node_state; + bool unblock; + Thread_Control *needs_help; - node = _Scheduler_SMP_Thread_get_node( thread ); - is_scheduled = ( node->state == SCHEDULER_SMP_NODE_SCHEDULED ); + node_state = _Scheduler_SMP_Node_state( node ); unblock = _Scheduler_Unblock_node( context, thread, - &node->Base, - is_scheduled, + node, + node_state == SCHEDULER_SMP_NODE_SCHEDULED, _Scheduler_SMP_Release_idle_thread ); @@ -947,26 +946,29 @@ static inline Thread_Control *_Scheduler_SMP_Unblock( Priority_Control new_priority; bool prepend_it; - new_priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it ); + new_priority = _Scheduler_Node_get_priority( node, &prepend_it ); (void) prepend_it; - if ( new_priority != node->priority ) { - ( *update )( context, &node->Base, new_priority ); + if ( new_priority != _Scheduler_SMP_Node_priority( node ) ) { + ( *update )( context, node, new_priority ); } - if ( node->state == SCHEDULER_SMP_NODE_BLOCKED ) { - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); + if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) { + _Scheduler_SMP_Node_change_state( + _Scheduler_SMP_Node_downcast( node ), + SCHEDULER_SMP_NODE_READY + ); - needs_help = ( *enqueue_fifo )( context, &node->Base, thread ); + needs_help = ( *enqueue_fifo )( context, node, thread ); } else { - _Assert( node->state == SCHEDULER_SMP_NODE_READY ); + _Assert( node_state == SCHEDULER_SMP_NODE_READY ); _Assert( - node->Base.help_state == SCHEDULER_HELP_ACTIVE_OWNER - || node->Base.help_state == SCHEDULER_HELP_ACTIVE_RIVAL + node->help_state == SCHEDULER_HELP_ACTIVE_OWNER + || node->help_state == SCHEDULER_HELP_ACTIVE_RIVAL ); - _Assert( node->Base.idle == NULL ); + _Assert( node->idle == NULL ); - if ( node->Base.accepts_help == thread ) { + if ( node->accepts_help == thread ) { needs_help = thread; } else { needs_help = NULL; diff --git a/cpukit/score/include/rtems/score/schedulerstrongapa.h b/cpukit/score/include/rtems/score/schedulerstrongapa.h index a83616cdfc..fd6d6ec247 100644 --- a/cpukit/score/include/rtems/score/schedulerstrongapa.h +++ b/cpukit/score/include/rtems/score/schedulerstrongapa.h @@ -113,7 +113,8 @@ void _Scheduler_strong_APA_Block( Thread_Control *_Scheduler_strong_APA_Unblock( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); Thread_Control *_Scheduler_strong_APA_Update_priority( diff --git a/cpukit/score/src/schedulercbsunblock.c b/cpukit/score/src/schedulercbsunblock.c index c09f471afa..63abc12c70 100644 --- a/cpukit/score/src/schedulercbsunblock.c +++ b/cpukit/score/src/schedulercbsunblock.c @@ -27,17 +27,18 @@ Scheduler_Void_or_thread _Scheduler_CBS_Unblock( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ) { - Scheduler_CBS_Node *node; + Scheduler_CBS_Node *the_node; Scheduler_CBS_Server *serv_info; Priority_Control priority; bool prepend_it; - node = _Scheduler_CBS_Thread_get_node( the_thread ); - serv_info = node->cbs_server; - priority = _Scheduler_Node_get_priority( &node->Base.Base, &prepend_it ); + the_node = _Scheduler_CBS_Node_downcast( node ); + serv_info = the_node->cbs_server; + priority = _Scheduler_Node_get_priority( &the_node->Base.Base, &prepend_it ); (void) prepend_it; /* @@ -60,12 +61,12 @@ Scheduler_Void_or_thread _Scheduler_CBS_Unblock( _Scheduler_CBS_Cancel_job( scheduler, the_thread, - node->deadline_node, + the_node->deadline_node, &queue_context ); } } - _Scheduler_EDF_Unblock( scheduler, the_thread ); + _Scheduler_EDF_Unblock( scheduler, the_thread, &the_node->Base.Base ); SCHEDULER_RETURN_VOID_OR_NULL; } diff --git a/cpukit/score/src/scheduleredfunblock.c b/cpukit/score/src/scheduleredfunblock.c index a5cc4b6a37..5b3fbb3943 100644 --- a/cpukit/score/src/scheduleredfunblock.c +++ b/cpukit/score/src/scheduleredfunblock.c @@ -24,21 +24,22 @@ Scheduler_Void_or_thread _Scheduler_EDF_Unblock( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ) { Scheduler_EDF_Context *context; - Scheduler_EDF_Node *node; + Scheduler_EDF_Node *the_node; Priority_Control priority; bool prepend_it; context = _Scheduler_EDF_Get_context( scheduler ); - node = _Scheduler_EDF_Thread_get_node( the_thread ); - priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it ); + the_node = _Scheduler_EDF_Node_downcast( node ); + priority = _Scheduler_Node_get_priority( &the_node->Base, &prepend_it ); (void) prepend_it; - node->priority = priority; - _Scheduler_EDF_Enqueue( context, node, priority ); + the_node->priority = priority; + _Scheduler_EDF_Enqueue( context, the_node, priority ); /* * If the thread that was unblocked is more important than the heir, diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c index 451df88d83..f684b1ae55 100644 --- a/cpukit/score/src/schedulerpriorityaffinitysmp.c +++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c @@ -364,7 +364,8 @@ static void _Scheduler_priority_affinity_SMP_Check_for_migrations( */ Thread_Control *_Scheduler_priority_affinity_SMP_Unblock( const Scheduler_Control *scheduler, - Thread_Control *thread + Thread_Control *thread, + Scheduler_Node *node ) { Scheduler_Context *context = _Scheduler_Get_context( scheduler ); @@ -373,6 +374,7 @@ Thread_Control *_Scheduler_priority_affinity_SMP_Unblock( needs_help = _Scheduler_SMP_Unblock( context, thread, + node, _Scheduler_priority_SMP_Do_update, _Scheduler_priority_affinity_SMP_Enqueue_fifo ); @@ -610,7 +612,7 @@ bool _Scheduler_priority_affinity_SMP_Set_affinity( /* * FIXME: Do not ignore threads in need for help. */ - (void) _Scheduler_priority_affinity_SMP_Unblock( scheduler, thread ); + (void) _Scheduler_priority_affinity_SMP_Unblock( scheduler, thread, &node->Base.Base.Base ); } return true; diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c index ab3e663a81..f80c3b8c4c 100644 --- a/cpukit/score/src/schedulerprioritysmp.c +++ b/cpukit/score/src/schedulerprioritysmp.c @@ -214,7 +214,8 @@ static Thread_Control *_Scheduler_priority_SMP_Enqueue_scheduled_fifo( Thread_Control *_Scheduler_priority_SMP_Unblock( const Scheduler_Control *scheduler, - Thread_Control *thread + Thread_Control *thread, + Scheduler_Node *node ) { Scheduler_Context *context = _Scheduler_Get_context( scheduler ); @@ -222,6 +223,7 @@ Thread_Control *_Scheduler_priority_SMP_Unblock( return _Scheduler_SMP_Unblock( context, thread, + node, _Scheduler_priority_SMP_Do_update, _Scheduler_priority_SMP_Enqueue_fifo ); diff --git a/cpukit/score/src/schedulerpriorityunblock.c b/cpukit/score/src/schedulerpriorityunblock.c index 7186103f2b..99d4310a4c 100644 --- a/cpukit/score/src/schedulerpriorityunblock.c +++ b/cpukit/score/src/schedulerpriorityunblock.c @@ -24,23 +24,24 @@ Scheduler_Void_or_thread _Scheduler_priority_Unblock ( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ) { Scheduler_priority_Context *context; - Scheduler_priority_Node *node; + Scheduler_priority_Node *the_node; unsigned int priority; bool prepend_it; context = _Scheduler_priority_Get_context( scheduler ); - node = _Scheduler_priority_Thread_get_node( the_thread ); + the_node = _Scheduler_priority_Node_downcast( node ); priority = (unsigned int ) - _Scheduler_Node_get_priority( &node->Base, &prepend_it ); + _Scheduler_Node_get_priority( &the_node->Base, &prepend_it ); (void) prepend_it; - if ( priority != node->Ready_queue.current_priority ) { + if ( priority != the_node->Ready_queue.current_priority ) { _Scheduler_priority_Ready_queue_update( - &node->Ready_queue, + &the_node->Ready_queue, priority, &context->Bit_map, &context->Ready[ 0 ] @@ -49,7 +50,7 @@ Scheduler_Void_or_thread _Scheduler_priority_Unblock ( _Scheduler_priority_Ready_queue_enqueue( &the_thread->Object.Node, - &node->Ready_queue, + &the_node->Ready_queue, &context->Bit_map ); diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c index 3d4efeade0..28410ea6c5 100644 --- a/cpukit/score/src/schedulersimplesmp.c +++ b/cpukit/score/src/schedulersimplesmp.c @@ -281,7 +281,8 @@ static Thread_Control *_Scheduler_simple_SMP_Enqueue_scheduled_fifo( Thread_Control *_Scheduler_simple_SMP_Unblock( const Scheduler_Control *scheduler, - Thread_Control *thread + Thread_Control *thread, + Scheduler_Node *node ) { Scheduler_Context *context = _Scheduler_Get_context( scheduler ); @@ -289,6 +290,7 @@ Thread_Control *_Scheduler_simple_SMP_Unblock( return _Scheduler_SMP_Unblock( context, thread, + node, _Scheduler_simple_SMP_Do_update, _Scheduler_simple_SMP_Enqueue_fifo ); diff --git a/cpukit/score/src/schedulersimpleunblock.c b/cpukit/score/src/schedulersimpleunblock.c index de08fc1a5a..5eeaf6cc35 100644 --- a/cpukit/score/src/schedulersimpleunblock.c +++ b/cpukit/score/src/schedulersimpleunblock.c @@ -23,12 +23,15 @@ Scheduler_Void_or_thread _Scheduler_simple_Unblock( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ) { Scheduler_simple_Context *context; Priority_Control priority; + (void) node; + context = _Scheduler_simple_Get_context( scheduler ); _Scheduler_simple_Insert_priority_fifo( &context->Ready, the_thread ); priority = _Thread_Get_priority( the_thread ); diff --git a/cpukit/score/src/schedulerstrongapa.c b/cpukit/score/src/schedulerstrongapa.c index b5a5545a5f..7dd65c0f8a 100644 --- a/cpukit/score/src/schedulerstrongapa.c +++ b/cpukit/score/src/schedulerstrongapa.c @@ -340,7 +340,8 @@ static Thread_Control *_Scheduler_strong_APA_Enqueue_scheduled_fifo( Thread_Control *_Scheduler_strong_APA_Unblock( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ) { Scheduler_Context *context = _Scheduler_Get_context( scheduler ); @@ -348,6 +349,7 @@ Thread_Control *_Scheduler_strong_APA_Unblock( return _Scheduler_SMP_Unblock( context, the_thread, + node, _Scheduler_strong_APA_Do_update, _Scheduler_strong_APA_Enqueue_fifo ); diff --git a/testsuites/smptests/smpscheduler03/init.c b/testsuites/smptests/smpscheduler03/init.c index dc3507f8bc..0d7b88ca8c 100644 --- a/testsuites/smptests/smpscheduler03/init.c +++ b/testsuites/smptests/smpscheduler03/init.c @@ -479,7 +479,10 @@ static void block_op( _Thread_State_release( thread, &state_lock_context ); } -static Thread_Control *unblock_op(Thread_Control *thread) +static Thread_Control *unblock_op( + Thread_Control *thread, + Scheduler_SMP_Node *scheduler_node +) { const Scheduler_Control *scheduler; ISR_lock_Context state_lock_context; @@ -490,7 +493,11 @@ static Thread_Control *unblock_op(Thread_Control *thread) scheduler = _Scheduler_Get( thread ); _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context ); - needs_help = (*scheduler->Operations.unblock)(scheduler, thread); + needs_help = (*scheduler->Operations.unblock)( + scheduler, + thread, + &scheduler_node->Base + ); _Scheduler_Release_critical( scheduler, &scheduler_lock_context ); _Thread_State_release( thread, &state_lock_context ); @@ -527,7 +534,7 @@ static void test_case_unblock_op( block_op(executing, executing_node); rtems_test_assert(executing_node->state == SCHEDULER_SMP_NODE_BLOCKED); - needs_help = unblock_op(executing); + needs_help = unblock_op(executing, executing_node); rtems_test_assert(executing_node->state == new_state); switch (new_state) { -- cgit v1.2.3