Changeset 3995e6d in rtems for cpukit/score/src/threadqops.c


Ignore:
Timestamp:
Sep 2, 2015, 9:58:54 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
dafa5d88
Parents:
c4db18a0
git-author:
Sebastian Huber <sebastian.huber@…> (09/02/15 09:58:54)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/04/15 11:25:03)
Message:

score: Implement SMP-specific priority queue

File:
1 edited

Legend:

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

    rc4db18a0 r3995e6d  
    2121#include <rtems/score/chainimpl.h>
    2222#include <rtems/score/rbtreeimpl.h>
     23#include <rtems/score/schedulerimpl.h>
    2324
    2425static void _Thread_queue_Do_nothing_priority_change(
     
    151152}
    152153
     154static Thread_queue_Priority_queue *_Thread_queue_Priority_queue(
     155  Thread_queue_Heads   *heads,
     156  const Thread_Control *the_thread
     157)
     158{
     159#if defined(RTEMS_SMP)
     160  return &heads->Priority[
     161    _Scheduler_Get_index( _Scheduler_Get_own( the_thread ) )
     162  ];
     163#else
     164  (void) the_thread;
     165
     166  return &heads->Heads.Priority;
     167#endif
     168}
     169
    153170static void _Thread_queue_Priority_priority_change(
    154171  Thread_Control     *the_thread,
     
    157174)
    158175{
    159   Thread_queue_Heads *heads = queue->heads;
     176  Thread_queue_Heads          *heads = queue->heads;
     177  Thread_queue_Priority_queue *priority_queue;
    160178
    161179  _Assert( heads != NULL );
    162180
     181  priority_queue = _Thread_queue_Priority_queue( heads, the_thread );
     182
    163183  _RBTree_Extract(
    164     &heads->Heads.Priority,
     184    &priority_queue->Queue,
    165185    &the_thread->Wait.Node.RBTree
    166186  );
    167187  _RBTree_Insert(
    168     &heads->Heads.Priority,
     188    &priority_queue->Queue,
    169189    &the_thread->Wait.Node.RBTree,
    170190    _Thread_queue_Compare_priority,
     
    177197)
    178198{
     199#if defined(RTEMS_SMP)
     200  _Chain_Initialize_empty( &heads->Heads.Fifo );
     201#else
    179202  _RBTree_Initialize_empty( &heads->Heads.Priority );
     203#endif
    180204}
    181205
     
    185209)
    186210{
     211  Thread_queue_Priority_queue *priority_queue =
     212    _Thread_queue_Priority_queue( heads, the_thread );
     213
     214#if defined(RTEMS_SMP)
     215  if ( _RBTree_Is_empty( &priority_queue->Queue ) ) {
     216    _Chain_Append_unprotected( &heads->Heads.Fifo, &priority_queue->Node );
     217  }
     218#endif
     219
    187220  _RBTree_Insert(
    188     &heads->Heads.Priority,
     221    &priority_queue->Queue,
    189222    &the_thread->Wait.Node.RBTree,
    190223    _Thread_queue_Compare_priority,
     
    198231)
    199232{
     233  Thread_queue_Priority_queue *priority_queue =
     234    _Thread_queue_Priority_queue( heads, the_thread );
     235
    200236  _RBTree_Extract(
    201     &heads->Heads.Priority,
     237    &priority_queue->Queue,
    202238    &the_thread->Wait.Node.RBTree
    203239  );
     240
     241#if defined(RTEMS_SMP)
     242  _Chain_Extract_unprotected( &priority_queue->Node );
     243
     244  if ( !_RBTree_Is_empty( &priority_queue->Queue ) ) {
     245    _Chain_Append_unprotected( &heads->Heads.Fifo, &priority_queue->Node );
     246  }
     247#endif
    204248}
    205249
     
    233277)
    234278{
    235   RBTree_Control *priority_queue = &heads->Heads.Priority;
    236   RBTree_Node    *first;
    237 
    238   _Assert( !_RBTree_Is_empty( priority_queue ) );
    239   first = _RBTree_Minimum( priority_queue );
     279  Thread_queue_Priority_queue *priority_queue;
     280  RBTree_Node                 *first;
     281
     282#if defined(RTEMS_SMP)
     283  _Assert( !_Chain_Is_empty( &heads->Heads.Fifo ) );
     284  priority_queue = (Thread_queue_Priority_queue *)
     285    _Chain_First( &heads->Heads.Fifo );
     286#else
     287  priority_queue = &heads->Heads.Priority;
     288#endif
     289
     290  _Assert( !_RBTree_Is_empty( &priority_queue->Queue ) );
     291  first = _RBTree_Minimum( &priority_queue->Queue );
    240292
    241293  return THREAD_RBTREE_NODE_TO_THREAD( first );
Note: See TracChangeset for help on using the changeset viewer.