mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 19:11:44 +08:00
score: Move NULL pointer check to order function
This helps to avoid untestable code for the normal SMP schedulers.
This commit is contained in:
@@ -471,7 +471,9 @@ static inline Thread_Control *_Scheduler_SMP_Get_lowest_scheduled(
|
||||
* @param[in] move_from_scheduled_to_ready Function to move a node from the set
|
||||
* of scheduled nodes to the set of ready nodes.
|
||||
* @param[in] get_lowest_scheduled Function to select the thread from the
|
||||
* scheduled nodes to replace. It may not be possible to find one.
|
||||
* scheduled nodes to replace. It may not be possible to find one, in this
|
||||
* case a pointer must be returned so that the order functions returns false
|
||||
* if this pointer is passed as the second argument to the order function.
|
||||
* @param[in] allocate_processor Function to allocate a processor to a thread
|
||||
* based on the rules of the scheduler.
|
||||
*/
|
||||
@@ -490,20 +492,7 @@ static inline void _Scheduler_SMP_Enqueue_ordered(
|
||||
Thread_Control *lowest_scheduled =
|
||||
( *get_lowest_scheduled )( context, thread, order );
|
||||
|
||||
/*
|
||||
* get_lowest_scheduled can return a NULL if no scheduled threads
|
||||
* should be removed from their processor based on the selection
|
||||
* criteria. For example, this can occur when the affinity of the
|
||||
* thread being enqueued schedules it against higher priority threads.
|
||||
* A low priority thread with affinity can only consider the threads
|
||||
* which are on the cores if has affinity for.
|
||||
*
|
||||
* The get_lowest_scheduled helper should assert on not returning NULL
|
||||
* if that is not possible for that scheduler.
|
||||
*/
|
||||
|
||||
if ( lowest_scheduled &&
|
||||
( *order )( &thread->Object.Node, &lowest_scheduled->Object.Node ) ) {
|
||||
if ( ( *order )( &thread->Object.Node, &lowest_scheduled->Object.Node ) ) {
|
||||
Scheduler_SMP_Node *lowest_scheduled_node =
|
||||
_Scheduler_SMP_Node_get( lowest_scheduled );
|
||||
|
||||
|
||||
@@ -42,6 +42,30 @@
|
||||
* + _Scheduler_priority_SMP_Do_update
|
||||
*/
|
||||
|
||||
static bool _Scheduler_priority_affinity_SMP_Insert_priority_lifo_order(
|
||||
const Chain_Node *to_insert,
|
||||
const Chain_Node *next
|
||||
)
|
||||
{
|
||||
const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
|
||||
const Thread_Control *thread_next = (const Thread_Control *) next;
|
||||
|
||||
return next != NULL
|
||||
&& thread_to_insert->current_priority <= thread_next->current_priority;
|
||||
}
|
||||
|
||||
static bool _Scheduler_priority_affinity_SMP_Insert_priority_fifo_order(
|
||||
const Chain_Node *to_insert,
|
||||
const Chain_Node *next
|
||||
)
|
||||
{
|
||||
const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
|
||||
const Thread_Control *thread_next = (const Thread_Control *) next;
|
||||
|
||||
return next != NULL
|
||||
&& thread_to_insert->current_priority < thread_next->current_priority;
|
||||
}
|
||||
|
||||
/*
|
||||
* This method returns the scheduler node for the specified thread
|
||||
* as a scheduler specific type.
|
||||
@@ -268,7 +292,7 @@ static void _Scheduler_priority_affinity_SMP_Enqueue_fifo(
|
||||
_Scheduler_SMP_Enqueue_ordered(
|
||||
context,
|
||||
thread,
|
||||
_Scheduler_simple_Insert_priority_fifo_order,
|
||||
_Scheduler_priority_affinity_SMP_Insert_priority_fifo_order,
|
||||
_Scheduler_priority_SMP_Insert_ready_fifo,
|
||||
_Scheduler_SMP_Insert_scheduled_fifo,
|
||||
_Scheduler_priority_SMP_Move_from_scheduled_to_ready,
|
||||
@@ -402,7 +426,7 @@ static void _Scheduler_priority_affinity_SMP_Enqueue_lifo(
|
||||
_Scheduler_priority_affinity_SMP_Enqueue_ordered(
|
||||
context,
|
||||
thread,
|
||||
_Scheduler_simple_Insert_priority_lifo_order,
|
||||
_Scheduler_priority_affinity_SMP_Insert_priority_lifo_order,
|
||||
_Scheduler_priority_SMP_Insert_ready_lifo,
|
||||
_Scheduler_SMP_Insert_scheduled_lifo
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user