score: Generalize SMP scheduler block support

Add extract from scheduled function to the _Scheduler_SMP_Block()
operation.  This allows a scheduler implementation to do extra work in
case a scheduled node is blocked.
This commit is contained in:
Sebastian Huber
2018-09-03 09:31:19 +02:00
parent fad3f79b88
commit 3aad9d9b08
6 changed files with 18 additions and 8 deletions

View File

@@ -867,9 +867,11 @@ static inline bool _Scheduler_SMP_Enqueue_scheduled(
}
static inline void _Scheduler_SMP_Extract_from_scheduled(
Scheduler_Node *node
Scheduler_Context *context,
Scheduler_Node *node
)
{
(void) context;
_Chain_Extract_unprotected( &node->Node.Chain );
}
@@ -968,6 +970,8 @@ static inline void _Scheduler_SMP_Preempt_and_schedule_highest_ready(
* @param[in] context The scheduler instance context.
* @param[in] thread The thread of the scheduling operation.
* @param[in] node The scheduler node of the thread to block.
* @param[in] extract_from_scheduled Function to extract a node from the set of
* scheduled nodes.
* @param[in] extract_from_ready Function to extract a node from the set of
* ready nodes.
* @param[in] get_highest_ready Function to get the highest ready node.
@@ -978,6 +982,7 @@ static inline void _Scheduler_SMP_Block(
Scheduler_Context *context,
Thread_Control *thread,
Scheduler_Node *node,
Scheduler_SMP_Extract extract_from_scheduled,
Scheduler_SMP_Extract extract_from_ready,
Scheduler_SMP_Get_highest_ready get_highest_ready,
Scheduler_SMP_Move move_from_ready_to_scheduled,
@@ -1001,7 +1006,7 @@ static inline void _Scheduler_SMP_Block(
_Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED );
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
_Scheduler_SMP_Extract_from_scheduled( node );
( *extract_from_scheduled )( context, node );
_Scheduler_SMP_Schedule_highest_ready(
context,
node,
@@ -1096,7 +1101,7 @@ static inline void _Scheduler_SMP_Update_priority(
node_state = _Scheduler_SMP_Node_state( node );
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
_Scheduler_SMP_Extract_from_scheduled( node );
_Scheduler_SMP_Extract_from_scheduled( context, node );
( *update )( context, node, priority );
( *enqueue_scheduled )( context, node, insert_priority );
} else if ( node_state == SCHEDULER_SMP_NODE_READY ) {
@@ -1130,7 +1135,7 @@ static inline void _Scheduler_SMP_Yield(
insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority );
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
_Scheduler_SMP_Extract_from_scheduled( node );
_Scheduler_SMP_Extract_from_scheduled( context, node );
( *enqueue_scheduled )( context, node, insert_priority );
needs_help = false;
} else if ( node_state == SCHEDULER_SMP_NODE_READY ) {
@@ -1299,7 +1304,7 @@ static inline void _Scheduler_SMP_Withdraw_node(
_Scheduler_Thread_change_state( thread, next_state );
_Thread_Scheduler_release_critical( thread, &lock_context );
_Scheduler_SMP_Extract_from_scheduled( node );
_Scheduler_SMP_Extract_from_scheduled( context, node );
_Scheduler_SMP_Schedule_highest_ready(
context,
node,
@@ -1393,7 +1398,7 @@ static inline Thread_Control *_Scheduler_SMP_Remove_processor(
chain_node = _Chain_Next( chain_node );
} while ( _Thread_Get_CPU( victim_user ) != cpu );
_Scheduler_SMP_Extract_from_scheduled( victim_node );
_Scheduler_SMP_Extract_from_scheduled( context, victim_node );
victim_owner = _Scheduler_Node_get_owner( victim_node );
if ( !victim_owner->is_idle ) {
@@ -1452,7 +1457,7 @@ static inline void _Scheduler_SMP_Set_affinity(
insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority );
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
_Scheduler_SMP_Extract_from_scheduled( node );
_Scheduler_SMP_Extract_from_scheduled( context, node );
_Scheduler_SMP_Preempt_and_schedule_highest_ready(
context,
node,

View File

@@ -311,7 +311,7 @@ static inline void _Scheduler_EDF_SMP_Move_from_scheduled_to_ready(
{
Priority_Control insert_priority;
_Chain_Extract_unprotected( &scheduled_to_ready->Node.Chain );
_Scheduler_SMP_Extract_from_scheduled( context, scheduled_to_ready );
insert_priority = _Scheduler_SMP_Node_priority( scheduled_to_ready );
_Scheduler_EDF_SMP_Insert_ready(
context,
@@ -403,6 +403,7 @@ void _Scheduler_EDF_SMP_Block(
context,
thread,
node,
_Scheduler_SMP_Extract_from_scheduled,
_Scheduler_EDF_SMP_Extract_from_ready,
_Scheduler_EDF_SMP_Get_highest_ready,
_Scheduler_EDF_SMP_Move_from_ready_to_scheduled,

View File

@@ -174,6 +174,7 @@ void _Scheduler_priority_affinity_SMP_Block(
context,
thread,
node,
_Scheduler_SMP_Extract_from_scheduled,
_Scheduler_priority_SMP_Extract_from_ready,
_Scheduler_priority_affinity_SMP_Get_highest_ready,
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,

View File

@@ -102,6 +102,7 @@ void _Scheduler_priority_SMP_Block(
context,
thread,
node,
_Scheduler_SMP_Extract_from_scheduled,
_Scheduler_priority_SMP_Extract_from_ready,
_Scheduler_priority_SMP_Get_highest_ready,
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,

View File

@@ -174,6 +174,7 @@ void _Scheduler_simple_SMP_Block(
context,
thread,
node,
_Scheduler_SMP_Extract_from_scheduled,
_Scheduler_simple_SMP_Extract_from_ready,
_Scheduler_simple_SMP_Get_highest_ready,
_Scheduler_simple_SMP_Move_from_ready_to_scheduled,

View File

@@ -234,6 +234,7 @@ void _Scheduler_strong_APA_Block(
context,
the_thread,
node,
_Scheduler_SMP_Extract_from_scheduled,
_Scheduler_strong_APA_Extract_from_ready,
_Scheduler_strong_APA_Get_highest_ready,
_Scheduler_strong_APA_Move_from_ready_to_scheduled,