Changeset 1e1a91e in rtems


Ignore:
Timestamp:
Mar 23, 2016, 9:01:31 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
97bbf02
Parents:
9c7de43
git-author:
Sebastian Huber <sebastian.huber@…> (03/23/16 09:01:31)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/29/16 05:26:42)
Message:

score: Remove Thread_queue_Queue::operations field

Remove the Thread_queue_Queue::operations field to reduce the size of
this structure. Add a thread queue operations parameter to the
_Thread_queue_First(), _Thread_queue_First_locked(),
_Thread_queue_Enqueue(), _Thread_queue_Dequeue() and
_Thread_queue_Flush() functions. This is a preparation patch to reduce
the size of several synchronization objects.

Files:
54 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/include/rtems/posix/condimpl.h

    r9c7de43 r1e1a91e  
    3232 */
    3333#define POSIX_CONDITION_VARIABLES_NO_MUTEX 0
     34
     35#define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
    3436
    3537/**
  • cpukit/posix/include/rtems/posix/psignalimpl.h

    r9c7de43 r1e1a91e  
    3535#include <rtems/score/percpu.h>
    3636#include <rtems/score/threadqimpl.h>
     37
     38#define POSIX_SIGNALS_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
    3739
    3840#define _States_Is_interruptible_signal( _states ) \
  • cpukit/posix/include/rtems/posix/pthreadimpl.h

    r9c7de43 r1e1a91e  
    3535 */
    3636/**@{**/
     37
     38#define POSIX_THREAD_JOIN_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
    3739
    3840/**
     
    210212}
    211213
     214RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Join_dequeue(
     215  POSIX_API_Control *api
     216)
     217{
     218  return _Thread_queue_Dequeue(
     219    &api->Join_List,
     220    POSIX_THREAD_JOIN_TQ_OPERATIONS
     221  );
     222}
     223
    212224/** @} */
    213225
  • cpukit/posix/src/conddestroy.c

    r9c7de43 r1e1a91e  
    4444    case OBJECTS_LOCAL:
    4545
    46       if ( _Thread_queue_First( &the_cond->Wait_queue ) ) {
     46      if (
     47        _Thread_queue_First(
     48          &the_cond->Wait_queue,
     49          POSIX_CONDITION_VARIABLES_TQ_OPERATIONS
     50        )
     51      ) {
    4752        _Objects_Put( &the_cond->Object );
    4853        _Objects_Allocator_unlock();
  • cpukit/posix/src/condinit.c

    r9c7de43 r1e1a91e  
    6262  the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
    6363
    64   _Thread_queue_Initialize(
    65     &the_cond->Wait_queue,
    66     THREAD_QUEUE_DISCIPLINE_FIFO
    67   );
     64  _Thread_queue_Initialize( &the_cond->Wait_queue );
    6865
    6966  _Objects_Open_u32(
  • cpukit/posix/src/condsignalsupp.c

    r9c7de43 r1e1a91e  
    4848    case OBJECTS_LOCAL:
    4949      do {
    50         the_thread = _Thread_queue_Dequeue( &the_cond->Wait_queue );
     50        the_thread = _Thread_queue_Dequeue(
     51          &the_cond->Wait_queue,
     52          POSIX_CONDITION_VARIABLES_TQ_OPERATIONS
     53        );
    5154        if ( !the_thread )
    5255          the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
  • cpukit/posix/src/condwaitsupp.c

    r9c7de43 r1e1a91e  
    8080        _Thread_queue_Enqueue(
    8181          &the_cond->Wait_queue,
     82          POSIX_CONDITION_VARIABLES_TQ_OPERATIONS,
    8283          executing,
    8384          STATES_WAITING_FOR_CONDITION_VARIABLE
  • cpukit/posix/src/mqueuecreatesupp.c

    r9c7de43 r1e1a91e  
    5656{
    5757  POSIX_Message_queue_Control   *the_mq;
    58   CORE_message_queue_Attributes *the_mq_attr;
    5958  struct mq_attr                 attr;
    6059  char                          *name;
     
    112111   *        if it is a real requirement.
    113112   */
    114   the_mq_attr = &the_mq->Message_queue.Attributes;
    115   the_mq_attr->discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
    116 
    117113  if ( !_CORE_message_queue_Initialize(
    118114           &the_mq->Message_queue,
    119            the_mq_attr,
     115           CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO,
    120116           attr.mq_maxmsg,
    121117           attr.mq_msgsize
  • cpukit/posix/src/nanosleep.c

    r9c7de43 r1e1a91e  
    2929
    3030static Thread_queue_Control _Nanosleep_Pseudo_queue =
    31   THREAD_QUEUE_FIFO_INITIALIZER( _Nanosleep_Pseudo_queue, "Nanosleep" );
     31  THREAD_QUEUE_INITIALIZER( "Nanosleep" );
    3232
    3333/*
     
    9090  _Thread_queue_Enqueue(
    9191    &_Nanosleep_Pseudo_queue,
     92    &_Thread_queue_Operations_FIFO,
    9293    executing,
    9394    STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL,
  • cpukit/posix/src/prwlockdestroy.c

    r9c7de43 r1e1a91e  
    5050       *  If there is at least one thread waiting, then do not delete it.
    5151       */
    52       if ( _Thread_queue_First( &the_rwlock->RWLock.Wait_queue ) != NULL ) {
     52      if (
     53        _Thread_queue_First(
     54          &the_rwlock->RWLock.Wait_queue,
     55          CORE_RWLOCK_TQ_OPERATIONS
     56        ) != NULL
     57      ) {
    5358        _Objects_Put( &the_rwlock->Object );
    5459        _Objects_Allocator_unlock();
  • cpukit/posix/src/psignal.c

    r9c7de43 r1e1a91e  
    9393struct sigaction _POSIX_signals_Vectors[ SIG_ARRAY_MAX ];
    9494
    95 Thread_queue_Control _POSIX_signals_Wait_queue;
     95Thread_queue_Control _POSIX_signals_Wait_queue =
     96  THREAD_QUEUE_INITIALIZER( "POSIX Signals" );
    9697
    9798Chain_Control _POSIX_signals_Inactive_siginfo;
     
    185186   */
    186187  sigemptyset( &_POSIX_signals_Pending );
    187 
    188   /*
    189    *  Initialize the queue we use to block for signals
    190    */
    191   _Thread_queue_Initialize(
    192     &_POSIX_signals_Wait_queue,
    193     THREAD_QUEUE_DISCIPLINE_FIFO
    194   );
    195188
    196189  /* XXX status codes */
  • cpukit/posix/src/pthread.c

    r9c7de43 r1e1a91e  
    234234  }
    235235
    236   _Thread_queue_Initialize( &api->Join_List, THREAD_QUEUE_DISCIPLINE_FIFO );
     236  _Thread_queue_Initialize( &api->Join_List );
    237237
    238238  _Watchdog_Preinitialize( &api->Sporadic_timer, _Per_CPU_Get_by_index( 0 ) );
     
    262262  value_ptr = (void **) executing->Wait.return_argument;
    263263
    264   while ( (the_thread = _Thread_queue_Dequeue( &api->Join_List )) )
    265       *(void **)the_thread->Wait.return_argument = value_ptr;
     264  while ( ( the_thread = _POSIX_Threads_Join_dequeue( api ) ) ) {
     265    *(void **)the_thread->Wait.return_argument = value_ptr;
     266  }
    266267
    267268  if ( api->schedpolicy == SCHED_SPORADIC )
  • cpukit/posix/src/pthreadexit.c

    r9c7de43 r1e1a91e  
    4949   */
    5050  if ( api->detachstate == PTHREAD_CREATE_JOINABLE ) {
    51     unblocked = _Thread_queue_Dequeue( &api->Join_List );
     51    unblocked = _POSIX_Threads_Join_dequeue( api );
    5252    if ( unblocked ) {
    5353      do {
    5454        *(void **)unblocked->Wait.return_argument = value_ptr;
    55       } while ( (unblocked = _Thread_queue_Dequeue( &api->Join_List )) );
     55      } while ( ( unblocked = _POSIX_Threads_Join_dequeue( api ) ) );
    5656    } else {
    5757      _Thread_Set_state( the_thread, STATES_WAITING_FOR_JOIN_AT_EXIT );
  • cpukit/posix/src/pthreadjoin.c

    r9c7de43 r1e1a91e  
    7070        _Thread_queue_Enqueue(
    7171          &api->Join_List,
     72          POSIX_THREAD_JOIN_TQ_OPERATIONS,
    7273          executing,
    7374          STATES_WAITING_FOR_JOIN | STATES_INTERRUPTIBLE_BY_SIGNAL,
  • cpukit/posix/src/semaphorecreatesupp.c

    r9c7de43 r1e1a91e  
    4848)
    4949{
    50   POSIX_Semaphore_Control   *the_semaphore;
    51   CORE_semaphore_Attributes *the_sem_attr;
    52   char                      *name;
     50  POSIX_Semaphore_Control *the_semaphore;
     51  char                    *name;
    5352
    5453  /* Sharing semaphores among processes is not currently supported */
     
    8786  }
    8887
    89   the_sem_attr = &the_semaphore->Semaphore.Attributes;
    90 
    9188  /*
    9289   *  POSIX does not appear to specify what the discipline for
     
    9693   *  the same as  all other POSIX implementations. :)
    9794   */
    98   the_sem_attr->discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
    99 
    100   /*
    101    *  This effectively disables limit checking.
    102    */
    103   the_sem_attr->maximum_count = 0xFFFFFFFF;
    104 
    105   _CORE_semaphore_Initialize( &the_semaphore->Semaphore, the_sem_attr, value );
     95  _CORE_semaphore_Initialize(
     96    &the_semaphore->Semaphore,
     97    CORE_SEMAPHORE_DISCIPLINES_FIFO,
     98    0xFFFFFFFF,
     99    value
     100  );
    106101
    107102  /*
  • cpukit/posix/src/sigtimedwait.c

    r9c7de43 r1e1a91e  
    157157    _Thread_queue_Enqueue_critical(
    158158      &_POSIX_signals_Wait_queue.Queue,
    159       _POSIX_signals_Wait_queue.operations,
     159      POSIX_SIGNALS_TQ_OPERATIONS,
    160160      executing,
    161161      STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL,
  • cpukit/rtems/include/rtems/rtems/region.h

    r9c7de43 r1e1a91e  
    6060  Objects_Control       Object;
    6161  Thread_queue_Control  Wait_queue;            /* waiting threads        */
     62  const Thread_queue_Operations *wait_operations;
    6263  void                 *starting_address;      /* physical start addr    */
    6364  uintptr_t             length;                /* physical length(bytes) */
  • cpukit/rtems/src/msgqcreate.c

    r9c7de43 r1e1a91e  
    4141{
    4242  Message_queue_Control          *the_message_queue;
    43   CORE_message_queue_Attributes   the_msgq_attributes;
     43  CORE_message_queue_Disciplines  discipline;
    4444#if defined(RTEMS_MULTIPROCESSING)
    4545  bool                            is_global;
     
    102102
    103103  if (_Attributes_Is_priority( attribute_set ) )
    104     the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
     104    discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
    105105  else
    106     the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
     106    discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
    107107
    108108  if ( ! _CORE_message_queue_Initialize(
    109109           &the_message_queue->message_queue,
    110            &the_msgq_attributes,
     110           discipline,
    111111           count,
    112112           max_message_size
  • cpukit/rtems/src/regioncreate.c

    r9c7de43 r1e1a91e  
    7272
    7373    else {
    74       _Thread_queue_Initialize(
    75         &the_region->Wait_queue,
    76         _Attributes_Is_priority( attribute_set ) ?
    77            THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO
    78       );
     74      _Thread_queue_Initialize( &the_region->Wait_queue );
     75
     76      if ( _Attributes_Is_priority( attribute_set ) ) {
     77        the_region->wait_operations = &_Thread_queue_Operations_priority;
     78      } else {
     79        the_region->wait_operations = &_Thread_queue_Operations_FIFO;
     80      }
    7981
    8082      the_region->maximum_segment_size = _Heap_Initialize(
  • cpukit/rtems/src/regiongetsegment.c

    r9c7de43 r1e1a91e  
    8282            _Thread_queue_Enqueue(
    8383              &the_region->Wait_queue,
     84              the_region->wait_operations,
    8485              executing,
    8586              STATES_WAITING_FOR_SEGMENT,
  • cpukit/rtems/src/regionprocessqueue.c

    r9c7de43 r1e1a91e  
    4747   */
    4848  for ( ; ; ) {
    49     the_thread = _Thread_queue_First( &the_region->Wait_queue );
     49    the_thread = _Thread_queue_First(
     50      &the_region->Wait_queue,
     51      the_region->wait_operations
     52    );
    5053
    5154    if ( the_thread == NULL )
  • cpukit/rtems/src/semcreate.c

    r9c7de43 r1e1a91e  
    6363  Semaphore_Control          *the_semaphore;
    6464  CORE_mutex_Attributes       the_mutex_attr;
    65   CORE_semaphore_Attributes   the_semaphore_attr;
     65  CORE_semaphore_Disciplines  semaphore_discipline;
    6666  CORE_mutex_Status           mutex_status;
    6767
     
    140140   */
    141141  if ( _Attributes_Is_counting_semaphore( attribute_set ) ) {
    142     /*
    143      *  This effectively disables limit checking.
    144      */
    145     the_semaphore_attr.maximum_count = 0xFFFFFFFF;
    146 
    147142    if ( _Attributes_Is_priority( attribute_set ) )
    148       the_semaphore_attr.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY;
     143      semaphore_discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY;
    149144    else
    150       the_semaphore_attr.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
     145      semaphore_discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
    151146
    152147    /*
     
    158153    _CORE_semaphore_Initialize(
    159154      &the_semaphore->Core_control.semaphore,
    160       &the_semaphore_attr,
     155      semaphore_discipline,
     156      0xFFFFFFFF,
    161157      count
    162158    );
  • cpukit/score/include/rtems/score/corebarrierimpl.h

    r9c7de43 r1e1a91e  
    6262 */
    6363#define CORE_BARRIER_STATUS_LAST CORE_BARRIER_TIMEOUT
     64
     65#define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
    6466
    6567/**
     
    151153  _Thread_queue_Flush( \
    152154    &((_the_barrier)->Wait_queue), \
     155    CORE_BARRIER_TQ_OPERATIONS, \
    153156    (_remote_extract_callout), \
    154157    (_status) \
  • cpukit/score/include/rtems/score/coremsg.h

    r9c7de43 r1e1a91e  
    110110}   CORE_message_queue_Disciplines;
    111111
    112 /**
    113  *  @brief Control block used to manage the attributes of each message queue.
    114  *
    115  *  The following defines the control block used to manage the
    116  *  attributes of each message queue.
    117  */
    118 typedef struct {
    119   /** This field specifies the order in which blocking tasks will be ordered. */
    120   CORE_message_queue_Disciplines  discipline;
    121 }   CORE_message_queue_Attributes;
    122 
    123112#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
    124113  /**
     
    143132   */
    144133  Thread_queue_Control               Wait_queue;
    145   /** This element is the set of attributes which define this instance's
    146    *  behavior.
     134
     135  /**
     136   * @brief The thread queue operations according to the blocking discipline.
    147137   */
    148   CORE_message_queue_Attributes      Attributes;
     138  const Thread_queue_Operations     *operations;
     139
    149140  /** This element is maximum number of messages which may be pending
    150141   *  at any given time.
  • cpukit/score/include/rtems/score/coremsgimpl.h

    r9c7de43 r1e1a91e  
    123123 *
    124124 *  @param[in] the_message_queue points to the message queue to initialize
    125  *  @param[in] the_message_queue_attributes points to the attributes that
    126  *         will be used with this message queue instance
     125 *  @param[in] discipline the blocking discipline
    127126 *  @param[in] maximum_pending_messages is the maximum number of messages
    128127 *         that will be allowed to pend at any given time
     
    135134 */
    136135bool _CORE_message_queue_Initialize(
    137   CORE_message_queue_Control    *the_message_queue,
    138   CORE_message_queue_Attributes *the_message_queue_attributes,
    139   uint32_t                       maximum_pending_messages,
    140   size_t                         maximum_message_size
     136  CORE_message_queue_Control     *the_message_queue,
     137  CORE_message_queue_Disciplines  discipline,
     138  uint32_t                        maximum_pending_messages,
     139  size_t                          maximum_message_size
    141140);
    142141
     
    514513}
    515514
    516 /**
    517  * This function returns true if the priority attribute is
    518  * enabled in the attribute_set and false otherwise.
    519  */
    520 RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_priority(
    521   CORE_message_queue_Attributes *the_attribute
    522 )
    523 {
    524   return
    525     (the_attribute->discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY);
    526 }
    527 
    528515#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
    529516  /**
     
    585572   *  receive a message.
    586573   */
    587   the_thread = _Thread_queue_First_locked( &the_message_queue->Wait_queue );
     574  the_thread = _Thread_queue_First_locked(
     575    &the_message_queue->Wait_queue,
     576    the_message_queue->operations
     577  );
    588578  if ( the_thread == NULL ) {
    589579    return NULL;
     
    601591  _Thread_queue_Extract_critical(
    602592    &the_message_queue->Wait_queue.Queue,
    603     the_message_queue->Wait_queue.operations,
     593    the_message_queue->operations,
    604594    the_thread,
    605595    lock_context
  • cpukit/score/include/rtems/score/coremutex.h

    r9c7de43 r1e1a91e  
    152152   */
    153153  Thread_queue_Control    Wait_queue;
     154
     155  /**
     156   * @brief The thread queue operations according to the blocking discipline.
     157   */
     158  const Thread_queue_Operations *operations;
     159
    154160  /** This element is the set of attributes which define this instance's
    155161   *  behavior.
  • cpukit/score/include/rtems/score/coremuteximpl.h

    r9c7de43 r1e1a91e  
    393393 */
    394394RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_priority(
    395   CORE_mutex_Attributes *the_attribute
     395  const CORE_mutex_Attributes *the_attribute
    396396)
    397397{
     
    411411 */
    412412RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_inherit_priority(
    413   CORE_mutex_Attributes *the_attribute
     413  const CORE_mutex_Attributes *the_attribute
    414414)
    415415{
     
    429429 */
    430430RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_priority_ceiling(
    431   CORE_mutex_Attributes *the_attribute
     431  const CORE_mutex_Attributes *the_attribute
    432432)
    433433{
  • cpukit/score/include/rtems/score/corerwlockimpl.h

    r9c7de43 r1e1a91e  
    3333 */
    3434/**@{**/
     35
     36#define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
    3537
    3638/**
  • cpukit/score/include/rtems/score/coresem.h

    r9c7de43 r1e1a91e  
    5757  /** This element indicates the maximum count this semaphore may have. */
    5858  uint32_t                    maximum_count;
    59   /** This field indicates whether threads waiting on the semaphore block in
    60    *  FIFO or priority order.
    61    */
    62   CORE_semaphore_Disciplines  discipline;
    6359}   CORE_semaphore_Attributes;
    6460
     
    7268   */
    7369  Thread_queue_Control        Wait_queue;
     70
     71  /**
     72   * @brief The thread queue operations according to the blocking discipline.
     73   */
     74  const Thread_queue_Operations *operations;
     75
    7476  /** This element is the set of attributes which define this instance's
    7577   *  behavior.
  • cpukit/score/include/rtems/score/coresemimpl.h

    r9c7de43 r1e1a91e  
    8787 *
    8888 *  @param[in] the_semaphore is the semaphore to initialize
    89  *  @param[in] the_semaphore_attributes define the behavior of this instance
     89 *  @param[in] discipline the blocking discipline
     90 *  @param[in] maximum_count the maximum count
    9091 *  @param[in] initial_value is the initial count of the semaphore
    9192 */
    9293void _CORE_semaphore_Initialize(
    93   CORE_semaphore_Control          *the_semaphore,
    94   const CORE_semaphore_Attributes *the_semaphore_attributes,
    95   uint32_t                         initial_value
     94  CORE_semaphore_Control     *the_semaphore,
     95  CORE_semaphore_Disciplines  discipline,
     96  uint32_t                    maximum_count,
     97  uint32_t                    initial_value
    9698);
    9799
     
    134136  _Thread_queue_Acquire_critical( &the_semaphore->Wait_queue, lock_context );
    135137
    136   the_thread = _Thread_queue_First_locked( &the_semaphore->Wait_queue );
     138  the_thread = _Thread_queue_First_locked(
     139    &the_semaphore->Wait_queue,
     140    the_semaphore->operations
     141  );
    137142  if ( the_thread != NULL ) {
    138143#if defined(RTEMS_MULTIPROCESSING)
     
    142147    _Thread_queue_Extract_critical(
    143148      &the_semaphore->Wait_queue.Queue,
    144       the_semaphore->Wait_queue.operations,
     149      the_semaphore->operations,
    145150      the_thread,
    146151      lock_context
     
    188193  _Thread_queue_Flush(
    189194    &the_semaphore->Wait_queue,
     195    the_semaphore->operations,
    190196    remote_extract_callout,
    191197    status
    192198  );
    193 }
    194 
    195 /**
    196  * This function returns true if the priority attribute is
    197  * enabled in the @a attribute_set and false otherwise.
    198  *
    199  * @param[in] the_attribute is the attribute set to test
    200  *
    201  * @return true if the priority attribute is enabled
    202  */
    203 RTEMS_INLINE_ROUTINE bool _CORE_semaphore_Is_priority(
    204   const CORE_semaphore_Attributes *the_attribute
    205 )
    206 {
    207    return ( the_attribute->discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY );
    208199}
    209200
     
    266257  _Thread_queue_Enqueue_critical(
    267258    &the_semaphore->Wait_queue.Queue,
    268     the_semaphore->Wait_queue.operations,
     259    the_semaphore->operations,
    269260    executing,
    270261    STATES_WAITING_FOR_SEMAPHORE,
  • cpukit/score/include/rtems/score/threadq.h

    r9c7de43 r1e1a91e  
    245245
    246246/**
    247  *  The following enumerated type details all of the disciplines
    248  *  supported by the Thread Queue Handler.
    249  */
    250 typedef enum {
    251   THREAD_QUEUE_DISCIPLINE_FIFO,     /* FIFO queue discipline */
    252   THREAD_QUEUE_DISCIPLINE_PRIORITY  /* PRIORITY queue discipline */
    253 }   Thread_queue_Disciplines;
    254 
    255 /**
    256247 *  This is the structure used to manage sets of tasks which are blocked
    257248 *  waiting to acquire a resource.
     
    266257  SMP_lock_Stats Lock_stats;
    267258#endif
    268 
    269   /**
    270    * @brief The operations for the actual thread queue.
    271    */
    272   const Thread_queue_Operations *operations;
    273259} Thread_queue_Control;
    274260
  • cpukit/score/include/rtems/score/threadqimpl.h

    r9c7de43 r1e1a91e  
    174174 */
    175175Thread_Control *_Thread_queue_Dequeue(
    176   Thread_queue_Control *the_thread_queue
     176  Thread_queue_Control          *the_thread_queue,
     177  const Thread_queue_Operations *operations
    177178);
    178179
     
    197198 * #include <rtems/score/statesimpl.h>
    198199 *
     200 * #define MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority
     201 *
    199202 * typedef struct {
    200203 *   Thread_queue_Control  Queue;
     
    217220 *     _Thread_queue_Enqueue_critical(
    218221 *       &mutex->Queue.Queue,
    219  *       mutex->Queue.operations,
     222 *       MUTEX_TQ_OPERATIONS,
    220223 *       executing,
    221224 *       STATES_WAITING_FOR_MUTEX,
     
    252255 */
    253256RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
    254   Thread_queue_Control *the_thread_queue,
    255   Thread_Control       *the_thread,
    256   States_Control        state,
    257   Watchdog_Interval     timeout,
    258   uint32_t              timeout_code
     257  Thread_queue_Control          *the_thread_queue,
     258  const Thread_queue_Operations *operations,
     259  Thread_Control                *the_thread,
     260  States_Control                 state,
     261  Watchdog_Interval              timeout,
     262  uint32_t                       timeout_code
    259263)
    260264{
     
    264268  _Thread_queue_Enqueue_critical(
    265269    &the_thread_queue->Queue,
    266     the_thread_queue->operations,
     270    operations,
    267271    the_thread,
    268272    state,
     
    401405 *
    402406 * @param[in] the_thread_queue The thread queue.
     407 * @param[in] operations The thread queue operations.
    403408 *
    404409 * @retval NULL No thread is present on the thread queue.
     
    407412 */
    408413RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked(
    409   Thread_queue_Control *the_thread_queue
     414  Thread_queue_Control          *the_thread_queue,
     415  const Thread_queue_Operations *operations
    410416)
    411417{
     
    413419
    414420  if ( heads != NULL ) {
    415     return ( *the_thread_queue->operations->first )( heads );
     421    return ( *operations->first )( heads );
    416422  } else {
    417423    return NULL;
     
    430436 */
    431437Thread_Control *_Thread_queue_First(
    432   Thread_queue_Control *the_thread_queue
     438  Thread_queue_Control          *the_thread_queue,
     439  const Thread_queue_Operations *operations
    433440);
    434441
     
    440447 *
    441448 *  @param[in] the_thread_queue is the pointer to a threadq header
     449 *  @param[in] operations The thread queue operations.
    442450 *  @param[in] remote_extract_callout points to a method to invoke to
    443451 *             invoke when a remote thread is unblocked
     
    446454 */
    447455void _Thread_queue_Flush(
    448   Thread_queue_Control       *the_thread_queue,
    449   Thread_queue_Flush_callout  remote_extract_callout,
    450   uint32_t                    status
    451 );
    452 
    453 /**
    454  *  @brief Initialize the_thread_queue.
    455  *
    456  *  This routine initializes the_thread_queue based on the
    457  *  discipline indicated in attribute_set.  The state set on
    458  *  threads which block on the_thread_queue is state.
    459  *
    460  *  @param[in] the_thread_queue is the pointer to a threadq header
    461  *  @param[in] the_discipline is the queueing discipline
    462  */
    463 void _Thread_queue_Initialize(
    464   Thread_queue_Control     *the_thread_queue,
    465   Thread_queue_Disciplines  the_discipline
    466 );
     456  Thread_queue_Control          *the_thread_queue,
     457  const Thread_queue_Operations *operations,
     458  Thread_queue_Flush_callout     remote_extract_callout,
     459  uint32_t                       status
     460);
     461
     462void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue );
    467463
    468464#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
    469   #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
     465  #define THREAD_QUEUE_INITIALIZER( name ) \
     466    { \
    470467      .Queue = { \
    471468        .heads = NULL, \
    472469        .Lock = SMP_TICKET_LOCK_INITIALIZER, \
    473470      }, \
    474       .Lock_stats = SMP_LOCK_STATS_INITIALIZER( name ), \
    475       .operations = &_Thread_queue_Operations_FIFO \
     471      .Lock_stats = SMP_LOCK_STATS_INITIALIZER( name ) \
    476472    }
    477 
    478   #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
     473#elif defined(RTEMS_SMP)
     474  #define THREAD_QUEUE_INITIALIZER( name ) \
     475    { \
    479476      .Queue = { \
    480477        .heads = NULL, \
    481478        .Lock = SMP_TICKET_LOCK_INITIALIZER, \
    482       }, \
    483       .Lock_stats = SMP_LOCK_STATS_INITIALIZER( name ), \
    484       .operations = &_Thread_queue_Operations_priority \
    485     }
    486 #elif defined(RTEMS_SMP)
    487   #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
    488       .Queue = { \
    489         .heads = NULL, \
    490         .Lock = SMP_TICKET_LOCK_INITIALIZER, \
    491       }, \
    492       .operations = &_Thread_queue_Operations_FIFO \
    493     }
    494 
    495   #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
    496       .Queue = { \
    497         .heads = NULL, \
    498         .Lock = SMP_TICKET_LOCK_INITIALIZER, \
    499       }, \
    500       .operations = &_Thread_queue_Operations_priority \
     479      } \
    501480    }
    502481#else
    503   #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
    504       .Queue = { .heads = NULL }, \
    505       .operations = &_Thread_queue_Operations_FIFO \
    506     }
    507 
    508   #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
    509       .Queue = { .heads = NULL }, \
    510       .operations = &_Thread_queue_Operations_priority \
    511     }
     482  #define THREAD_QUEUE_INITIALIZER( name ) \
     483    { .Queue = { .heads = NULL } }
    512484#endif
    513485
  • cpukit/score/src/corebarrier.c

    r9c7de43 r1e1a91e  
    3131  the_barrier->number_of_waiting_threads = 0;
    3232
    33   _Thread_queue_Initialize(
    34     &the_barrier->Wait_queue,
    35     THREAD_QUEUE_DISCIPLINE_FIFO
    36   );
     33  _Thread_queue_Initialize( &the_barrier->Wait_queue );
    3734}
  • cpukit/score/src/corebarrierrelease.c

    r9c7de43 r1e1a91e  
    2424#include <rtems/score/threadqimpl.h>
    2525
     26static Thread_Control *_CORE_barrier_Dequeue(
     27  CORE_barrier_Control *the_barrier
     28)
     29{
     30  return _Thread_queue_Dequeue(
     31    &the_barrier->Wait_queue,
     32    CORE_BARRIER_TQ_OPERATIONS
     33  );
     34}
     35
    2636uint32_t _CORE_barrier_Release(
    2737  CORE_barrier_Control                *the_barrier,
     
    3949
    4050  count = 0;
    41   while ( (the_thread = _Thread_queue_Dequeue(&the_barrier->Wait_queue)) ) {
     51  while ( ( the_thread = _CORE_barrier_Dequeue( the_barrier ) ) ) {
    4252#if defined(RTEMS_MULTIPROCESSING)
    4353    if ( !_Objects_Is_local_id( the_thread->Object.id ) )
  • cpukit/score/src/corebarrierwait.c

    r9c7de43 r1e1a91e  
    5252  _Thread_queue_Enqueue_critical(
    5353    &the_barrier->Wait_queue.Queue,
    54     the_barrier->Wait_queue.operations,
     54    CORE_BARRIER_TQ_OPERATIONS,
    5555    executing,
    5656    STATES_WAITING_FOR_BARRIER,
  • cpukit/score/src/coremsg.c

    r9c7de43 r1e1a91e  
    4444
    4545bool _CORE_message_queue_Initialize(
    46   CORE_message_queue_Control    *the_message_queue,
    47   CORE_message_queue_Attributes *the_message_queue_attributes,
    48   uint32_t                       maximum_pending_messages,
    49   size_t                         maximum_message_size
     46  CORE_message_queue_Control     *the_message_queue,
     47  CORE_message_queue_Disciplines  discipline,
     48  uint32_t                        maximum_pending_messages,
     49  size_t                          maximum_message_size
    5050)
    5151{
     
    109109  _Chain_Initialize_empty( &the_message_queue->Pending_messages );
    110110
    111   _Thread_queue_Initialize(
    112     &the_message_queue->Wait_queue,
    113     _CORE_message_queue_Is_priority( the_message_queue_attributes ) ?
    114        THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO
    115   );
     111  _Thread_queue_Initialize( &the_message_queue->Wait_queue );
     112
     113  if ( discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY ) {
     114    the_message_queue->operations = &_Thread_queue_Operations_priority;
     115  } else {
     116    the_message_queue->operations = &_Thread_queue_Operations_FIFO;
     117  }
    116118
    117119  return true;
  • cpukit/score/src/coremsgclose.c

    r9c7de43 r1e1a91e  
    3737  _Thread_queue_Flush(
    3838    &the_message_queue->Wait_queue,
     39    the_message_queue->operations,
    3940    remote_extract_callout,
    4041    status
  • cpukit/score/src/coremsgseize.c

    r9c7de43 r1e1a91e  
    7575       */
    7676      the_thread = _Thread_queue_First_locked(
    77         &the_message_queue->Wait_queue
     77        &the_message_queue->Wait_queue,
     78        the_message_queue->operations
    7879      );
    7980      if ( the_thread == NULL ) {
     
    109110      _Thread_queue_Extract_critical(
    110111        &the_message_queue->Wait_queue.Queue,
    111         the_message_queue->Wait_queue.operations,
     112        the_message_queue->operations,
    112113        the_thread,
    113114        lock_context
     
    134135  _Thread_queue_Enqueue_critical(
    135136    &the_message_queue->Wait_queue.Queue,
    136     the_message_queue->Wait_queue.operations,
     137    the_message_queue->operations,
    137138    executing,
    138139    STATES_WAITING_FOR_MESSAGE,
  • cpukit/score/src/coremsgsubmit.c

    r9c7de43 r1e1a91e  
    134134    _Thread_queue_Enqueue_critical(
    135135      &the_message_queue->Wait_queue.Queue,
    136       the_message_queue->Wait_queue.operations,
     136      the_message_queue->operations,
    137137      executing,
    138138      STATES_WAITING_FOR_MESSAGE,
  • cpukit/score/src/coremutex.c

    r9c7de43 r1e1a91e  
    8787  }
    8888
    89   _Thread_queue_Initialize(
    90     &the_mutex->Wait_queue,
    91     _CORE_mutex_Is_fifo( the_mutex_attributes ) ?
    92       THREAD_QUEUE_DISCIPLINE_FIFO : THREAD_QUEUE_DISCIPLINE_PRIORITY
    93   );
     89  _Thread_queue_Initialize( &the_mutex->Wait_queue );
     90
     91  if ( _CORE_mutex_Is_priority( the_mutex_attributes ) ) {
     92    the_mutex->operations = &_Thread_queue_Operations_priority;
     93  } else {
     94    the_mutex->operations = &_Thread_queue_Operations_FIFO;
     95  }
    9496
    9597  return CORE_MUTEX_STATUS_SUCCESSFUL;
  • cpukit/score/src/coremutexflush.c

    r9c7de43 r1e1a91e  
    3232  _Thread_queue_Flush(
    3333    &the_mutex->Wait_queue,
     34    the_mutex->operations,
    3435    remote_extract_callout,
    3536    status
  • cpukit/score/src/coremutexseize.c

    r9c7de43 r1e1a91e  
    8585  _Thread_queue_Enqueue_critical(
    8686    &the_mutex->Wait_queue.Queue,
    87     the_mutex->Wait_queue.operations,
     87    the_mutex->operations,
    8888    executing,
    8989    STATES_WAITING_FOR_MUTEX,
  • cpukit/score/src/coremutexsurrender.c

    r9c7de43 r1e1a91e  
    179179   *  transfer the mutex to that thread.
    180180   */
    181   if ( ( the_thread = _Thread_queue_First_locked( &the_mutex->Wait_queue ) ) ) {
     181  if (
     182    ( the_thread = _Thread_queue_First_locked(
     183        &the_mutex->Wait_queue,
     184        the_mutex->operations
     185      )
     186    )
     187  ) {
    182188    bool unblock;
    183189
     
    190196    unblock = _Thread_queue_Extract_locked(
    191197      &the_mutex->Wait_queue.Queue,
    192       the_mutex->Wait_queue.operations,
     198      the_mutex->operations,
    193199      the_thread
    194200    );
  • cpukit/score/src/corerwlock.c

    r9c7de43 r1e1a91e  
    3535  the_rwlock->current_state = CORE_RWLOCK_UNLOCKED;
    3636
    37   _Thread_queue_Initialize(
    38     &the_rwlock->Wait_queue,
    39     THREAD_QUEUE_DISCIPLINE_FIFO
    40   );
     37  _Thread_queue_Initialize( &the_rwlock->Wait_queue );
    4138}
  • cpukit/score/src/corerwlockobtainread.c

    r9c7de43 r1e1a91e  
    5252      case CORE_RWLOCK_LOCKED_FOR_READING: {
    5353        Thread_Control *waiter;
    54         waiter = _Thread_queue_First_locked( &the_rwlock->Wait_queue );
     54        waiter = _Thread_queue_First_locked(
     55          &the_rwlock->Wait_queue,
     56          CORE_RWLOCK_TQ_OPERATIONS
     57        );
    5558        if ( !waiter ) {
    5659          the_rwlock->number_of_readers += 1;
     
    8588    _Thread_queue_Enqueue_critical(
    8689       &the_rwlock->Wait_queue.Queue,
    87        the_rwlock->Wait_queue.operations,
     90       CORE_RWLOCK_TQ_OPERATIONS,
    8891       executing,
    8992       STATES_WAITING_FOR_RWLOCK,
  • cpukit/score/src/corerwlockobtainwrite.c

    r9c7de43 r1e1a91e  
    7575    _Thread_queue_Enqueue_critical(
    7676       &the_rwlock->Wait_queue.Queue,
    77        the_rwlock->Wait_queue.operations,
     77       CORE_RWLOCK_TQ_OPERATIONS,
    7878       executing,
    7979       STATES_WAITING_FOR_RWLOCK,
  • cpukit/score/src/corerwlockrelease.c

    r9c7de43 r1e1a91e  
    6565  _ISR_Enable( level );
    6666
    67   next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue );
     67  next = _Thread_queue_Dequeue(
     68    &the_rwlock->Wait_queue,
     69    CORE_RWLOCK_TQ_OPERATIONS
     70  );
    6871
    6972  if ( next ) {
     
    8386     */
    8487    while ( 1 ) {
    85       next = _Thread_queue_First( &the_rwlock->Wait_queue );
     88      next = _Thread_queue_First(
     89        &the_rwlock->Wait_queue,
     90        CORE_RWLOCK_TQ_OPERATIONS
     91      );
    8692      if ( !next ||
    8793           next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE )
  • cpukit/score/src/coresem.c

    r9c7de43 r1e1a91e  
    2222
    2323void _CORE_semaphore_Initialize(
    24   CORE_semaphore_Control          *the_semaphore,
    25   const CORE_semaphore_Attributes *the_semaphore_attributes,
    26   uint32_t                         initial_value
     24  CORE_semaphore_Control     *the_semaphore,
     25  CORE_semaphore_Disciplines  discipline,
     26  uint32_t                    maximum_count,
     27  uint32_t                    initial_value
    2728)
    2829{
    2930
    30   the_semaphore->Attributes = *the_semaphore_attributes;
    31   the_semaphore->count      = initial_value;
     31  the_semaphore->Attributes.maximum_count = maximum_count;
     32  the_semaphore->count = initial_value;
    3233
    33   _Thread_queue_Initialize(
    34     &the_semaphore->Wait_queue,
    35     _CORE_semaphore_Is_priority( the_semaphore_attributes ) ?
    36               THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO
    37   );
     34  _Thread_queue_Initialize( &the_semaphore->Wait_queue );
     35
     36  if ( discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY ) {
     37    the_semaphore->operations = &_Thread_queue_Operations_priority;
     38  } else {
     39    the_semaphore->operations = &_Thread_queue_Operations_FIFO;
     40  }
    3841}
  • cpukit/score/src/mpci.c

    r9c7de43 r1e1a91e  
    5555CORE_semaphore_Control _MPCI_Semaphore;
    5656
    57 Thread_queue_Control _MPCI_Remote_blocked_threads;
     57Thread_queue_Control _MPCI_Remote_blocked_threads =
     58  THREAD_QUEUE_INITIALIZER( "MPCI Remote Blocked Threads" );
    5859
    5960MPCI_Control *_MPCI_table;
     
    8687static void _MPCI_Handler_initialization( void )
    8788{
    88   CORE_semaphore_Attributes   attributes;
    8989  MPCI_Control               *users_mpci_table;
    9090
     
    118118   */
    119119
    120   attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
    121 
    122120  _CORE_semaphore_Initialize(
    123121    &_MPCI_Semaphore,
    124     &attributes,              /* the_semaphore_attributes */
     122    CORE_SEMAPHORE_DISCIPLINES_FIFO,
     123    0xffffffff,
    125124    0                         /* initial_value */
    126   );
    127 
    128   _Thread_queue_Initialize(
    129     &_MPCI_Remote_blocked_threads,
    130     THREAD_QUEUE_DISCIPLINE_FIFO
    131125  );
    132126}
     
    263257    _Thread_queue_Enqueue(
    264258      &_MPCI_Remote_blocked_threads,
     259      &_Thread_queue_Operations_FIFO,
    265260      executing,
    266261      STATES_WAITING_FOR_RPC_REPLY | extra_state,
  • cpukit/score/src/threadq.c

    r9c7de43 r1e1a91e  
    8080}
    8181
    82 void _Thread_queue_Initialize(
    83   Thread_queue_Control     *the_thread_queue,
    84   Thread_queue_Disciplines  the_discipline
    85 )
     82void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue )
    8683{
    87   const Thread_queue_Operations *operations;
    88 
    89   if ( the_discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) {
    90     operations = &_Thread_queue_Operations_priority;
    91   } else {
    92     _Assert( the_discipline == THREAD_QUEUE_DISCIPLINE_FIFO );
    93     operations = &_Thread_queue_Operations_FIFO;
    94   }
    95 
    96   the_thread_queue->operations = operations;
    97 
    9884  _Thread_queue_Queue_initialize( &the_thread_queue->Queue );
    9985#if defined(RTEMS_SMP)
  • cpukit/score/src/threadqenqueue.c

    r9c7de43 r1e1a91e  
    194194}
    195195
    196 Thread_Control *_Thread_queue_Dequeue( Thread_queue_Control *the_thread_queue )
     196Thread_Control *_Thread_queue_Dequeue(
     197  Thread_queue_Control          *the_thread_queue,
     198  const Thread_queue_Operations *operations
     199)
    197200{
    198201  ISR_lock_Context  lock_context;
     
    201204  _Thread_queue_Acquire( the_thread_queue, &lock_context );
    202205
    203   the_thread = _Thread_queue_First_locked( the_thread_queue );
     206  the_thread = _Thread_queue_First_locked( the_thread_queue, operations );
    204207
    205208  if ( the_thread != NULL ) {
     
    208211    _Thread_queue_Extract_critical(
    209212      &the_thread_queue->Queue,
    210       the_thread_queue->operations,
     213      operations,
    211214      the_thread,
    212215      &lock_context
  • cpukit/score/src/threadqfirst.c

    r9c7de43 r1e1a91e  
    2222
    2323Thread_Control *_Thread_queue_First(
    24   Thread_queue_Control *the_thread_queue
     24  Thread_queue_Control          *the_thread_queue,
     25  const Thread_queue_Operations *operations
    2526)
    2627{
     
    2930
    3031  _Thread_queue_Acquire( the_thread_queue, &lock_context );
    31   the_thread = _Thread_queue_First_locked( the_thread_queue );
     32  the_thread = _Thread_queue_First_locked( the_thread_queue, operations );
    3233  _Thread_queue_Release( the_thread_queue, &lock_context );
    3334
  • cpukit/score/src/threadqflush.c

    r9c7de43 r1e1a91e  
    2323
    2424void _Thread_queue_Flush(
    25   Thread_queue_Control       *the_thread_queue,
     25  Thread_queue_Control          *the_thread_queue,
     26  const Thread_queue_Operations *operations,
    2627#if defined(RTEMS_MULTIPROCESSING)
    27   Thread_queue_Flush_callout  remote_extract_callout,
     28  Thread_queue_Flush_callout     remote_extract_callout,
    2829#else
    29   Thread_queue_Flush_callout  remote_extract_callout RTEMS_UNUSED,
     30  Thread_queue_Flush_callout     remote_extract_callout RTEMS_UNUSED,
    3031#endif
    31   uint32_t                    status
     32  uint32_t                       status
    3233)
    3334{
     
    3738  _Thread_queue_Acquire( the_thread_queue, &lock_context );
    3839
    39   while ( (the_thread = _Thread_queue_First_locked( the_thread_queue ) ) ) {
     40  while (
     41    (
     42      the_thread = _Thread_queue_First_locked(
     43        the_thread_queue,
     44        operations
     45      )
     46    )
     47  ) {
    4048#if defined(RTEMS_MULTIPROCESSING)
    4149    if ( _Objects_Is_local_id( the_thread->Object.id ) )
     
    4553    _Thread_queue_Extract_critical(
    4654      &the_thread_queue->Queue,
    47       the_thread_queue->operations,
     55      operations,
    4856      the_thread,
    4957      &lock_context
  • testsuites/sptests/spthreadq01/init.c

    r9c7de43 r1e1a91e  
    1919const char rtems_test_name[] = "SPTHREADQ 1";
    2020
    21 static Thread_queue_Control fifo_queue =
    22   THREAD_QUEUE_FIFO_INITIALIZER( fifo_queue, "FIFO" );
    23 
    24 static Thread_queue_Control prio_queue =
    25   THREAD_QUEUE_PRIORITY_INITIALIZER( prio_queue, "Prio" );
     21static Thread_queue_Control queue = THREAD_QUEUE_INITIALIZER( "Queue" );
    2622
    2723static rtems_task Init(
     
    3733  /* is there more to check? */
    3834
    39   rtems_test_assert( fifo_queue.Queue.heads == NULL );
    40   rtems_test_assert( fifo_queue.operations == &_Thread_queue_Operations_FIFO );
    41 
    42   rtems_test_assert( prio_queue.Queue.heads == NULL );
    43   rtems_test_assert(
    44     prio_queue.operations == &_Thread_queue_Operations_priority
    45   );
     35  rtems_test_assert( queue.Queue.heads == NULL );
    4636
    4737  TEST_END();
Note: See TracChangeset for help on using the changeset viewer.