Changeset 0c286e3 in rtems


Ignore:
Timestamp:
Oct 25, 2017, 2:00:17 PM (20 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
fb272963
Parents:
bceb9db6
git-author:
Sebastian Huber <sebastian.huber@…> (10/25/17 14:00:17)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/06/17 08:06:21)
Message:

score: _Chain_Insert_ordered_unprotected()

Change the chain order relation to use a directly specified left hand
side value. This is similar to _RBTree_Insert_inline() and helps the
compiler to better optimize the code.

Files:
9 edited

Legend:

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

    rbceb9db6 r0c286e3  
    831831 * @brief Chain node order.
    832832 *
    833  * @param[in] left The left node.
    834  * @param[in] right The right node.
     833 * @param[in] left The left hand side.
     834 * @param[in] right The right hand side.
    835835 *
    836836 * @retval true According to the order the left node precedes the right node.
     
    838838 */
    839839typedef bool ( *Chain_Node_order )(
    840   const Chain_Node *left,
     840  const void      *left,
    841841  const Chain_Node *right
    842842);
     
    849849 * after the inserted node are not moved.
    850850 *
    851  * @param[in,out] chain The chain.
    852  * @param[in,out] to_insert The node to insert.
     851 * @param[in] the_chain The chain.
     852 * @param[in] to_insert The node to insert.
     853 * @param[in] left The left hand side passed to the order relation.  It must
     854 *   correspond to the node to insert.  The separate left hand side parameter
     855 *   may help the compiler to generate better code if it is stored in a local
     856 *   variable.
    853857 * @param[in] order The order relation.
    854858 */
    855859RTEMS_INLINE_ROUTINE void _Chain_Insert_ordered_unprotected(
    856   Chain_Control *chain,
    857   Chain_Node *to_insert,
    858   Chain_Node_order order
    859 )
    860 {
    861   const Chain_Node *tail = _Chain_Immutable_tail( chain );
    862   Chain_Node *next = _Chain_First( chain );
    863 
    864   while ( next != tail && !( *order )( to_insert, next ) ) {
     860  Chain_Control    *the_chain,
     861  Chain_Node       *to_insert,
     862  const void       *left,
     863  Chain_Node_order  order
     864)
     865{
     866  const Chain_Node *tail = _Chain_Immutable_tail( the_chain );
     867  Chain_Node *next = _Chain_First( the_chain );
     868
     869  while ( next != tail && !( *order )( left, next ) ) {
    865870    next = _Chain_Next( next );
    866871  }
  • cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h

    rbceb9db6 r0c286e3  
    8989)
    9090{
    91   Scheduler_priority_SMP_Context *self =
    92     _Scheduler_priority_SMP_Get_self( context );
    93   Scheduler_priority_SMP_Node *node =
    94     _Scheduler_priority_SMP_Node_downcast( ready_to_scheduled );
     91  Scheduler_priority_SMP_Context *self;
     92  Scheduler_priority_SMP_Node    *node;
     93  Priority_Control                priority;
     94
     95  self = _Scheduler_priority_SMP_Get_self( context );
     96  node = _Scheduler_priority_SMP_Node_downcast( ready_to_scheduled );
    9597
    9698  _Scheduler_priority_Ready_queue_extract(
     
    99101    &self->Bit_map
    100102  );
     103  priority = node->Base.priority;
    101104  _Chain_Insert_ordered_unprotected(
    102105    &self->Base.Scheduled,
    103106    &node->Base.Base.Node.Chain,
     107    &priority,
    104108    _Scheduler_SMP_Insert_priority_fifo_order
    105109  );
  • cpukit/score/include/rtems/score/schedulersimpleimpl.h

    rbceb9db6 r0c286e3  
    4040
    4141RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_lifo_order(
    42   const Chain_Node *to_insert,
     42  const void      *to_insert,
    4343  const Chain_Node *next
    4444)
    4545{
    46   const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
    47   const Thread_Control *thread_next = (const Thread_Control *) next;
     46  const Priority_Control *priority_to_insert;
     47  const Thread_Control   *thread_next;
    4848
    49   return _Thread_Get_priority( thread_to_insert )
    50     <= _Thread_Get_priority( thread_next );
     49  priority_to_insert = (const Priority_Control *) to_insert;
     50  thread_next = (const Thread_Control *) next;
     51
     52  return *priority_to_insert <= _Thread_Get_priority( thread_next );
    5153}
    5254
    5355RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_fifo_order(
    54   const Chain_Node *to_insert,
     56  const void      *to_insert,
    5557  const Chain_Node *next
    5658)
    5759{
    58   const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
    59   const Thread_Control *thread_next = (const Thread_Control *) next;
     60  const Priority_Control *priority_to_insert;
     61  const Thread_Control   *thread_next;
    6062
    61   return _Thread_Get_priority( thread_to_insert )
    62     < _Thread_Get_priority( thread_next );
     63  priority_to_insert = (const Priority_Control *) to_insert;
     64  thread_next = (const Thread_Control *) next;
     65
     66  return *priority_to_insert < _Thread_Get_priority( thread_next );
    6367}
    6468
    6569RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_lifo(
    66   Chain_Control *chain,
     70  Chain_Control  *chain,
    6771  Thread_Control *to_insert
    6872)
    6973{
     74  Priority_Control priority_to_insert;
     75
     76  priority_to_insert = _Thread_Get_priority( to_insert );
     77
    7078  _Chain_Insert_ordered_unprotected(
    7179    chain,
    7280    &to_insert->Object.Node,
     81    &priority_to_insert,
    7382    _Scheduler_simple_Insert_priority_lifo_order
    7483  );
     
    7685
    7786RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_fifo(
    78   Chain_Control *chain,
     87  Chain_Control  *chain,
    7988  Thread_Control *to_insert
    8089)
    8190{
     91  Priority_Control priority_to_insert;
     92
     93  priority_to_insert = _Thread_Get_priority( to_insert );
     94
    8295  _Chain_Insert_ordered_unprotected(
    8396    chain,
    8497    &to_insert->Object.Node,
     98    &priority_to_insert,
    8599    _Scheduler_simple_Insert_priority_fifo_order
    86100  );
  • cpukit/score/include/rtems/score/schedulersmpimpl.h

    rbceb9db6 r0c286e3  
    353353
    354354static inline bool _Scheduler_SMP_Insert_priority_lifo_order(
    355   const Chain_Node *to_insert,
     355  const void      *to_insert,
    356356  const Chain_Node *next
    357357)
    358358{
    359   const Scheduler_SMP_Node *node_to_insert =
    360     (const Scheduler_SMP_Node *) to_insert;
    361   const Scheduler_SMP_Node *node_next =
    362     (const Scheduler_SMP_Node *) next;
    363 
    364   return node_to_insert->priority <= node_next->priority;
     359  const Priority_Control   *priority_to_insert;
     360  const Scheduler_SMP_Node *node_next;
     361
     362  priority_to_insert = (const Priority_Control *) to_insert;
     363  node_next = (const Scheduler_SMP_Node *) next;
     364
     365  return *priority_to_insert <= node_next->priority;
    365366}
    366367
    367368static inline bool _Scheduler_SMP_Insert_priority_fifo_order(
    368   const Chain_Node *to_insert,
     369  const void      *to_insert,
    369370  const Chain_Node *next
    370371)
    371372{
    372   const Scheduler_SMP_Node *node_to_insert =
    373     (const Scheduler_SMP_Node *) to_insert;
    374   const Scheduler_SMP_Node *node_next =
    375     (const Scheduler_SMP_Node *) next;
    376 
    377   return node_to_insert->priority < node_next->priority;
     373  const Priority_Control   *priority_to_insert;
     374  const Scheduler_SMP_Node *node_next;
     375
     376  priority_to_insert = (const Priority_Control *) to_insert;
     377  node_next = (const Scheduler_SMP_Node *) next;
     378
     379  return *priority_to_insert < node_next->priority;
    378380}
    379381
     
    720722)
    721723{
    722   bool            needs_help;
    723   Scheduler_Node *lowest_scheduled;
     724  bool              needs_help;
     725  Scheduler_Node   *lowest_scheduled;
     726  Priority_Control  node_priority;
    724727
    725728  lowest_scheduled = ( *get_lowest_scheduled )( context, node );
    726 
    727   if ( ( *order )( &node->Node.Chain, &lowest_scheduled->Node.Chain ) ) {
     729  node_priority = _Scheduler_SMP_Node_priority( node );
     730
     731  if ( ( *order )( &node_priority, &lowest_scheduled->Node.Chain ) ) {
    728732    _Scheduler_SMP_Enqueue_to_scheduled(
    729733      context,
     
    777781    Scheduler_Node                   *highest_ready;
    778782    Scheduler_Try_to_schedule_action  action;
     783    Priority_Control                  node_priority;
    779784
    780785    highest_ready = ( *get_highest_ready )( context, node );
     786    node_priority = _Scheduler_SMP_Node_priority( node );
    781787
    782788    /*
     
    786792    if (
    787793      node->sticky_level > 0
    788         && ( *order )( &node->Node.Chain, &highest_ready->Node.Chain )
     794        && ( *order )( &node_priority, &highest_ready->Node.Chain )
    789795    ) {
    790796      ( *insert_scheduled )( context, node );
     
    11661172)
    11671173{
    1168   Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
     1174  Scheduler_SMP_Context *self;
     1175  Priority_Control       priority_to_insert;
     1176
     1177  self = _Scheduler_SMP_Get_self( context );
     1178  priority_to_insert = _Scheduler_SMP_Node_priority( node_to_insert );
    11691179
    11701180  _Chain_Insert_ordered_unprotected(
    11711181    &self->Scheduled,
    11721182    &node_to_insert->Node.Chain,
     1183    &priority_to_insert,
    11731184    _Scheduler_SMP_Insert_priority_lifo_order
    11741185  );
     
    11801191)
    11811192{
    1182   Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
     1193  Scheduler_SMP_Context *self;
     1194  Priority_Control       priority_to_insert;
     1195
     1196  self = _Scheduler_SMP_Get_self( context );
     1197  priority_to_insert = _Scheduler_SMP_Node_priority( node_to_insert );
    11831198
    11841199  _Chain_Insert_ordered_unprotected(
    11851200    &self->Scheduled,
    11861201    &node_to_insert->Node.Chain,
     1202    &priority_to_insert,
    11871203    _Scheduler_SMP_Insert_priority_fifo_order
    11881204  );
     
    12151231
    12161232    if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) {
    1217       if ( ( *order )( &node->Node.Chain, &lowest_scheduled->Node.Chain ) ) {
     1233      Priority_Control node_priority;
     1234
     1235      node_priority = _Scheduler_SMP_Node_priority( node );
     1236
     1237      if ( ( *order )( &node_priority, &lowest_scheduled->Node.Chain ) ) {
    12181238        _Thread_Scheduler_cancel_need_for_help(
    12191239          thread,
  • cpukit/score/src/coremsginsert.c

    rbceb9db6 r0c286e3  
    2323#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
    2424static bool _CORE_message_queue_Order(
    25   const Chain_Node *left,
     25  const void      *left,
    2626  const Chain_Node *right
    2727)
    2828{
    29    const CORE_message_queue_Buffer_control *left_message;
     29   const int                               *left_priority;
    3030   const CORE_message_queue_Buffer_control *right_message;
    3131
    32    left_message = (const CORE_message_queue_Buffer_control *) left;
     32   left_priority = (const int *) left;
    3333   right_message = (const CORE_message_queue_Buffer_control *) right;
    3434
    35    return _CORE_message_queue_Get_message_priority( left_message ) <
     35   return *left_priority <
    3636     _CORE_message_queue_Get_message_priority( right_message );
    3737}
     
    6767#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
    6868  } else  if ( submit_type != CORE_MESSAGE_QUEUE_URGENT_REQUEST ) {
     69    int priority;
     70
     71    priority = _CORE_message_queue_Get_message_priority( the_message );
    6972    _Chain_Insert_ordered_unprotected(
    7073      pending_messages,
    7174      &the_message->Node,
     75      &priority,
    7276      _CORE_message_queue_Order
    7377    );
  • cpukit/score/src/schedulerpriorityaffinitysmp.c

    rbceb9db6 r0c286e3  
    4141
    4242static bool _Scheduler_priority_affinity_SMP_Insert_priority_lifo_order(
    43   const Chain_Node *to_insert,
     43  const void      *to_insert,
    4444  const Chain_Node *next
    4545)
     
    5050
    5151static bool _Scheduler_priority_affinity_SMP_Insert_priority_fifo_order(
    52   const Chain_Node *to_insert,
     52  const void      *to_insert,
    5353  const Chain_Node *next
    5454)
     
    284284
    285285  while (1) {
     286    Priority_Control lowest_scheduled_priority;
     287
    286288    if ( _Priority_bit_map_Is_empty( &self->Bit_map ) ) {
    287289      /* Nothing to do */
     
    311313      break;
    312314
     315    lowest_scheduled_priority =
     316      _Scheduler_SMP_Node_priority( lowest_scheduled );
     317
    313318    if (
    314319      _Scheduler_SMP_Insert_priority_lifo_order(
    315         &lowest_scheduled->Node.Chain,
     320        &lowest_scheduled_priority,
    316321        &highest_ready->Node.Chain
    317322      )
  • cpukit/score/src/schedulersimplesmp.c

    rbceb9db6 r0c286e3  
    9999)
    100100{
    101   Scheduler_simple_SMP_Context *self =
    102     _Scheduler_simple_SMP_Get_self( context );
     101  Scheduler_simple_SMP_Context *self;
     102  Priority_Control              priority_to_insert;
     103
     104  self = _Scheduler_simple_SMP_Get_self( context );
     105  priority_to_insert = _Scheduler_SMP_Node_priority( scheduled_to_ready );
    103106
    104107  _Chain_Extract_unprotected( &scheduled_to_ready->Node.Chain );
     
    106109    &self->Ready,
    107110    &scheduled_to_ready->Node.Chain,
     111    &priority_to_insert,
    108112    _Scheduler_SMP_Insert_priority_lifo_order
    109113  );
     
    115119)
    116120{
    117   Scheduler_simple_SMP_Context *self =
    118     _Scheduler_simple_SMP_Get_self( context );
     121  Scheduler_simple_SMP_Context *self;
     122  Priority_Control              priority_to_insert;
     123
     124  self = _Scheduler_simple_SMP_Get_self( context );
     125  priority_to_insert = _Scheduler_SMP_Node_priority( ready_to_scheduled );
    119126
    120127  _Chain_Extract_unprotected( &ready_to_scheduled->Node.Chain );
     
    122129    &self->Base.Scheduled,
    123130    &ready_to_scheduled->Node.Chain,
     131    &priority_to_insert,
    124132    _Scheduler_SMP_Insert_priority_fifo_order
    125133  );
     
    131139)
    132140{
    133   Scheduler_simple_SMP_Context *self =
    134     _Scheduler_simple_SMP_Get_self( context );
     141  Scheduler_simple_SMP_Context *self;
     142  Priority_Control              priority_to_insert;
     143
     144  self = _Scheduler_simple_SMP_Get_self( context );
     145  priority_to_insert = _Scheduler_SMP_Node_priority( node_to_insert );
    135146
    136147  _Chain_Insert_ordered_unprotected(
    137148    &self->Ready,
    138149    &node_to_insert->Node.Chain,
     150    &priority_to_insert,
    139151    _Scheduler_SMP_Insert_priority_lifo_order
    140152  );
     
    146158)
    147159{
    148   Scheduler_simple_SMP_Context *self =
    149     _Scheduler_simple_SMP_Get_self( context );
     160  Scheduler_simple_SMP_Context *self;
     161  Priority_Control              priority_to_insert;
     162
     163  self = _Scheduler_simple_SMP_Get_self( context );
     164  priority_to_insert = _Scheduler_SMP_Node_priority( node_to_insert );
    150165
    151166  _Chain_Insert_ordered_unprotected(
    152167    &self->Ready,
    153168    &node_to_insert->Node.Chain,
     169    &priority_to_insert,
    154170    _Scheduler_SMP_Insert_priority_fifo_order
    155171  );
  • cpukit/score/src/schedulerstrongapa.c

    rbceb9db6 r0c286e3  
    6565)
    6666{
    67   Scheduler_strong_APA_Context *self =
    68     _Scheduler_strong_APA_Get_self( context );
    69   Scheduler_strong_APA_Node *node =
    70     _Scheduler_strong_APA_Node_downcast( ready_to_scheduled );
     67  Scheduler_strong_APA_Context *self;
     68  Scheduler_strong_APA_Node    *node;
     69  Priority_Control              priority;
     70
     71  self = _Scheduler_strong_APA_Get_self( context );
     72  node = _Scheduler_strong_APA_Node_downcast( ready_to_scheduled );
    7173
    7274  _Scheduler_priority_Ready_queue_extract(
     
    7577    &self->Bit_map
    7678  );
     79  priority = node->Base.priority;
    7780  _Chain_Insert_ordered_unprotected(
    7881    &self->Base.Scheduled,
    7982    &node->Base.Base.Node.Chain,
     83    &priority,
    8084    _Scheduler_SMP_Insert_priority_fifo_order
    8185  );
  • testsuites/sptests/spchain/init.c

    rbceb9db6 r0c286e3  
    427427}
    428428
    429 static bool test_order( const Chain_Node *left, const Chain_Node *right )
    430 {
    431   return left < right;
     429static bool test_order( const void *left, const Chain_Node *right )
     430{
     431  return (uintptr_t) left < (uintptr_t) right;
     432}
     433
     434static void insert_ordered( Chain_Control *chain, Chain_Node *node )
     435{
     436  _Chain_Insert_ordered_unprotected( chain, node, node, test_order );
    432437}
    433438
     
    447452  }
    448453
    449   _Chain_Insert_ordered_unprotected( &chain, &nodes[4], test_order );
    450   _Chain_Insert_ordered_unprotected( &chain, &nodes[2], test_order );
    451   _Chain_Insert_ordered_unprotected( &chain, &nodes[0], test_order );
    452   _Chain_Insert_ordered_unprotected( &chain, &nodes[3], test_order );
    453   _Chain_Insert_ordered_unprotected( &chain, &nodes[1], test_order );
     454  insert_ordered( &chain, &nodes[4] );
     455  insert_ordered( &chain, &nodes[2] );
     456  insert_ordered( &chain, &nodes[0] );
     457  insert_ordered( &chain, &nodes[3] );
     458  insert_ordered( &chain, &nodes[1] );
    454459
    455460  tail = _Chain_Immutable_tail( &chain );
Note: See TracChangeset for help on using the changeset viewer.