Changeset 3730a07f in rtems


Ignore:
Timestamp:
May 13, 2014, 1:08:07 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
b2d191e
Parents:
e9ee2f0
git-author:
Sebastian Huber <sebastian.huber@…> (05/13/14 13:08:07)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/14/14 12:46:20)
Message:

score: Use Scheduler_Context for SMP scheduler

Use the basic Scheduler_Context for the general SMP scheduler operations
to avoid usage of structure offsets to get the specialized context
variants.

Location:
cpukit/score
Files:
3 edited

Legend:

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

    re9ee2f0 r3730a07f  
    315315
    316316typedef Thread_Control *( *Scheduler_SMP_Get_highest_ready )(
    317   Scheduler_SMP_Context *self
     317  Scheduler_Context *context
    318318);
    319319
    320320typedef void ( *Scheduler_SMP_Extract )(
    321   Scheduler_SMP_Context *self,
     321  Scheduler_Context *context,
    322322  Thread_Control *thread
    323323);
    324324
    325325typedef void ( *Scheduler_SMP_Insert )(
    326   Scheduler_SMP_Context *self,
     326  Scheduler_Context *context,
    327327  Thread_Control *thread_to_insert
    328328);
    329329
    330330typedef void ( *Scheduler_SMP_Move )(
    331   Scheduler_SMP_Context *self,
     331  Scheduler_Context *context,
    332332  Thread_Control *thread_to_move
    333333);
     334
     335static inline Scheduler_SMP_Context *_Scheduler_SMP_Get_self(
     336  Scheduler_Context *context
     337)
     338{
     339  return (Scheduler_SMP_Context *) context;
     340}
    334341
    335342static inline void _Scheduler_SMP_Initialize(
     
    473480 */
    474481static inline void _Scheduler_SMP_Enqueue_ordered(
    475   Scheduler_SMP_Context *self,
     482  Scheduler_Context *context,
    476483  Thread_Control *thread,
    477484  Chain_Node_order order,
     
    483490)
    484491{
     492  Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
    485493  Scheduler_SMP_Node *node = _Scheduler_SMP_Node_get( thread );
    486494
    487495  if ( node->state == SCHEDULER_SMP_NODE_IN_THE_AIR ) {
    488     Thread_Control *highest_ready = ( *get_highest_ready )( self );
     496    Thread_Control *highest_ready = ( *get_highest_ready )( &self->Base );
    489497
    490498    /*
     
    500508      _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY );
    501509      _Scheduler_SMP_Allocate_processor( self, highest_ready, thread );
    502       ( *insert_ready )( self, thread );
    503       ( *move_from_ready_to_scheduled )( self, highest_ready );
     510      ( *insert_ready )( &self->Base, thread );
     511      ( *move_from_ready_to_scheduled )( &self->Base, highest_ready );
    504512    } else {
    505513      _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_SCHEDULED );
    506       ( *insert_scheduled )( self, thread );
     514      ( *insert_scheduled )( &self->Base, thread );
    507515    }
    508516  } else {
    509     Thread_Control *lowest_scheduled = _Scheduler_SMP_Get_lowest_scheduled( self );
     517    Thread_Control *lowest_scheduled =
     518      _Scheduler_SMP_Get_lowest_scheduled( self );
    510519
    511520    /*
     
    525534      );
    526535      _Scheduler_SMP_Allocate_processor( self, thread, lowest_scheduled );
    527       ( *insert_scheduled )( self, thread );
    528       ( *move_from_scheduled_to_ready )( self, lowest_scheduled );
     536      ( *insert_scheduled )( &self->Base, thread );
     537      ( *move_from_scheduled_to_ready )( &self->Base, lowest_scheduled );
    529538    } else {
    530539      _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY );
    531       ( *insert_ready )( self, thread );
     540      ( *insert_ready )( &self->Base, thread );
    532541    }
    533542  }
     
    535544
    536545static inline void _Scheduler_SMP_Schedule_highest_ready(
    537   Scheduler_SMP_Context *self,
     546  Scheduler_Context *context,
    538547  Thread_Control *victim,
    539548  Scheduler_SMP_Get_highest_ready get_highest_ready,
     
    541550)
    542551{
    543   Thread_Control *highest_ready = ( *get_highest_ready )( self );
     552  Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
     553  Thread_Control *highest_ready = ( *get_highest_ready )( &self->Base );
    544554
    545555  _Scheduler_SMP_Allocate_processor( self, highest_ready, victim );
    546556
    547   ( *move_from_ready_to_scheduled )( self, highest_ready );
     557  ( *move_from_ready_to_scheduled )( &self->Base, highest_ready );
    548558}
    549559
     
    558568 */
    559569static inline void _Scheduler_SMP_Schedule(
    560   Scheduler_SMP_Context *self,
     570  Scheduler_Context *context,
    561571  Thread_Control *thread,
    562572  Scheduler_SMP_Get_highest_ready get_highest_ready,
     
    570580
    571581    _Scheduler_SMP_Schedule_highest_ready(
    572       self,
     582      context,
    573583      thread,
    574584      get_highest_ready,
     
    579589
    580590static inline void _Scheduler_SMP_Block(
    581   Scheduler_SMP_Context *self,
     591  Scheduler_Context *context,
    582592  Thread_Control *thread,
    583593  Scheduler_SMP_Extract extract,
     
    586596)
    587597{
    588   ( *extract )( self, thread );
     598  ( *extract )( context, thread );
    589599
    590600  _Scheduler_SMP_Schedule(
    591     self,
     601    context,
    592602    thread,
    593603    get_highest_ready,
     
    605615 */
    606616static inline void _Scheduler_SMP_Extract(
    607   Scheduler_SMP_Context *self,
     617  Scheduler_Context *context,
    608618  Thread_Control *thread,
    609619  Scheduler_SMP_Extract extract
    610620)
    611621{
    612   ( *extract )( self, thread );
     622  ( *extract )( context, thread );
    613623}
    614624
    615625static inline void _Scheduler_SMP_Insert_scheduled_lifo(
    616   Scheduler_SMP_Context *self,
     626  Scheduler_Context *context,
    617627  Thread_Control *thread
    618628)
    619629{
     630  Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
     631
    620632  _Chain_Insert_ordered_unprotected(
    621633    &self->Scheduled,
     
    626638
    627639static inline void _Scheduler_SMP_Insert_scheduled_fifo(
    628   Scheduler_SMP_Context *self,
     640  Scheduler_Context *context,
    629641  Thread_Control *thread
    630642)
    631643{
     644  Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
     645
    632646  _Chain_Insert_ordered_unprotected(
    633647    &self->Scheduled,
     
    638652
    639653static inline void _Scheduler_SMP_Start_idle(
    640   Scheduler_SMP_Context *self,
     654  Scheduler_Context *context,
    641655  Thread_Control *thread,
    642656  Per_CPU_Control *cpu
    643657)
    644658{
     659  Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
    645660  Scheduler_SMP_Node *node = _Scheduler_SMP_Node_get( thread );
    646661
  • cpukit/score/src/schedulerprioritysmp.c

    re9ee2f0 r3730a07f  
    3737
    3838static Scheduler_priority_SMP_Context *
    39 _Scheduler_priority_SMP_Self_from_SMP_base( Scheduler_SMP_Context *smp_base )
    40 {
    41   return (Scheduler_priority_SMP_Context *)
    42     ( (char *) smp_base
    43       - offsetof( Scheduler_priority_SMP_Context, Base ) );
     39_Scheduler_priority_SMP_Get_self( Scheduler_Context *context )
     40{
     41  return (Scheduler_priority_SMP_Context *) context;
    4442}
    4543
     
    9290
    9391static Thread_Control *_Scheduler_priority_SMP_Get_highest_ready(
    94   Scheduler_SMP_Context *smp_base
    95 )
    96 {
    97   Scheduler_priority_SMP_Context *self =
    98     _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
     92  Scheduler_Context *context
     93)
     94{
     95  Scheduler_priority_SMP_Context *self =
     96    _Scheduler_priority_SMP_Get_self( context );
    9997  Thread_Control *highest_ready = NULL;
    10098
     
    110108
    111109static void _Scheduler_priority_SMP_Move_from_scheduled_to_ready(
    112   Scheduler_SMP_Context *smp_base,
     110  Scheduler_Context *context,
    113111  Thread_Control *scheduled_to_ready
    114112)
    115113{
    116114  Scheduler_priority_SMP_Context *self =
    117     _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
     115    _Scheduler_priority_SMP_Get_self( context );
    118116  Scheduler_priority_SMP_Node *node =
    119117    _Scheduler_priority_SMP_Node_get( scheduled_to_ready );
     
    128126
    129127static void _Scheduler_priority_SMP_Move_from_ready_to_scheduled(
    130   Scheduler_SMP_Context *smp_base,
     128  Scheduler_Context *context,
    131129  Thread_Control *ready_to_scheduled
    132130)
    133131{
    134132  Scheduler_priority_SMP_Context *self =
    135     _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
     133    _Scheduler_priority_SMP_Get_self( context );
    136134  Scheduler_priority_SMP_Node *node =
    137135    _Scheduler_priority_SMP_Node_get( ready_to_scheduled );
     
    149147
    150148static void _Scheduler_priority_SMP_Insert_ready_lifo(
    151   Scheduler_SMP_Context *smp_base,
    152   Thread_Control *thread
    153 )
    154 {
    155   Scheduler_priority_SMP_Context *self =
    156     _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
     149  Scheduler_Context *context,
     150  Thread_Control *thread
     151)
     152{
     153  Scheduler_priority_SMP_Context *self =
     154    _Scheduler_priority_SMP_Get_self( context );
    157155  Scheduler_priority_SMP_Node *node =
    158156    _Scheduler_priority_SMP_Node_get( thread );
     
    166164
    167165static void _Scheduler_priority_SMP_Insert_ready_fifo(
    168   Scheduler_SMP_Context *smp_base,
    169   Thread_Control *thread
    170 )
    171 {
    172   Scheduler_priority_SMP_Context *self =
    173     _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
     166  Scheduler_Context *context,
     167  Thread_Control *thread
     168)
     169{
     170  Scheduler_priority_SMP_Context *self =
     171    _Scheduler_priority_SMP_Get_self( context );
    174172  Scheduler_priority_SMP_Node *node =
    175173    _Scheduler_priority_SMP_Node_get( thread );
     
    183181
    184182static void _Scheduler_priority_SMP_Do_extract(
    185   Scheduler_SMP_Context *smp_base,
    186   Thread_Control *thread
    187 )
    188 {
    189   Scheduler_priority_SMP_Context *self =
    190     _Scheduler_priority_SMP_Self_from_SMP_base( smp_base );
     183  Scheduler_Context *context,
     184  Thread_Control *thread
     185)
     186{
     187  Scheduler_priority_SMP_Context *self =
     188    _Scheduler_priority_SMP_Get_self( context );
    191189  Scheduler_priority_SMP_Node *node =
    192190    _Scheduler_priority_SMP_Node_get( thread );
     
    220218
    221219  _Scheduler_SMP_Block(
    222     &self->Base,
     220    &self->Base.Base,
    223221    thread,
    224222    _Scheduler_priority_SMP_Do_extract,
     
    229227
    230228static void _Scheduler_priority_SMP_Enqueue_ordered(
    231   Scheduler_SMP_Context *self,
     229  Scheduler_Context *context,
    232230  Thread_Control *thread,
    233231  Chain_Node_order order,
     
    237235{
    238236  _Scheduler_SMP_Enqueue_ordered(
    239     self,
     237    context,
    240238    thread,
    241239    order,
     
    257255
    258256  _Scheduler_priority_SMP_Enqueue_ordered(
    259     &self->Base,
     257    &self->Base.Base,
    260258    thread,
    261259    _Scheduler_simple_Insert_priority_lifo_order,
     
    274272
    275273  _Scheduler_priority_SMP_Enqueue_ordered(
    276     &self->Base,
     274    &self->Base.Base,
    277275    thread,
    278276    _Scheduler_simple_Insert_priority_fifo_order,
     
    291289
    292290  _Scheduler_SMP_Extract(
    293     &self->Base,
     291    &self->Base.Base,
    294292    thread,
    295293    _Scheduler_priority_SMP_Do_extract
     
    321319
    322320  _Scheduler_SMP_Schedule(
    323     &self->Base,
     321    &self->Base.Base,
    324322    thread,
    325323    _Scheduler_priority_SMP_Get_highest_ready,
     
    337335    _Scheduler_priority_SMP_Get_context( scheduler );
    338336
    339   _Scheduler_SMP_Start_idle( &self->Base, thread, cpu );
    340 }
     337  _Scheduler_SMP_Start_idle( &self->Base.Base, thread, cpu );
     338}
  • cpukit/score/src/schedulersimplesmp.c

    re9ee2f0 r3730a07f  
    3030
    3131static Scheduler_simple_SMP_Context *
    32 _Scheduler_simple_SMP_Self_from_SMP_base( Scheduler_SMP_Context *smp_base )
    33 {
    34   return (Scheduler_simple_SMP_Context *)
    35     ( (char *) smp_base - offsetof( Scheduler_simple_SMP_Context, Base ) );
     32_Scheduler_simple_SMP_Get_self( Scheduler_Context *context )
     33{
     34  return (Scheduler_simple_SMP_Context *) context;
    3635}
    3736
     
    5857
    5958static Thread_Control *_Scheduler_simple_SMP_Get_highest_ready(
    60   Scheduler_SMP_Context *smp_base
    61 )
    62 {
    63   Scheduler_simple_SMP_Context *self =
    64     _Scheduler_simple_SMP_Self_from_SMP_base( smp_base );
     59  Scheduler_Context *context
     60)
     61{
     62  Scheduler_simple_SMP_Context *self =
     63    _Scheduler_simple_SMP_Get_self( context );
    6564  Thread_Control *highest_ready = NULL;
    6665  Chain_Control *ready = &self->Ready;
     
    7473
    7574static void _Scheduler_simple_SMP_Move_from_scheduled_to_ready(
    76   Scheduler_SMP_Context *smp_base,
     75  Scheduler_Context *context,
    7776  Thread_Control *scheduled_to_ready
    7877)
    7978{
    8079  Scheduler_simple_SMP_Context *self =
    81     _Scheduler_simple_SMP_Self_from_SMP_base( smp_base );
     80    _Scheduler_simple_SMP_Get_self( context );
    8281
    8382  _Chain_Extract_unprotected( &scheduled_to_ready->Object.Node );
     
    8988
    9089static void _Scheduler_simple_SMP_Move_from_ready_to_scheduled(
    91   Scheduler_SMP_Context *smp_base,
     90  Scheduler_Context *context,
    9291  Thread_Control *ready_to_scheduled
    9392)
    9493{
     94  Scheduler_simple_SMP_Context *self =
     95    _Scheduler_simple_SMP_Get_self( context );
     96
    9597  _Chain_Extract_unprotected( &ready_to_scheduled->Object.Node );
    9698  _Scheduler_simple_Insert_priority_fifo(
    97     &smp_base->Scheduled,
     99    &self->Base.Scheduled,
    98100    ready_to_scheduled
    99101  );
     
    101103
    102104static void _Scheduler_simple_SMP_Insert_ready_lifo(
    103   Scheduler_SMP_Context *smp_base,
    104   Thread_Control *thread
    105 )
    106 {
    107   Scheduler_simple_SMP_Context *self =
    108     _Scheduler_simple_SMP_Self_from_SMP_base( smp_base );
     105  Scheduler_Context *context,
     106  Thread_Control *thread
     107)
     108{
     109  Scheduler_simple_SMP_Context *self =
     110    _Scheduler_simple_SMP_Get_self( context );
    109111
    110112  _Chain_Insert_ordered_unprotected(
     
    116118
    117119static void _Scheduler_simple_SMP_Insert_ready_fifo(
    118   Scheduler_SMP_Context *smp_base,
    119   Thread_Control *thread
    120 )
    121 {
    122   Scheduler_simple_SMP_Context *self =
    123     _Scheduler_simple_SMP_Self_from_SMP_base( smp_base );
     120  Scheduler_Context *context,
     121  Thread_Control *thread
     122)
     123{
     124  Scheduler_simple_SMP_Context *self =
     125    _Scheduler_simple_SMP_Get_self( context );
    124126
    125127  _Chain_Insert_ordered_unprotected(
     
    131133
    132134static void _Scheduler_simple_SMP_Do_extract(
    133   Scheduler_SMP_Context *smp_base,
     135  Scheduler_Context *context,
    134136  Thread_Control *thread
    135137)
     
    137139  Scheduler_SMP_Node *node = _Scheduler_SMP_Node_get( thread );
    138140
    139   (void) smp_base;
     141  (void) context;
    140142
    141143  if ( node->state == SCHEDULER_SMP_NODE_SCHEDULED ) {
     
    157159
    158160  _Scheduler_SMP_Block(
    159     &self->Base,
     161    &self->Base.Base,
    160162    thread,
    161163    _Scheduler_simple_SMP_Do_extract,
     
    166168
    167169static void _Scheduler_simple_SMP_Enqueue_ordered(
    168   Scheduler_SMP_Context *smp_base,
     170  Scheduler_Context *context,
    169171  Thread_Control *thread,
    170172  Chain_Node_order order,
     
    174176{
    175177  _Scheduler_SMP_Enqueue_ordered(
    176     smp_base,
     178    context,
    177179    thread,
    178180    order,
     
    194196
    195197  _Scheduler_simple_SMP_Enqueue_ordered(
    196     &self->Base,
     198    &self->Base.Base,
    197199    thread,
    198200    _Scheduler_simple_Insert_priority_lifo_order,
     
    211213
    212214  _Scheduler_simple_SMP_Enqueue_ordered(
    213     &self->Base,
     215    &self->Base.Base,
    214216    thread,
    215217    _Scheduler_simple_Insert_priority_fifo_order,
     
    228230
    229231  _Scheduler_SMP_Extract(
    230     &self->Base,
     232    &self->Base.Base,
    231233    thread,
    232234    _Scheduler_simple_SMP_Do_extract
     
    258260
    259261  _Scheduler_SMP_Schedule(
    260     &self->Base,
     262    &self->Base.Base,
    261263    thread,
    262264    _Scheduler_simple_SMP_Get_highest_ready,
     
    274276    _Scheduler_simple_SMP_Get_context( scheduler );
    275277
    276   _Scheduler_SMP_Start_idle( &self->Base, thread, cpu );
    277 }
     278  _Scheduler_SMP_Start_idle( &self->Base.Base, thread, cpu );
     279}
Note: See TracChangeset for help on using the changeset viewer.