diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-06-12 09:06:53 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-06-12 09:06:53 +0200 |
commit | 82df6f347b9c6705684300248ff74784d58b2b86 (patch) | |
tree | 0fedc33e8e2d72840ea43e31d2d47a2dda6cc454 | |
parent | 65006149b987013f8b0558d6635e1e595041bdce (diff) |
score: Move NULL pointer check to order function
This helps to avoid untestable code for the normal SMP schedulers.
-rw-r--r-- | cpukit/score/include/rtems/score/schedulersmpimpl.h | 19 | ||||
-rw-r--r-- | cpukit/score/src/schedulerpriorityaffinitysmp.c | 28 |
2 files changed, 30 insertions, 17 deletions
diff --git a/cpukit/score/include/rtems/score/schedulersmpimpl.h b/cpukit/score/include/rtems/score/schedulersmpimpl.h index ee81955f8c..b4126b5d6d 100644 --- a/cpukit/score/include/rtems/score/schedulersmpimpl.h +++ b/cpukit/score/include/rtems/score/schedulersmpimpl.h @@ -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 ); diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c index 6677126688..f5ab8cf158 100644 --- a/cpukit/score/src/schedulerpriorityaffinitysmp.c +++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c @@ -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 ); |