diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-09-30 14:38:04 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-11-02 10:05:40 +0100 |
commit | 501043a18bae037ca7195ce6989d3ffa8cc72660 (patch) | |
tree | 57e5051298373efcf465be0d0675a0efce50c80f /cpukit/score | |
parent | score: Rename scheduler ask for help stuff (diff) | |
download | rtems-501043a18bae037ca7195ce6989d3ffa8cc72660.tar.bz2 |
score: Pass scheduler node to update priority op
This enables to call this scheduler operation for all scheduler nodes
available to a thread.
Update #2556.
Diffstat (limited to 'cpukit/score')
17 files changed, 100 insertions, 63 deletions
diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h index e85b7f8c34..0fc7d5a880 100644 --- a/cpukit/score/include/rtems/score/scheduler.h +++ b/cpukit/score/include/rtems/score/scheduler.h @@ -83,7 +83,8 @@ typedef struct { /** @see _Scheduler_Update_priority() */ Scheduler_Void_or_thread ( *update_priority )( const Scheduler_Control *, - Thread_Control * + Thread_Control *, + Scheduler_Node * ); /** @see _Scheduler_Map_priority() */ diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h index ab43672ec1..0ae33cf359 100644 --- a/cpukit/score/include/rtems/score/scheduleredf.h +++ b/cpukit/score/include/rtems/score/scheduleredf.h @@ -171,7 +171,8 @@ Scheduler_Void_or_thread _Scheduler_EDF_Unblock( Scheduler_Void_or_thread _Scheduler_EDF_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); Priority_Control _Scheduler_EDF_Map_priority( diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h index e44dd4fbbb..211b7a7fd9 100644 --- a/cpukit/score/include/rtems/score/schedulerimpl.h +++ b/cpukit/score/include/rtems/score/schedulerimpl.h @@ -136,6 +136,17 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Release_critical( _ISR_lock_Release( &_Scheduler_Lock, lock_context ); } +RTEMS_INLINE_ROUTINE Scheduler_Node *_Scheduler_Thread_get_node( + const Thread_Control *the_thread +) +{ +#if defined(RTEMS_SMP) + return the_thread->Scheduler.node; +#else + return the_thread->Scheduler.nodes; +#endif +} + /** * The preferred method to add a new scheduler is to define the jump table * entries and add a case to the _Scheduler_Initialize routine. @@ -381,7 +392,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority( Thread_Control *the_thread #if defined(RTEMS_SMP) needs_help = #endif - ( *own_scheduler->Operations.update_priority )( own_scheduler, the_thread ); + ( *own_scheduler->Operations.update_priority )( + own_scheduler, + the_thread, + _Thread_Scheduler_get_home_node( the_thread ) + ); #if defined(RTEMS_SMP) _Scheduler_Ask_for_help_if_necessary( needs_help ); @@ -768,17 +783,6 @@ RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index( return (uint32_t) (scheduler - &_Scheduler_Table[ 0 ]); } -RTEMS_INLINE_ROUTINE Scheduler_Node *_Scheduler_Thread_get_node( - const Thread_Control *the_thread -) -{ -#if defined(RTEMS_SMP) - return the_thread->Scheduler.node; -#else - return the_thread->Scheduler.nodes; -#endif -} - RTEMS_INLINE_ROUTINE void _Scheduler_Thread_set_priority( Thread_Control *the_thread, Priority_Control new_priority, diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h index f3e805a43b..4c9c698830 100644 --- a/cpukit/score/include/rtems/score/schedulerpriority.h +++ b/cpukit/score/include/rtems/score/schedulerpriority.h @@ -155,7 +155,8 @@ Scheduler_Void_or_thread _Scheduler_priority_Unblock( Scheduler_Void_or_thread _Scheduler_priority_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *base_node ); void _Scheduler_priority_Node_initialize( diff --git a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h index 4d06bcb43a..be28deca28 100644 --- a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h +++ b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h @@ -138,7 +138,8 @@ bool _Scheduler_priority_affinity_SMP_Get_affinity( */ Thread_Control *_Scheduler_priority_affinity_SMP_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); Thread_Control *_Scheduler_priority_affinity_SMP_Ask_for_help_X( diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmp.h b/cpukit/score/include/rtems/score/schedulerprioritysmp.h index 4bd779557f..afde45b82d 100644 --- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h +++ b/cpukit/score/include/rtems/score/schedulerprioritysmp.h @@ -117,7 +117,8 @@ Thread_Control *_Scheduler_priority_SMP_Unblock( Thread_Control *_Scheduler_priority_SMP_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); Thread_Control *_Scheduler_priority_SMP_Ask_for_help_X( diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h index 22393790bc..5d610691a6 100644 --- a/cpukit/score/include/rtems/score/schedulersimple.h +++ b/cpukit/score/include/rtems/score/schedulersimple.h @@ -147,7 +147,8 @@ Scheduler_Void_or_thread _Scheduler_simple_Unblock( Scheduler_Void_or_thread _Scheduler_simple_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); /**@}*/ diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h index 6d2b77c2e9..42734455b1 100644 --- a/cpukit/score/include/rtems/score/schedulersimplesmp.h +++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h @@ -100,7 +100,8 @@ Thread_Control *_Scheduler_simple_SMP_Unblock( Thread_Control *_Scheduler_simple_SMP_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); Thread_Control *_Scheduler_simple_SMP_Ask_for_help_X( diff --git a/cpukit/score/include/rtems/score/schedulersmpimpl.h b/cpukit/score/include/rtems/score/schedulersmpimpl.h index 4e4edf75a1..cec0357f32 100644 --- a/cpukit/score/include/rtems/score/schedulersmpimpl.h +++ b/cpukit/score/include/rtems/score/schedulersmpimpl.h @@ -385,6 +385,20 @@ static inline Scheduler_SMP_Node *_Scheduler_SMP_Node_downcast( return (Scheduler_SMP_Node *) node; } +static inline Scheduler_SMP_Node_state _Scheduler_SMP_Node_state( + const Scheduler_Node *node +) +{ + return ( (const Scheduler_SMP_Node *) node )->state; +} + +static inline Priority_Control _Scheduler_SMP_Node_priority( + const Scheduler_Node *node +) +{ + return ( (const Scheduler_SMP_Node *) node )->priority; +} + static inline void _Scheduler_SMP_Node_initialize( const Scheduler_Control *scheduler, Scheduler_SMP_Node *node, @@ -963,6 +977,7 @@ static inline Thread_Control *_Scheduler_SMP_Unblock( static inline Thread_Control *_Scheduler_SMP_Update_priority( Scheduler_Context *context, Thread_Control *thread, + Scheduler_Node *node, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Update update, Scheduler_SMP_Enqueue enqueue_fifo, @@ -971,41 +986,42 @@ static inline Thread_Control *_Scheduler_SMP_Update_priority( Scheduler_SMP_Enqueue_scheduled enqueue_scheduled_lifo ) { - Scheduler_SMP_Node *node; - Thread_Control *needs_help; - Priority_Control new_priority; - bool prepend_it; + Thread_Control *needs_help; + Priority_Control new_priority; + bool prepend_it; + Scheduler_SMP_Node_state node_state; - node = _Scheduler_SMP_Thread_get_own_node( thread ); - new_priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it ); + new_priority = _Scheduler_Node_get_priority( node, &prepend_it ); - if ( new_priority == node->priority ) { + if ( new_priority == _Scheduler_SMP_Node_priority( node ) ) { /* Nothing to do */ return NULL; } - if ( node->state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Scheduler_SMP_Extract_from_scheduled( &node->Base ); + node_state = _Scheduler_SMP_Node_state( node ); + + if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { + _Scheduler_SMP_Extract_from_scheduled( node ); - ( *update )( context, &node->Base, new_priority ); + ( *update )( context, node, new_priority ); if ( prepend_it ) { - needs_help = ( *enqueue_scheduled_lifo )( context, &node->Base ); + needs_help = ( *enqueue_scheduled_lifo )( context, node ); } else { - needs_help = ( *enqueue_scheduled_fifo )( context, &node->Base ); + needs_help = ( *enqueue_scheduled_fifo )( context, node ); } - } else if ( node->state == SCHEDULER_SMP_NODE_READY ) { - ( *extract_from_ready )( context, &node->Base ); + } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { + ( *extract_from_ready )( context, node ); - ( *update )( context, &node->Base, new_priority ); + ( *update )( context, node, new_priority ); if ( prepend_it ) { - needs_help = ( *enqueue_lifo )( context, &node->Base, NULL ); + needs_help = ( *enqueue_lifo )( context, node, NULL ); } else { - needs_help = ( *enqueue_fifo )( context, &node->Base, NULL ); + needs_help = ( *enqueue_fifo )( context, node, NULL ); } } else { - ( *update )( context, &node->Base, new_priority ); + ( *update )( context, node, new_priority ); needs_help = NULL; } diff --git a/cpukit/score/include/rtems/score/schedulerstrongapa.h b/cpukit/score/include/rtems/score/schedulerstrongapa.h index 4dfc2ff2c8..35d3eddee2 100644 --- a/cpukit/score/include/rtems/score/schedulerstrongapa.h +++ b/cpukit/score/include/rtems/score/schedulerstrongapa.h @@ -117,7 +117,8 @@ Thread_Control *_Scheduler_strong_APA_Unblock( Thread_Control *_Scheduler_strong_APA_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ); Thread_Control *_Scheduler_strong_APA_Ask_for_help_X( diff --git a/cpukit/score/src/scheduleredfchangepriority.c b/cpukit/score/src/scheduleredfchangepriority.c index 8940b1d54b..8fcc1115f4 100644 --- a/cpukit/score/src/scheduleredfchangepriority.c +++ b/cpukit/score/src/scheduleredfchangepriority.c @@ -38,11 +38,12 @@ Priority_Control _Scheduler_EDF_Unmap_priority( Scheduler_Void_or_thread _Scheduler_EDF_Update_priority( 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; @@ -51,23 +52,23 @@ Scheduler_Void_or_thread _Scheduler_EDF_Update_priority( SCHEDULER_RETURN_VOID_OR_NULL; } - 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 ); - if ( priority == node->priority ) { + if ( priority == the_node->priority ) { /* Nothing to do */ SCHEDULER_RETURN_VOID_OR_NULL; } - node->priority = priority; + the_node->priority = priority; context = _Scheduler_EDF_Get_context( scheduler ); - _Scheduler_EDF_Extract( context, node ); + _Scheduler_EDF_Extract( context, the_node ); if ( prepend_it ) { - _Scheduler_EDF_Enqueue_first( context, node, priority ); + _Scheduler_EDF_Enqueue_first( context, the_node, priority ); } else { - _Scheduler_EDF_Enqueue( context, node, priority ); + _Scheduler_EDF_Enqueue( context, the_node, priority ); } _Scheduler_EDF_Schedule_body( scheduler, the_thread, false ); diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c index a15ff0f2f2..9282b1a845 100644 --- a/cpukit/score/src/schedulerpriorityaffinitysmp.c +++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c @@ -500,7 +500,8 @@ static Thread_Control *_Scheduler_priority_affinity_SMP_Enqueue_scheduled_fifo( */ Thread_Control *_Scheduler_priority_affinity_SMP_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *thread + Thread_Control *thread, + Scheduler_Node *node ) { Scheduler_Context *context = _Scheduler_Get_context( scheduler ); @@ -509,6 +510,7 @@ Thread_Control *_Scheduler_priority_affinity_SMP_Update_priority( displaced = _Scheduler_SMP_Update_priority( context, thread, + node, _Scheduler_priority_SMP_Extract_from_ready, _Scheduler_priority_SMP_Do_update, _Scheduler_priority_affinity_SMP_Enqueue_fifo, diff --git a/cpukit/score/src/schedulerprioritychangepriority.c b/cpukit/score/src/schedulerprioritychangepriority.c index 4fc46cf15a..339168f20c 100644 --- a/cpukit/score/src/schedulerprioritychangepriority.c +++ b/cpukit/score/src/schedulerprioritychangepriority.c @@ -23,11 +23,12 @@ Scheduler_Void_or_thread _Scheduler_priority_Update_priority( 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; @@ -36,11 +37,11 @@ Scheduler_Void_or_thread _Scheduler_priority_Update_priority( SCHEDULER_RETURN_VOID_OR_NULL; } - 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 ); - if ( priority == node->Ready_queue.current_priority ) { + if ( priority == the_node->Ready_queue.current_priority ) { /* Nothing to do */ SCHEDULER_RETURN_VOID_OR_NULL; } @@ -49,12 +50,12 @@ Scheduler_Void_or_thread _Scheduler_priority_Update_priority( _Scheduler_priority_Ready_queue_extract( &the_thread->Object.Node, - &node->Ready_queue, + &the_node->Ready_queue, &context->Bit_map ); _Scheduler_priority_Ready_queue_update( - &node->Ready_queue, + &the_node->Ready_queue, priority, &context->Bit_map, &context->Ready[ 0 ] @@ -63,13 +64,13 @@ Scheduler_Void_or_thread _Scheduler_priority_Update_priority( if ( prepend_it ) { _Scheduler_priority_Ready_queue_enqueue_first( &the_thread->Object.Node, - &node->Ready_queue, + &the_node->Ready_queue, &context->Bit_map ); } else { _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/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c index 2445503485..4936b05fce 100644 --- a/cpukit/score/src/schedulerprioritysmp.c +++ b/cpukit/score/src/schedulerprioritysmp.c @@ -227,7 +227,8 @@ Thread_Control *_Scheduler_priority_SMP_Unblock( Thread_Control *_Scheduler_priority_SMP_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *thread + Thread_Control *thread, + Scheduler_Node *node ) { Scheduler_Context *context = _Scheduler_Get_context( scheduler ); @@ -235,6 +236,7 @@ Thread_Control *_Scheduler_priority_SMP_Update_priority( return _Scheduler_SMP_Update_priority( context, thread, + node, _Scheduler_priority_SMP_Extract_from_ready, _Scheduler_priority_SMP_Do_update, _Scheduler_priority_SMP_Enqueue_fifo, diff --git a/cpukit/score/src/schedulersimplechangepriority.c b/cpukit/score/src/schedulersimplechangepriority.c index 9d4a565dbd..e430c75e08 100644 --- a/cpukit/score/src/schedulersimplechangepriority.c +++ b/cpukit/score/src/schedulersimplechangepriority.c @@ -23,11 +23,11 @@ Scheduler_Void_or_thread _Scheduler_simple_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ) { Scheduler_simple_Context *context; - Scheduler_Node *node; bool prepend_it; if ( !_Thread_Is_ready( the_thread ) ) { @@ -36,7 +36,6 @@ Scheduler_Void_or_thread _Scheduler_simple_Update_priority( } context = _Scheduler_simple_Get_context( scheduler ); - node = _Scheduler_Thread_get_node( the_thread ); _Scheduler_Node_get_priority( node, &prepend_it ); _Scheduler_simple_Extract( scheduler, the_thread ); diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c index f51990e9c7..2d333c9400 100644 --- a/cpukit/score/src/schedulersimplesmp.c +++ b/cpukit/score/src/schedulersimplesmp.c @@ -294,7 +294,8 @@ Thread_Control *_Scheduler_simple_SMP_Unblock( Thread_Control *_Scheduler_simple_SMP_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *thread + Thread_Control *thread, + Scheduler_Node *node ) { Scheduler_Context *context = _Scheduler_Get_context( scheduler ); @@ -302,6 +303,7 @@ Thread_Control *_Scheduler_simple_SMP_Update_priority( return _Scheduler_SMP_Update_priority( context, thread, + node, _Scheduler_simple_SMP_Extract_from_ready, _Scheduler_simple_SMP_Do_update, _Scheduler_simple_SMP_Enqueue_fifo, diff --git a/cpukit/score/src/schedulerstrongapa.c b/cpukit/score/src/schedulerstrongapa.c index 7dfe0759b8..f42f470cfc 100644 --- a/cpukit/score/src/schedulerstrongapa.c +++ b/cpukit/score/src/schedulerstrongapa.c @@ -353,7 +353,8 @@ Thread_Control *_Scheduler_strong_APA_Unblock( Thread_Control *_Scheduler_strong_APA_Update_priority( const Scheduler_Control *scheduler, - Thread_Control *the_thread + Thread_Control *the_thread, + Scheduler_Node *node ) { Scheduler_Context *context = _Scheduler_Get_context( scheduler ); @@ -361,6 +362,7 @@ Thread_Control *_Scheduler_strong_APA_Update_priority( return _Scheduler_SMP_Update_priority( context, the_thread, + node, _Scheduler_strong_APA_Extract_from_ready, _Scheduler_strong_APA_Do_update, _Scheduler_strong_APA_Enqueue_fifo, |