Changeset 82df6f3 in rtems


Ignore:
Timestamp:
Jun 12, 2014, 7:06:53 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
4639002
Parents:
6500614
Message:

score: Move NULL pointer check to order function

This helps to avoid untestable code for the normal SMP schedulers.

Location:
cpukit/score
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/schedulersmpimpl.h

    r6500614 r82df6f3  
    472472 *   of scheduled nodes to the set of ready nodes.
    473473 * @param[in] get_lowest_scheduled Function to select the thread from the
    474  *   scheduled nodes to replace. It may not be possible to find one.
     474 *   scheduled nodes to replace.  It may not be possible to find one, in this
     475 *   case a pointer must be returned so that the order functions returns false
     476 *   if this pointer is passed as the second argument to the order function.
    475477 * @param[in] allocate_processor Function to allocate a processor to a thread
    476478 *   based on the rules of the scheduler.
     
    491493    ( *get_lowest_scheduled )( context, thread, order );
    492494
    493   /*
    494    *  get_lowest_scheduled can return a NULL if no scheduled threads
    495    *  should be removed from their processor based on the selection
    496    *  criteria. For example, this can occur when the affinity of the
    497    *  thread being enqueued schedules it against higher priority threads.
    498    *  A low priority thread with affinity can only consider the threads
    499    *  which are on the cores if has affinity for.
    500    *
    501    *  The get_lowest_scheduled helper should assert on not returning NULL
    502    *  if that is not possible for that scheduler.
    503    */
    504 
    505   if ( lowest_scheduled &&
    506        ( *order )( &thread->Object.Node, &lowest_scheduled->Object.Node ) ) {
     495  if ( ( *order )( &thread->Object.Node, &lowest_scheduled->Object.Node ) ) {
    507496    Scheduler_SMP_Node *lowest_scheduled_node =
    508497      _Scheduler_SMP_Node_get( lowest_scheduled );
  • cpukit/score/src/schedulerpriorityaffinitysmp.c

    r6500614 r82df6f3  
    4242 *  + _Scheduler_priority_SMP_Do_update
    4343 */
     44
     45static bool _Scheduler_priority_affinity_SMP_Insert_priority_lifo_order(
     46  const Chain_Node *to_insert,
     47  const Chain_Node *next
     48)
     49{
     50  const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
     51  const Thread_Control *thread_next = (const Thread_Control *) next;
     52
     53  return next != NULL
     54    && thread_to_insert->current_priority <= thread_next->current_priority;
     55}
     56
     57static bool _Scheduler_priority_affinity_SMP_Insert_priority_fifo_order(
     58  const Chain_Node *to_insert,
     59  const Chain_Node *next
     60)
     61{
     62  const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
     63  const Thread_Control *thread_next = (const Thread_Control *) next;
     64
     65  return next != NULL
     66    && thread_to_insert->current_priority < thread_next->current_priority;
     67}
    4468
    4569/*
     
    269293    context,
    270294    thread,
    271     _Scheduler_simple_Insert_priority_fifo_order,
     295    _Scheduler_priority_affinity_SMP_Insert_priority_fifo_order,
    272296    _Scheduler_priority_SMP_Insert_ready_fifo,
    273297    _Scheduler_SMP_Insert_scheduled_fifo,
     
    403427    context,
    404428    thread,
    405     _Scheduler_simple_Insert_priority_lifo_order,
     429    _Scheduler_priority_affinity_SMP_Insert_priority_lifo_order,
    406430    _Scheduler_priority_SMP_Insert_ready_lifo,
    407431    _Scheduler_SMP_Insert_scheduled_lifo
Note: See TracChangeset for help on using the changeset viewer.