Changeset dfcc8bb in rtems


Ignore:
Timestamp:
May 3, 2016, 5:43:54 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
0e1d11f3
Parents:
868cd24d
git-author:
Sebastian Huber <sebastian.huber@…> (05/03/16 05:43:54)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/30/16 12:36:18)
Message:

score: Adjust thread queue layout

Adjust thread queue layout according to Newlib. This makes it possible
to use the same implementation for <sys/lock.h> and CORE mutexes in the
future.

Location:
cpukit/score
Files:
4 edited

Legend:

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

    r868cd24d rdfcc8bb  
    156156typedef struct {
    157157  /**
     158   * @brief Lock to protect this thread queue.
     159   *
     160   * It may be used to protect additional state of the object embedding this
     161   * thread queue.
     162   *
     163   * Must be the first component of this structure to be able to re-use
     164   * implementation parts for structures defined by Newlib <sys/lock.h>.
     165   *
     166   * @see _Thread_queue_Acquire(), _Thread_queue_Acquire_critical() and
     167   * _Thread_queue_Release().
     168   */
     169#if defined(RTEMS_SMP)
     170  SMP_ticket_lock_Control Lock;
     171#endif
     172
     173  /**
    158174   * @brief The thread queue heads.
    159175   *
     
    165181
    166182  /**
    167    * @brief Lock to protect this thread queue.
    168    *
    169    * It may be used to protect additional state of the object embedding this
    170    * thread queue.
    171    *
    172    * @see _Thread_queue_Acquire(), _Thread_queue_Acquire_critical() and
    173    * _Thread_queue_Release().
    174    */
    175 #if defined(RTEMS_SMP)
    176   SMP_ticket_lock_Control Lock;
    177 #endif
     183   * @brief The thread queue owner.
     184   */
     185  Thread_Control *owner;
    178186} Thread_queue_Queue;
    179187
  • cpukit/score/include/rtems/score/threadqimpl.h

    r868cd24d rdfcc8bb  
    4141 */
    4242typedef struct {
    43   Thread_queue_Queue Queue;
    44 
    4543#if !defined(RTEMS_SMP)
    4644  /*
     
    5250  unsigned int reserved[2];
    5351#endif
     52
     53  Thread_queue_Queue Queue;
    5454} Thread_queue_Syslock_queue;
    5555
     
    116116)
    117117{
    118   queue->heads = NULL;
    119118#if defined(RTEMS_SMP)
    120119  _SMP_ticket_lock_Initialize( &queue->Lock );
    121120#endif
     121  queue->heads = NULL;
     122  queue->owner = NULL;
    122123}
    123124
  • cpukit/score/src/mutex.c

    r868cd24d rdfcc8bb  
    3131typedef struct {
    3232  Thread_queue_Syslock_queue Queue;
    33   Thread_Control *owner;
    3433} Mutex_Control;
    3534
     
    3837    == offsetof( struct _Mutex_Control, _Queue ),
    3938  MUTEX_CONTROL_QUEUE
    40 );
    41 
    42 RTEMS_STATIC_ASSERT(
    43   offsetof( Mutex_Control, owner )
    44     == offsetof( struct _Mutex_Control, _owner ),
    45   MUTEX_CONTROL_OWNER
    4639);
    4740
     
    140133    first = ( *operations->first )( heads );
    141134
    142     mutex->owner = first;
     135    mutex->Queue.Queue.owner = first;
    143136    ++first->resource_count;
    144137    unblock = _Thread_queue_Extract_locked(
     
    177170  bool keep_priority;
    178171
    179   mutex->owner = NULL;
     172  mutex->Queue.Queue.owner = NULL;
    180173
    181174  --executing->resource_count;
     
    215208  executing = _Mutex_Queue_acquire( mutex, &lock_context );
    216209
    217   owner = mutex->owner;
    218 
    219   if ( __predict_true( owner == NULL ) ) {
    220     mutex->owner = executing;
     210  owner = mutex->Queue.Queue.owner;
     211
     212  if ( __predict_true( owner == NULL ) ) {
     213    mutex->Queue.Queue.owner = executing;
    221214    ++executing->resource_count;
    222215    _Mutex_Queue_release( mutex, &lock_context );
     
    239232  executing = _Mutex_Queue_acquire( mutex, &lock_context );
    240233
    241   owner = mutex->owner;
    242 
    243   if ( __predict_true( owner == NULL ) ) {
    244     mutex->owner = executing;
     234  owner = mutex->Queue.Queue.owner;
     235
     236  if ( __predict_true( owner == NULL ) ) {
     237    mutex->Queue.Queue.owner = executing;
    245238    ++executing->resource_count;
    246239    _Mutex_Queue_release( mutex, &lock_context );
     
    279272  executing = _Mutex_Queue_acquire( mutex, &lock_context );
    280273
    281   owner = mutex->owner;
    282 
    283   if ( __predict_true( owner == NULL ) ) {
    284     mutex->owner = executing;
     274  owner = mutex->Queue.Queue.owner;
     275
     276  if ( __predict_true( owner == NULL ) ) {
     277    mutex->Queue.Queue.owner = executing;
    285278    ++executing->resource_count;
    286279    eno = 0;
     
    304297  executing = _Mutex_Queue_acquire( mutex, &queue_context.Lock_context );
    305298
    306   _Assert( mutex->owner == executing );
     299  _Assert( mutex->Queue.Queue.owner == executing );
    307300
    308301  _Mutex_Release_critical( mutex, executing, &queue_context );
     
    326319  executing = _Mutex_Queue_acquire( &mutex->Mutex, &lock_context );
    327320
    328   owner = mutex->Mutex.owner;
    329 
    330   if ( __predict_true( owner == NULL ) ) {
    331     mutex->Mutex.owner = executing;
     321  owner = mutex->Mutex.Queue.Queue.owner;
     322
     323  if ( __predict_true( owner == NULL ) ) {
     324    mutex->Mutex.Queue.Queue.owner = executing;
    332325    ++executing->resource_count;
    333326    _Mutex_Queue_release( &mutex->Mutex, &lock_context );
     
    353346  executing = _Mutex_Queue_acquire( &mutex->Mutex, &lock_context );
    354347
    355   owner = mutex->Mutex.owner;
    356 
    357   if ( __predict_true( owner == NULL ) ) {
    358     mutex->Mutex.owner = executing;
     348  owner = mutex->Mutex.Queue.Queue.owner;
     349
     350  if ( __predict_true( owner == NULL ) ) {
     351    mutex->Mutex.Queue.Queue.owner = executing;
    359352    ++executing->resource_count;
    360353    _Mutex_Queue_release( &mutex->Mutex, &lock_context );
     
    404397  executing = _Mutex_Queue_acquire( &mutex->Mutex, &lock_context );
    405398
    406   owner = mutex->Mutex.owner;
    407 
    408   if ( __predict_true( owner == NULL ) ) {
    409     mutex->Mutex.owner = executing;
     399  owner = mutex->Mutex.Queue.Queue.owner;
     400
     401  if ( __predict_true( owner == NULL ) ) {
     402    mutex->Mutex.Queue.Queue.owner = executing;
    410403    ++executing->resource_count;
    411404    eno = 0;
     
    436429  );
    437430
    438   _Assert( mutex->Mutex.owner == executing );
     431  _Assert( mutex->Mutex.Queue.Queue.owner == executing );
    439432
    440433  nest_level = mutex->nest_level;
  • cpukit/score/src/threadq.c

    r868cd24d rdfcc8bb  
    2626
    2727RTEMS_STATIC_ASSERT(
    28   offsetof( Thread_queue_Syslock_queue, Queue.heads )
    29     == offsetof( struct _Thread_queue_Queue, _heads ),
    30   THREAD_QUEUE_SYSLOCK_QUEUE_HEADS
    31 );
    32 
    33 RTEMS_STATIC_ASSERT(
    3428#if defined(RTEMS_SMP)
    3529  offsetof( Thread_queue_Syslock_queue, Queue.Lock.next_ticket )
     
    4943    == offsetof( struct _Thread_queue_Queue, _Lock._now_serving ),
    5044  THREAD_QUEUE_SYSLOCK_QUEUE_NOW_SERVING
     45);
     46
     47RTEMS_STATIC_ASSERT(
     48  offsetof( Thread_queue_Syslock_queue, Queue.heads )
     49    == offsetof( struct _Thread_queue_Queue, _heads ),
     50  THREAD_QUEUE_SYSLOCK_QUEUE_HEADS
     51);
     52
     53RTEMS_STATIC_ASSERT(
     54  offsetof( Thread_queue_Syslock_queue, Queue.owner )
     55    == offsetof( struct _Thread_queue_Queue, _owner ),
     56  THREAD_QUEUE_SYSLOCK_QUEUE_OWNER
    5157);
    5258
Note: See TracChangeset for help on using the changeset viewer.