Changeset 1f210ac1 in rtems


Ignore:
Timestamp:
Aug 10, 2016, 6:37:16 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
e27421f
Parents:
e41308ea
git-author:
Sebastian Huber <sebastian.huber@…> (08/10/16 06:37:16)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/08/16 07:55:27)
Message:

score: Optimize thread queue enqueue

Optimize the enqueue to empty thread queue case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/threadqops.c

    re41308ea r1f210ac1  
    4646  Thread_queue_Queue *queue,
    4747  Thread_Control     *the_thread,
    48   void             ( *initialize )( Thread_queue_Heads * ),
     48  void             ( *initialize )( Thread_queue_Heads *, Thread_Control * ),
    4949  void             ( *enqueue )( Thread_queue_Heads *, Thread_Control * )
    5050)
    5151{
    52   Thread_queue_Heads *heads = queue->heads;
    53   Thread_queue_Heads *spare_heads = the_thread->Wait.spare_heads;
    54 
     52  Thread_queue_Heads *heads;
     53  Thread_queue_Heads *spare_heads;
     54
     55  heads = queue->heads;
     56  spare_heads = the_thread->Wait.spare_heads;
    5557  the_thread->Wait.spare_heads = NULL;
    5658
     
    5860    _Assert( spare_heads != NULL );
    5961    _Assert( _Chain_Is_empty( &spare_heads->Free_chain ) );
     62
    6063    heads = spare_heads;
    6164    queue->heads = heads;
    62     ( *initialize )( heads );
    63   }
    64 
    65   _Chain_Prepend_unprotected( &heads->Free_chain, &spare_heads->Free_node );
    66 
    67   ( *enqueue )( heads, the_thread );
     65    _Chain_Prepend_unprotected( &heads->Free_chain, &spare_heads->Free_node );
     66    ( *initialize )( heads, the_thread );
     67  } else {
     68    _Chain_Prepend_unprotected( &heads->Free_chain, &spare_heads->Free_node );
     69    ( *enqueue )( heads, the_thread );
     70  }
    6871
    6972  return heads;
     
    9396
    9497static void _Thread_queue_FIFO_do_initialize(
    95   Thread_queue_Heads *heads
    96 )
    97 {
    98   _Chain_Initialize_empty( &heads->Heads.Fifo );
     98  Thread_queue_Heads *heads,
     99  Thread_Control     *the_thread
     100)
     101{
     102  _Chain_Initialize_node( &the_thread->Wait.Node.Chain );
     103  _Chain_Initialize_one( &heads->Heads.Fifo, &the_thread->Wait.Node.Chain );
    99104}
    100105
     
    236241
    237242static void _Thread_queue_Priority_do_initialize(
    238   Thread_queue_Heads *heads
    239 )
    240 {
    241 #if defined(RTEMS_SMP)
    242   _Chain_Initialize_empty( &heads->Heads.Fifo );
    243 #else
    244   _RBTree_Initialize_empty( &heads->Heads.Priority.Queue );
    245 #endif
     243  Thread_queue_Heads *heads,
     244  Thread_Control     *the_thread
     245)
     246{
     247  Thread_queue_Priority_queue *priority_queue;
     248
     249  priority_queue = _Thread_queue_Priority_queue( heads, the_thread );
     250
     251#if defined(RTEMS_SMP)
     252  _Chain_Initialize_one( &heads->Heads.Fifo, &priority_queue->Node );
     253#endif
     254
     255  _RBTree_Initialize_node( &the_thread->Wait.Node.RBTree );
     256  _RBTree_Initialize_one(
     257    &priority_queue->Queue,
     258    &the_thread->Wait.Node.RBTree
     259  );
    246260}
    247261
     
    251265)
    252266{
    253   Thread_queue_Priority_queue *priority_queue =
    254     _Thread_queue_Priority_queue( heads, the_thread );
    255   Priority_Control current_priority;
     267  Thread_queue_Priority_queue *priority_queue;
     268  Priority_Control             current_priority;
     269
     270  priority_queue = _Thread_queue_Priority_queue( heads, the_thread );
    256271
    257272#if defined(RTEMS_SMP)
Note: See TracChangeset for help on using the changeset viewer.