From a5aaf20a2d25846c2bfe78e286550fed38d2c111 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 10 Aug 2021 15:07:35 +0200 Subject: score: Replace priority prepend it with an enum Use the new Priority_Group_order enum instead of a boolean to indicated if a priority should be inserted as the first or last node into its priority group. This makes the code more expressive. It is also a bit more efficient since a branch in _Scheduler_Node_set_priority() is avoided and a simple bitwise or operation can be used. --- cpukit/score/src/scheduleredfreleasejob.c | 2 +- cpukit/score/src/threadchangepriority.c | 39 +++++++++++++++++++------------ cpukit/score/src/threadqops.c | 18 +++++++------- cpukit/score/src/threadrestart.c | 4 ++-- 4 files changed, 36 insertions(+), 27 deletions(-) (limited to 'cpukit/score') diff --git a/cpukit/score/src/scheduleredfreleasejob.c b/cpukit/score/src/scheduleredfreleasejob.c index 443fdaeed5..4cccffc952 100644 --- a/cpukit/score/src/scheduleredfreleasejob.c +++ b/cpukit/score/src/scheduleredfreleasejob.c @@ -66,7 +66,7 @@ void _Scheduler_EDF_Release_job( _Thread_Priority_changed( the_thread, priority_node, - false, + PRIORITY_GROUP_LAST, queue_context ); } else { diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c index 13e9147916..ac2e9a6d0c 100644 --- a/cpukit/score/src/threadchangepriority.c +++ b/cpukit/score/src/threadchangepriority.c @@ -31,13 +31,13 @@ static void _Thread_Set_scheduler_node_priority( Priority_Aggregation *priority_aggregation, - bool prepend_it + Priority_Group_order priority_group_order ) { _Scheduler_Node_set_priority( SCHEDULER_NODE_OF_WAIT_PRIORITY_NODE( priority_aggregation ), _Priority_Get_priority( priority_aggregation ), - prepend_it + priority_group_order ); } @@ -55,7 +55,10 @@ static void _Thread_Priority_action_add( the_thread = arg; _Thread_Scheduler_add_wait_node( the_thread, scheduler_node ); - _Thread_Set_scheduler_node_priority( priority_aggregation, false ); + _Thread_Set_scheduler_node_priority( + priority_aggregation, + PRIORITY_GROUP_LAST + ); _Priority_Set_action_type( priority_aggregation, PRIORITY_ACTION_ADD ); _Priority_Actions_add( priority_actions, priority_aggregation ); } @@ -73,7 +76,10 @@ static void _Thread_Priority_action_remove( the_thread = arg; _Thread_Scheduler_remove_wait_node( the_thread, scheduler_node ); - _Thread_Set_scheduler_node_priority( priority_aggregation, true ); + _Thread_Set_scheduler_node_priority( + priority_aggregation, + PRIORITY_GROUP_FIRST + ); _Priority_Set_action_type( priority_aggregation, PRIORITY_ACTION_REMOVE ); _Priority_Actions_add( priority_actions, priority_aggregation ); } @@ -81,12 +87,15 @@ static void _Thread_Priority_action_remove( static void _Thread_Priority_action_change( Priority_Aggregation *priority_aggregation, - bool prepend_it, + Priority_Group_order priority_group_order, Priority_Actions *priority_actions, void *arg ) { - _Thread_Set_scheduler_node_priority( priority_aggregation, prepend_it ); + _Thread_Set_scheduler_node_priority( + priority_aggregation, + priority_group_order + ); #if defined(RTEMS_SMP) || defined(RTEMS_DEBUG) _Priority_Set_action_type( priority_aggregation, PRIORITY_ACTION_CHANGE ); #endif @@ -97,7 +106,7 @@ static void _Thread_Priority_do_perform_actions( Thread_Control *the_thread, Thread_queue_Queue *queue, const Thread_queue_Operations *operations, - bool prepend_it, + Priority_Group_order priority_group_order, Thread_queue_Context *queue_context ) { @@ -162,7 +171,7 @@ static void _Thread_Priority_do_perform_actions( _Priority_Changed( priority_aggregation, priority_action_node, - prepend_it, + priority_group_order, &queue_context->Priority.Actions, _Thread_Priority_action_change, NULL @@ -214,7 +223,7 @@ void _Thread_Priority_perform_actions( the_thread, queue, the_thread->Wait.operations, - false, + PRIORITY_GROUP_LAST, queue_context ); @@ -244,7 +253,7 @@ static void _Thread_Priority_apply( Thread_Control *the_thread, Priority_Node *priority_action_node, Thread_queue_Context *queue_context, - bool prepend_it, + Priority_Group_order priority_group_order, Priority_Action_type priority_action_type ) { @@ -263,7 +272,7 @@ static void _Thread_Priority_apply( the_thread, queue, the_thread->Wait.operations, - prepend_it, + priority_group_order, queue_context ); @@ -288,7 +297,7 @@ void _Thread_Priority_add( the_thread, priority_node, queue_context, - false, + PRIORITY_GROUP_LAST, PRIORITY_ACTION_ADD ); } @@ -303,7 +312,7 @@ void _Thread_Priority_remove( the_thread, priority_node, queue_context, - true, + PRIORITY_GROUP_FIRST, PRIORITY_ACTION_REMOVE ); } @@ -311,7 +320,7 @@ void _Thread_Priority_remove( void _Thread_Priority_changed( Thread_Control *the_thread, Priority_Node *priority_node, - bool prepend_it, + Priority_Group_order priority_group_order, Thread_queue_Context *queue_context ) { @@ -319,7 +328,7 @@ void _Thread_Priority_changed( the_thread, priority_node, queue_context, - prepend_it, + priority_group_order, PRIORITY_ACTION_CHANGE ); } diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c index d6ba9dad57..eb01002679 100644 --- a/cpukit/score/src/threadqops.c +++ b/cpukit/score/src/threadqops.c @@ -700,7 +700,7 @@ static void _Thread_queue_Priority_inherit_do_priority_actions_remove( static void _Thread_queue_Priority_inherit_do_priority_actions_change( Priority_Aggregation *priority_aggregation, - bool prepend_it, + Priority_Group_order priority_group_order, Priority_Actions *priority_actions, void *arg ) @@ -787,7 +787,7 @@ static void _Thread_queue_Priority_inherit_priority_actions( _Priority_Changed( &priority_queue->Queue, &scheduler_node->Wait.Priority.Node, - false, + PRIORITY_GROUP_LAST, priority_actions, _Thread_queue_Priority_inherit_do_priority_actions_change, scheduler_node_of_owner @@ -884,7 +884,7 @@ static void _Thread_queue_Priority_inherit_do_initialize( static void _Thread_queue_Priority_inherit_do_enqueue_change( Priority_Aggregation *priority_aggregation, - bool prepend_it, + Priority_Group_order priority_group_order, Priority_Actions *priority_actions, void *arg ) @@ -1079,7 +1079,7 @@ static void _Thread_queue_Priority_inherit_do_extract_remove( static void _Thread_queue_Priority_inherit_do_extract_change( Priority_Aggregation *priority_aggregation, - bool prepend_it, + Priority_Group_order priority_group_order, Priority_Actions *priority_actions, void *arg ) @@ -1231,7 +1231,7 @@ static void _Thread_queue_Priority_inherit_do_surrender_add( _Scheduler_Node_set_priority( scheduler_node, _Priority_Get_priority( priority_aggregation ), - false + PRIORITY_GROUP_LAST ); } @@ -1254,7 +1254,7 @@ static void _Thread_queue_Priority_inherit_do_surrender_remove( static void _Thread_queue_Priority_inherit_do_surrender_change( Priority_Aggregation *priority_aggregation, - bool prepend_it, + Priority_Group_order priority_group_order, Priority_Actions *priority_actions, void *arg ) @@ -1270,14 +1270,14 @@ static void _Thread_queue_Priority_inherit_do_surrender_change( _Scheduler_Node_set_priority( SCHEDULER_NODE_OF_WAIT_PRIORITY( priority_aggregation ), _Priority_Get_priority( priority_aggregation ), - prepend_it + priority_group_order ); } #if defined(RTEMS_SMP) static void _Thread_queue_Priority_inherit_do_surrender_change_2( Priority_Aggregation *priority_aggregation, - bool prepend_it, + Priority_Group_order priority_group_order, Priority_Actions *priority_actions, void *arg ) @@ -1285,7 +1285,7 @@ static void _Thread_queue_Priority_inherit_do_surrender_change_2( _Scheduler_Node_set_priority( SCHEDULER_NODE_OF_WAIT_PRIORITY( priority_aggregation ), _Priority_Get_priority( priority_aggregation ), - prepend_it + priority_group_order ); } #endif diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index 79a154e3d3..4b1907a2d9 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -70,7 +70,7 @@ static void _Thread_Raise_real_priority( the_thread, &the_thread->Real_priority, priority, - false, + PRIORITY_GROUP_LAST, &queue_context ); } @@ -576,7 +576,7 @@ Status_Control _Thread_Restart( the_thread, &the_thread->Real_priority, the_thread->Start.initial_priority, - false, + PRIORITY_GROUP_LAST, &queue_context ); _Thread_Wait_release( the_thread, &queue_context ); -- cgit v1.2.3