Changeset 19e41767 in rtems


Ignore:
Timestamp:
07/08/14 08:38:19 (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
08d9760
Parents:
835b88b
git-author:
Sebastian Huber <sebastian.huber@…> (07/08/14 08:38:19)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/08/14 14:30:48)
Message:

score: Simplify SMP processor allocation

Avoid copy and paste and set the scheduler node state in one place.

Location:
cpukit/score
Files:
4 edited

Legend:

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

    r835b88b r19e41767  
    314314typedef void ( *Scheduler_SMP_Allocate_processor )(
    315315  Scheduler_Context *context,
    316   Scheduler_Node    *scheduled,
    317   Scheduler_Node    *victim
     316  Thread_Control    *scheduled,
     317  Thread_Control    *victim
    318318);
    319319
     
    411411}
    412412
    413 static inline void _Scheduler_SMP_Allocate_processor(
    414   Scheduler_Context *context,
    415   Scheduler_Node    *scheduled,
    416   Scheduler_Node    *victim
    417 )
    418 {
    419   Thread_Control *scheduled_thread = _Scheduler_Node_get_owner( scheduled );
    420   Thread_Control *victim_thread = _Scheduler_Node_get_owner( victim );
     413static inline void _Scheduler_SMP_Allocate_processor_lazy(
     414  Scheduler_Context *context,
     415  Thread_Control    *scheduled_thread,
     416  Thread_Control    *victim_thread
     417)
     418{
    421419  Per_CPU_Control *scheduled_cpu = _Thread_Get_CPU( scheduled_thread );
    422420  Per_CPU_Control *victim_cpu = _Thread_Get_CPU( victim_thread );
    423421  Per_CPU_Control *cpu_self = _Per_CPU_Get();
    424422  Thread_Control *heir;
    425 
    426   _Scheduler_SMP_Node_change_state(
    427     _Scheduler_SMP_Node_downcast( scheduled ),
    428     SCHEDULER_SMP_NODE_SCHEDULED
    429   );
    430423
    431424  _Assert( _ISR_Get_level() != 0 );
     
    454447    _Thread_Dispatch_update_heir( cpu_self, victim_cpu, heir );
    455448  }
     449}
     450
     451static inline void _Scheduler_SMP_Allocate_processor(
     452  Scheduler_Context                *context,
     453  Scheduler_Node                   *scheduled,
     454  Scheduler_Node                   *victim,
     455  Scheduler_SMP_Allocate_processor  allocate_processor
     456)
     457{
     458  Thread_Control *scheduled_thread = _Scheduler_Node_get_owner( scheduled );
     459  Thread_Control *victim_thread = _Scheduler_Node_get_owner( victim );
     460
     461  _Scheduler_SMP_Node_change_state(
     462    _Scheduler_SMP_Node_downcast( scheduled ),
     463    SCHEDULER_SMP_NODE_SCHEDULED
     464  );
     465
     466  ( *allocate_processor )( context, scheduled_thread, victim_thread );
    456467}
    457468
     
    515526      SCHEDULER_SMP_NODE_READY
    516527    );
    517     ( *allocate_processor )( context, node, lowest_scheduled );
     528
     529    _Scheduler_SMP_Allocate_processor(
     530      context,
     531      node,
     532      lowest_scheduled,
     533      allocate_processor
     534    );
     535
    518536    ( *insert_scheduled )( context, node );
    519537    ( *move_from_scheduled_to_ready )( context, lowest_scheduled );
     
    566584      SCHEDULER_SMP_NODE_READY
    567585    );
    568     ( *allocate_processor) ( context, highest_ready, node );
     586
     587    _Scheduler_SMP_Allocate_processor(
     588      context,
     589      highest_ready,
     590      node,
     591      allocate_processor
     592    );
     593
    569594    ( *insert_ready )( context, node );
    570595    ( *move_from_ready_to_scheduled )( context, highest_ready );
     
    589614  Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim );
    590615
    591   ( *allocate_processor )( context, highest_ready, victim );
     616  _Scheduler_SMP_Allocate_processor(
     617    context,
     618    highest_ready,
     619    victim,
     620    allocate_processor
     621  );
     622
    592623  ( *move_from_ready_to_scheduled )( context, highest_ready );
    593624}
  • cpukit/score/src/schedulerpriorityaffinitysmp.c

    r835b88b r19e41767  
    105105
    106106/*
    107  * This method is slightly different from _Scheduler_SMP_Allocate_processor()
    108  * in that it does what it is asked to do. _Scheduler_SMP_Allocate_processor()
    109  * attempts to prevent migrations but does not take into account affinity
     107 * This method is slightly different from
     108 * _Scheduler_SMP_Allocate_processor_lazy() in that it does what it is asked to
     109 * do. _Scheduler_SMP_Allocate_processor_lazy() attempts to prevent migrations
     110 * but does not take into account affinity
    110111 */
    111112static inline void _Scheduler_SMP_Allocate_processor_exact(
    112    Scheduler_Context *context,
    113    Scheduler_Node    *scheduled,
    114    Scheduler_Node    *victim
    115 )
    116 {
    117   Thread_Control  *victim_thread = _Scheduler_Node_get_owner( victim );
    118   Thread_Control  *scheduled_thread = _Scheduler_Node_get_owner( scheduled );
     113  Scheduler_Context *context,
     114  Thread_Control    *scheduled_thread,
     115  Thread_Control    *victim_thread
     116)
     117{
    119118  Per_CPU_Control *victim_cpu = _Thread_Get_CPU( victim_thread );
    120119  Per_CPU_Control *cpu_self = _Per_CPU_Get();
    121120
    122121  (void) context;
    123 
    124   _Scheduler_SMP_Node_change_state(
    125     _Scheduler_SMP_Node_downcast( scheduled ),
    126     SCHEDULER_SMP_NODE_SCHEDULED
    127   );
    128122
    129123  _Thread_Set_CPU( scheduled_thread, victim_cpu );
     
    359353    );
    360354
    361     _Scheduler_SMP_Allocate_processor_exact(
     355    _Scheduler_SMP_Allocate_processor(
    362356      context,
    363357      highest_ready,
    364       lowest_scheduled
     358      lowest_scheduled,
     359      _Scheduler_SMP_Allocate_processor_exact
    365360    );
    366361
  • cpukit/score/src/schedulerprioritysmp.c

    r835b88b r19e41767  
    9494    _Scheduler_priority_SMP_Get_highest_ready,
    9595    _Scheduler_priority_SMP_Move_from_ready_to_scheduled,
    96     _Scheduler_SMP_Allocate_processor
     96    _Scheduler_SMP_Allocate_processor_lazy
    9797  );
    9898}
     
    114114    _Scheduler_priority_SMP_Move_from_scheduled_to_ready,
    115115    _Scheduler_SMP_Get_lowest_scheduled,
    116     _Scheduler_SMP_Allocate_processor
     116    _Scheduler_SMP_Allocate_processor_lazy
    117117  );
    118118}
     
    162162    insert_scheduled,
    163163    _Scheduler_priority_SMP_Move_from_ready_to_scheduled,
    164     _Scheduler_SMP_Allocate_processor
     164    _Scheduler_SMP_Allocate_processor_lazy
    165165  );
    166166}
  • cpukit/score/src/schedulersimplesmp.c

    r835b88b r19e41767  
    176176    _Scheduler_simple_SMP_Get_highest_ready,
    177177    _Scheduler_simple_SMP_Move_from_ready_to_scheduled,
    178     _Scheduler_SMP_Allocate_processor
     178    _Scheduler_SMP_Allocate_processor_lazy
    179179  );
    180180}
     
    196196    _Scheduler_simple_SMP_Move_from_scheduled_to_ready,
    197197    _Scheduler_SMP_Get_lowest_scheduled,
    198     _Scheduler_SMP_Allocate_processor
     198    _Scheduler_SMP_Allocate_processor_lazy
    199199  );
    200200}
     
    244244    insert_scheduled,
    245245    _Scheduler_simple_SMP_Move_from_ready_to_scheduled,
    246     _Scheduler_SMP_Allocate_processor
     246    _Scheduler_SMP_Allocate_processor_lazy
    247247  );
    248248}
Note: See TracChangeset for help on using the changeset viewer.