forked from Imagelibrary/rtems
score: _Scheduler_SMP_Schedule_highest_ready()
Simplify callers of _Scheduler_SMP_Schedule_highest_ready(). Move the node state change and the extraction from scheduled into _Scheduler_SMP_Schedule_highest_ready(). Move the idle thread release to the caller which have more information about the presence of an idle thread. Update #4531.
This commit is contained in:
@@ -1098,7 +1098,9 @@ static inline void _Scheduler_SMP_Extract_from_scheduled(
|
|||||||
*
|
*
|
||||||
* @param context The scheduler context instance.
|
* @param context The scheduler context instance.
|
||||||
* @param victim The node of the thread that is repressed by the newly scheduled thread.
|
* @param victim The node of the thread that is repressed by the newly scheduled thread.
|
||||||
* @param victim_cpu The cpu to allocate.
|
* @param cpu is the processor to allocate.
|
||||||
|
* @param extract_from_scheduled Function to extract a node from the set of
|
||||||
|
* scheduled nodes.
|
||||||
* @param extract_from_ready Function to extract a node from the set of
|
* @param extract_from_ready Function to extract a node from the set of
|
||||||
* ready nodes.
|
* ready nodes.
|
||||||
* @param get_highest_ready Function to get the highest ready node.
|
* @param get_highest_ready Function to get the highest ready node.
|
||||||
@@ -1110,22 +1112,19 @@ static inline void _Scheduler_SMP_Extract_from_scheduled(
|
|||||||
static inline void _Scheduler_SMP_Schedule_highest_ready(
|
static inline void _Scheduler_SMP_Schedule_highest_ready(
|
||||||
Scheduler_Context *context,
|
Scheduler_Context *context,
|
||||||
Scheduler_Node *victim,
|
Scheduler_Node *victim,
|
||||||
Per_CPU_Control *victim_cpu,
|
Per_CPU_Control *cpu,
|
||||||
|
Scheduler_SMP_Extract extract_from_scheduled,
|
||||||
Scheduler_SMP_Extract extract_from_ready,
|
Scheduler_SMP_Extract extract_from_ready,
|
||||||
Scheduler_SMP_Get_highest_ready get_highest_ready,
|
Scheduler_SMP_Get_highest_ready get_highest_ready,
|
||||||
Scheduler_SMP_Move move_from_ready_to_scheduled,
|
Scheduler_SMP_Move move_from_ready_to_scheduled,
|
||||||
Scheduler_SMP_Allocate_processor allocate_processor,
|
Scheduler_SMP_Allocate_processor allocate_processor,
|
||||||
Scheduler_Get_idle_node get_idle_node,
|
Scheduler_Get_idle_node get_idle_node
|
||||||
Scheduler_Release_idle_node release_idle_node
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Scheduler_SMP_Action action;
|
Scheduler_SMP_Action action;
|
||||||
|
|
||||||
(void) _Scheduler_Release_idle_thread_if_necessary(
|
_Scheduler_SMP_Node_change_state( victim, SCHEDULER_SMP_NODE_BLOCKED );
|
||||||
victim,
|
( *extract_from_scheduled )( context, victim );
|
||||||
release_idle_node,
|
|
||||||
context
|
|
||||||
);
|
|
||||||
|
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim );
|
Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim );
|
||||||
@@ -1140,7 +1139,7 @@ static inline void _Scheduler_SMP_Schedule_highest_ready(
|
|||||||
_Scheduler_SMP_Allocate_processor(
|
_Scheduler_SMP_Allocate_processor(
|
||||||
context,
|
context,
|
||||||
highest_ready,
|
highest_ready,
|
||||||
victim_cpu,
|
cpu,
|
||||||
allocate_processor
|
allocate_processor
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1239,14 +1238,13 @@ static inline void _Scheduler_SMP_Block(
|
|||||||
Scheduler_SMP_Get_highest_ready get_highest_ready,
|
Scheduler_SMP_Get_highest_ready get_highest_ready,
|
||||||
Scheduler_SMP_Move move_from_ready_to_scheduled,
|
Scheduler_SMP_Move move_from_ready_to_scheduled,
|
||||||
Scheduler_SMP_Allocate_processor allocate_processor,
|
Scheduler_SMP_Allocate_processor allocate_processor,
|
||||||
Scheduler_Get_idle_node get_idle_node,
|
Scheduler_Get_idle_node get_idle_node
|
||||||
Scheduler_Release_idle_node release_idle_node
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int sticky_level;
|
int sticky_level;
|
||||||
ISR_lock_Context lock_context;
|
ISR_lock_Context lock_context;
|
||||||
Scheduler_SMP_Node_state node_state;
|
Scheduler_SMP_Node_state node_state;
|
||||||
Per_CPU_Control *thread_cpu;
|
Per_CPU_Control *cpu;
|
||||||
|
|
||||||
sticky_level = node->sticky_level;
|
sticky_level = node->sticky_level;
|
||||||
--sticky_level;
|
--sticky_level;
|
||||||
@@ -1254,8 +1252,8 @@ static inline void _Scheduler_SMP_Block(
|
|||||||
_Assert( sticky_level >= 0 );
|
_Assert( sticky_level >= 0 );
|
||||||
|
|
||||||
_Thread_Scheduler_acquire_critical( thread, &lock_context );
|
_Thread_Scheduler_acquire_critical( thread, &lock_context );
|
||||||
thread_cpu = _Thread_Get_CPU( thread );
|
cpu = _Thread_Get_CPU( thread );
|
||||||
_Thread_Scheduler_cancel_need_for_help( thread, thread_cpu );
|
_Thread_Scheduler_cancel_need_for_help( thread, cpu );
|
||||||
_Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_BLOCKED );
|
_Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_BLOCKED );
|
||||||
_Thread_Scheduler_release_critical( thread, &lock_context );
|
_Thread_Scheduler_release_critical( thread, &lock_context );
|
||||||
|
|
||||||
@@ -1269,8 +1267,8 @@ static inline void _Scheduler_SMP_Block(
|
|||||||
Thread_Control *idle;
|
Thread_Control *idle;
|
||||||
|
|
||||||
idle = _Scheduler_Use_idle_thread( node, get_idle_node, context );
|
idle = _Scheduler_Use_idle_thread( node, get_idle_node, context );
|
||||||
_Thread_Set_CPU( idle, thread_cpu );
|
_Thread_Set_CPU( idle, cpu );
|
||||||
_Thread_Dispatch_update_heir( _Per_CPU_Get(), thread_cpu, idle );
|
_Thread_Dispatch_update_heir( _Per_CPU_Get(), cpu, idle );
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -1279,22 +1277,20 @@ static inline void _Scheduler_SMP_Block(
|
|||||||
_Assert( _Scheduler_Node_get_user( node ) == thread );
|
_Assert( _Scheduler_Node_get_user( node ) == thread );
|
||||||
_Assert( _Scheduler_Node_get_idle( node ) == NULL );
|
_Assert( _Scheduler_Node_get_idle( node ) == NULL );
|
||||||
|
|
||||||
_Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED );
|
|
||||||
|
|
||||||
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
|
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
|
||||||
( *extract_from_scheduled )( context, node );
|
|
||||||
_Scheduler_SMP_Schedule_highest_ready(
|
_Scheduler_SMP_Schedule_highest_ready(
|
||||||
context,
|
context,
|
||||||
node,
|
node,
|
||||||
thread_cpu,
|
cpu,
|
||||||
|
extract_from_scheduled,
|
||||||
extract_from_ready,
|
extract_from_ready,
|
||||||
get_highest_ready,
|
get_highest_ready,
|
||||||
move_from_ready_to_scheduled,
|
move_from_ready_to_scheduled,
|
||||||
allocate_processor,
|
allocate_processor,
|
||||||
get_idle_node,
|
get_idle_node
|
||||||
release_idle_node
|
|
||||||
);
|
);
|
||||||
} else if ( node_state == SCHEDULER_SMP_NODE_READY ) {
|
} else if ( node_state == SCHEDULER_SMP_NODE_READY ) {
|
||||||
|
_Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED );
|
||||||
( *extract_from_ready )( context, node );
|
( *extract_from_ready )( context, node );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1683,8 +1679,7 @@ static inline void _Scheduler_SMP_Withdraw_node(
|
|||||||
Scheduler_SMP_Get_highest_ready get_highest_ready,
|
Scheduler_SMP_Get_highest_ready get_highest_ready,
|
||||||
Scheduler_SMP_Move move_from_ready_to_scheduled,
|
Scheduler_SMP_Move move_from_ready_to_scheduled,
|
||||||
Scheduler_SMP_Allocate_processor allocate_processor,
|
Scheduler_SMP_Allocate_processor allocate_processor,
|
||||||
Scheduler_Get_idle_node get_idle_node,
|
Scheduler_Get_idle_node get_idle_node
|
||||||
Scheduler_Release_idle_node release_idle_node
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ISR_lock_Context lock_context;
|
ISR_lock_Context lock_context;
|
||||||
@@ -1693,30 +1688,32 @@ static inline void _Scheduler_SMP_Withdraw_node(
|
|||||||
_Thread_Scheduler_acquire_critical( thread, &lock_context );
|
_Thread_Scheduler_acquire_critical( thread, &lock_context );
|
||||||
|
|
||||||
node_state = _Scheduler_SMP_Node_state( node );
|
node_state = _Scheduler_SMP_Node_state( node );
|
||||||
_Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED );
|
|
||||||
|
|
||||||
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
|
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
|
||||||
Per_CPU_Control *thread_cpu;
|
Per_CPU_Control *cpu;
|
||||||
|
|
||||||
_Assert( thread == _Scheduler_Node_get_user( node ) );
|
_Assert( thread == _Scheduler_Node_get_user( node ) );
|
||||||
thread_cpu = _Thread_Get_CPU( thread );
|
cpu = _Thread_Get_CPU( thread );
|
||||||
_Scheduler_Thread_change_state( thread, next_state );
|
_Scheduler_Thread_change_state( thread, next_state );
|
||||||
_Thread_Scheduler_release_critical( thread, &lock_context );
|
_Thread_Scheduler_release_critical( thread, &lock_context );
|
||||||
|
|
||||||
( *extract_from_scheduled )( context, node );
|
_Assert( _Scheduler_Node_get_user( node ) == thread );
|
||||||
|
_Assert( _Scheduler_Node_get_idle( node ) == NULL );
|
||||||
|
|
||||||
_Scheduler_SMP_Schedule_highest_ready(
|
_Scheduler_SMP_Schedule_highest_ready(
|
||||||
context,
|
context,
|
||||||
node,
|
node,
|
||||||
thread_cpu,
|
cpu,
|
||||||
|
extract_from_scheduled,
|
||||||
extract_from_ready,
|
extract_from_ready,
|
||||||
get_highest_ready,
|
get_highest_ready,
|
||||||
move_from_ready_to_scheduled,
|
move_from_ready_to_scheduled,
|
||||||
allocate_processor,
|
allocate_processor,
|
||||||
get_idle_node,
|
get_idle_node
|
||||||
release_idle_node
|
|
||||||
);
|
);
|
||||||
} else if ( node_state == SCHEDULER_SMP_NODE_READY ) {
|
} else if ( node_state == SCHEDULER_SMP_NODE_READY ) {
|
||||||
_Thread_Scheduler_release_critical( thread, &lock_context );
|
_Thread_Scheduler_release_critical( thread, &lock_context );
|
||||||
|
_Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED );
|
||||||
( *extract_from_ready )( context, node );
|
( *extract_from_ready )( context, node );
|
||||||
} else {
|
} else {
|
||||||
_Assert( node_state == SCHEDULER_SMP_NODE_BLOCKED );
|
_Assert( node_state == SCHEDULER_SMP_NODE_BLOCKED );
|
||||||
@@ -1789,25 +1786,29 @@ static inline void _Scheduler_SMP_Clean_sticky(
|
|||||||
|
|
||||||
node_state = _Scheduler_SMP_Node_state( node );
|
node_state = _Scheduler_SMP_Node_state( node );
|
||||||
|
|
||||||
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED && node->idle != NULL ) {
|
if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
|
||||||
Scheduler_Context *context;
|
Thread_Control *idle;
|
||||||
|
|
||||||
context = _Scheduler_Get_context( scheduler );
|
idle = _Scheduler_Node_get_idle( node );
|
||||||
|
|
||||||
_Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED );
|
if ( idle != NULL ) {
|
||||||
( *extract_from_scheduled )( context, node );
|
Scheduler_Context *context;
|
||||||
|
|
||||||
_Scheduler_SMP_Schedule_highest_ready(
|
context = _Scheduler_Get_context( scheduler );
|
||||||
context,
|
|
||||||
node,
|
_Scheduler_Release_idle_thread( node, idle, release_idle_node, context );
|
||||||
_Thread_Get_CPU( node->idle ),
|
_Scheduler_SMP_Schedule_highest_ready(
|
||||||
extract_from_ready,
|
context,
|
||||||
get_highest_ready,
|
node,
|
||||||
move_from_ready_to_scheduled,
|
_Thread_Get_CPU( idle ),
|
||||||
allocate_processor,
|
extract_from_scheduled,
|
||||||
get_idle_node,
|
extract_from_ready,
|
||||||
release_idle_node
|
get_highest_ready,
|
||||||
);
|
move_from_ready_to_scheduled,
|
||||||
|
allocate_processor,
|
||||||
|
get_idle_node
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -534,8 +534,7 @@ void _Scheduler_EDF_SMP_Block(
|
|||||||
_Scheduler_EDF_SMP_Get_highest_ready,
|
_Scheduler_EDF_SMP_Get_highest_ready,
|
||||||
_Scheduler_EDF_SMP_Move_from_ready_to_scheduled,
|
_Scheduler_EDF_SMP_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_EDF_SMP_Allocate_processor,
|
_Scheduler_EDF_SMP_Allocate_processor,
|
||||||
_Scheduler_EDF_SMP_Get_idle,
|
_Scheduler_EDF_SMP_Get_idle
|
||||||
_Scheduler_EDF_SMP_Release_idle
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,8 +690,7 @@ void _Scheduler_EDF_SMP_Withdraw_node(
|
|||||||
_Scheduler_EDF_SMP_Get_highest_ready,
|
_Scheduler_EDF_SMP_Get_highest_ready,
|
||||||
_Scheduler_EDF_SMP_Move_from_ready_to_scheduled,
|
_Scheduler_EDF_SMP_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_EDF_SMP_Allocate_processor,
|
_Scheduler_EDF_SMP_Allocate_processor,
|
||||||
_Scheduler_EDF_SMP_Get_idle,
|
_Scheduler_EDF_SMP_Get_idle
|
||||||
_Scheduler_EDF_SMP_Release_idle
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -192,8 +192,7 @@ void _Scheduler_priority_affinity_SMP_Block(
|
|||||||
_Scheduler_priority_affinity_SMP_Get_highest_ready,
|
_Scheduler_priority_affinity_SMP_Get_highest_ready,
|
||||||
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
|
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_SMP_Allocate_processor_exact,
|
_Scheduler_SMP_Allocate_processor_exact,
|
||||||
_Scheduler_priority_SMP_Get_idle,
|
_Scheduler_priority_SMP_Get_idle
|
||||||
_Scheduler_priority_SMP_Release_idle
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -528,8 +527,7 @@ void _Scheduler_priority_affinity_SMP_Withdraw_node(
|
|||||||
_Scheduler_priority_affinity_SMP_Get_highest_ready,
|
_Scheduler_priority_affinity_SMP_Get_highest_ready,
|
||||||
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
|
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_SMP_Allocate_processor_lazy,
|
_Scheduler_SMP_Allocate_processor_lazy,
|
||||||
_Scheduler_priority_SMP_Get_idle,
|
_Scheduler_priority_SMP_Get_idle
|
||||||
_Scheduler_priority_SMP_Release_idle
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,8 +120,7 @@ void _Scheduler_priority_SMP_Block(
|
|||||||
_Scheduler_priority_SMP_Get_highest_ready,
|
_Scheduler_priority_SMP_Get_highest_ready,
|
||||||
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
|
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_SMP_Allocate_processor_lazy,
|
_Scheduler_SMP_Allocate_processor_lazy,
|
||||||
_Scheduler_priority_SMP_Get_idle,
|
_Scheduler_priority_SMP_Get_idle
|
||||||
_Scheduler_priority_SMP_Release_idle
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,8 +273,7 @@ void _Scheduler_priority_SMP_Withdraw_node(
|
|||||||
_Scheduler_priority_SMP_Get_highest_ready,
|
_Scheduler_priority_SMP_Get_highest_ready,
|
||||||
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
|
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_SMP_Allocate_processor_lazy,
|
_Scheduler_SMP_Allocate_processor_lazy,
|
||||||
_Scheduler_priority_SMP_Get_idle,
|
_Scheduler_priority_SMP_Get_idle
|
||||||
_Scheduler_priority_SMP_Release_idle
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,8 +213,7 @@ void _Scheduler_simple_SMP_Block(
|
|||||||
_Scheduler_simple_SMP_Get_highest_ready,
|
_Scheduler_simple_SMP_Get_highest_ready,
|
||||||
_Scheduler_simple_SMP_Move_from_ready_to_scheduled,
|
_Scheduler_simple_SMP_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_SMP_Allocate_processor_lazy,
|
_Scheduler_SMP_Allocate_processor_lazy,
|
||||||
_Scheduler_simple_SMP_Get_idle,
|
_Scheduler_simple_SMP_Get_idle
|
||||||
_Scheduler_simple_SMP_Release_idle
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,8 +366,7 @@ void _Scheduler_simple_SMP_Withdraw_node(
|
|||||||
_Scheduler_simple_SMP_Get_highest_ready,
|
_Scheduler_simple_SMP_Get_highest_ready,
|
||||||
_Scheduler_simple_SMP_Move_from_ready_to_scheduled,
|
_Scheduler_simple_SMP_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_SMP_Allocate_processor_lazy,
|
_Scheduler_SMP_Allocate_processor_lazy,
|
||||||
_Scheduler_simple_SMP_Get_idle,
|
_Scheduler_simple_SMP_Get_idle
|
||||||
_Scheduler_simple_SMP_Release_idle
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -920,8 +920,7 @@ void _Scheduler_strong_APA_Block(
|
|||||||
_Scheduler_strong_APA_Get_highest_ready,
|
_Scheduler_strong_APA_Get_highest_ready,
|
||||||
_Scheduler_strong_APA_Move_from_ready_to_scheduled,
|
_Scheduler_strong_APA_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_strong_APA_Allocate_processor,
|
_Scheduler_strong_APA_Allocate_processor,
|
||||||
_Scheduler_strong_APA_Get_idle,
|
_Scheduler_strong_APA_Get_idle
|
||||||
_Scheduler_strong_APA_Release_idle
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1014,8 +1013,7 @@ void _Scheduler_strong_APA_Withdraw_node(
|
|||||||
_Scheduler_strong_APA_Get_highest_ready,
|
_Scheduler_strong_APA_Get_highest_ready,
|
||||||
_Scheduler_strong_APA_Move_from_ready_to_scheduled,
|
_Scheduler_strong_APA_Move_from_ready_to_scheduled,
|
||||||
_Scheduler_strong_APA_Allocate_processor,
|
_Scheduler_strong_APA_Allocate_processor,
|
||||||
_Scheduler_strong_APA_Get_idle,
|
_Scheduler_strong_APA_Get_idle
|
||||||
_Scheduler_strong_APA_Release_idle
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user