Changeset 8797c76 in rtems


Ignore:
Timestamp:
Sep 27, 2016, 1:23:00 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
9b04456
Parents:
4e02681
Message:

score: Unify CORE mutex seize/surrender

Use the Thread_Control::resource_count for the no protocol mutexes.
Merge the no protocol and priority inherit CORE mutex seize/surrender
operations.

Location:
cpukit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libnetworking/rtems/rtems_glue.c

    r4e02681 r8797c76  
    380380        status = _CORE_recursive_mutex_Seize (
    381381                &the_networkSemaphore->Core_control.Mutex.Recursive,
     382                CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
    382383                _Thread_Executing,
    383384                true,                   /* wait */
     
    413414        status = _CORE_recursive_mutex_Surrender(
    414415                &the_networkSemaphore->Core_control.Mutex.Recursive,
     416                CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
    415417                _Thread_Executing,
    416418                &queue_context
  • cpukit/posix/src/mutexlocksupp.c

    r4e02681 r8797c76  
    7777      break;
    7878    case POSIX_MUTEX_NO_PROTOCOL:
    79       status = _CORE_recursive_mutex_Seize_no_protocol(
     79      status = _CORE_recursive_mutex_Seize(
    8080        &the_mutex->Mutex.Recursive,
    8181        POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
     
    9090      status = _CORE_recursive_mutex_Seize(
    9191        &the_mutex->Mutex.Recursive,
     92        CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
    9293        executing,
    9394        wait,
  • cpukit/posix/src/mutexunlock.c

    r4e02681 r8797c76  
    5454      break;
    5555    case POSIX_MUTEX_NO_PROTOCOL:
    56       status = _CORE_recursive_mutex_Surrender_no_protocol(
     56      status = _CORE_recursive_mutex_Surrender(
    5757        &the_mutex->Mutex.Recursive,
    5858        POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
     
    6565      status = _CORE_recursive_mutex_Surrender(
    6666        &the_mutex->Mutex.Recursive,
     67        CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
    6768        executing,
    6869        &queue_context
  • cpukit/rtems/src/semobtain.c

    r4e02681 r8797c76  
    7676      status = _CORE_recursive_mutex_Seize(
    7777        &the_semaphore->Core_control.Mutex.Recursive,
     78        CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
    7879        executing,
    7980        wait,
     
    9293      break;
    9394    case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
    94       status = _CORE_recursive_mutex_Seize_no_protocol(
     95      status = _CORE_recursive_mutex_Seize(
    9596        &the_semaphore->Core_control.Mutex.Recursive,
    9697        _Semaphore_Get_operations( the_semaphore ),
  • cpukit/rtems/src/semrelease.c

    r4e02681 r8797c76  
    5353      status = _CORE_recursive_mutex_Surrender(
    5454        &the_semaphore->Core_control.Mutex.Recursive,
     55        CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
    5556        executing,
    5657        &queue_context
     
    6566      break;
    6667    case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
    67       _CORE_recursive_mutex_Surrender_no_protocol(
     68      status = _CORE_recursive_mutex_Surrender(
    6869        &the_semaphore->Core_control.Mutex.Recursive,
    6970        _Semaphore_Get_operations( the_semaphore ),
     
    7172        &queue_context
    7273      );
    73       status = STATUS_SUCCESSFUL;
    7474      break;
    7575    case SEMAPHORE_VARIANT_SIMPLE_BINARY:
  • cpukit/score/include/rtems/score/coremuteximpl.h

    r4e02681 r8797c76  
    135135RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize(
    136136  CORE_recursive_mutex_Control  *the_mutex,
    137   Thread_Control                *executing,
    138   bool                           wait,
    139   Status_Control              ( *nested )( CORE_recursive_mutex_Control * ),
    140   Thread_queue_Context          *queue_context
    141 )
    142 {
    143   Thread_Control *owner;
    144 
    145   _CORE_mutex_Acquire_critical( &the_mutex->Mutex, queue_context );
    146 
    147   owner = _CORE_mutex_Get_owner( &the_mutex->Mutex );
    148 
    149   if ( owner == NULL ) {
    150     _CORE_mutex_Set_owner( &the_mutex->Mutex, executing );
    151     ++executing->resource_count;
    152     _CORE_mutex_Release( &the_mutex->Mutex, queue_context );
    153     return STATUS_SUCCESSFUL;
    154   }
    155 
    156   if ( owner == executing ) {
    157     Status_Control status;
    158 
    159     status = ( *nested )( the_mutex );
    160     _CORE_mutex_Release( &the_mutex->Mutex, queue_context );
    161     return status;
    162   }
    163 
    164   return _CORE_mutex_Seize_slow(
    165     &the_mutex->Mutex,
    166     CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
    167     executing,
    168     wait,
    169     queue_context
    170   );
    171 }
    172 
    173 RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Surrender(
    174   CORE_recursive_mutex_Control *the_mutex,
    175   Thread_Control               *executing,
    176   Thread_queue_Context         *queue_context
    177 )
    178 {
    179   unsigned int        nest_level;
    180   Thread_queue_Heads *heads;
    181 
    182   _CORE_mutex_Acquire_critical( &the_mutex->Mutex, queue_context );
    183 
    184   if ( !_CORE_mutex_Is_owner( &the_mutex->Mutex, executing ) ) {
    185     _CORE_mutex_Release( &the_mutex->Mutex, queue_context );
    186     return STATUS_NOT_OWNER;
    187   }
    188 
    189   nest_level = the_mutex->nest_level;
    190 
    191   if ( nest_level > 0 ) {
    192     the_mutex->nest_level = nest_level - 1;
    193     _CORE_mutex_Release( &the_mutex->Mutex, queue_context );
    194     return STATUS_SUCCESSFUL;
    195   }
    196 
    197   --executing->resource_count;
    198   _CORE_mutex_Set_owner( &the_mutex->Mutex, NULL );
    199 
    200   heads = the_mutex->Mutex.Wait_queue.Queue.heads;
    201 
    202   if ( heads == NULL ) {
    203     _CORE_mutex_Release( &the_mutex->Mutex, queue_context );
    204     return STATUS_SUCCESSFUL;
    205   }
    206 
    207   _Thread_queue_Surrender(
    208     &the_mutex->Mutex.Wait_queue.Queue,
    209     heads,
    210     executing,
    211     queue_context,
    212     CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS
    213   );
    214   return STATUS_SUCCESSFUL;
    215 }
    216 
    217 RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_no_protocol(
    218   CORE_recursive_mutex_Control  *the_mutex,
    219137  const Thread_queue_Operations *operations,
    220138  Thread_Control                *executing,
     
    232150  if ( owner == NULL ) {
    233151    _CORE_mutex_Set_owner( &the_mutex->Mutex, executing );
     152    ++executing->resource_count;
    234153    _CORE_mutex_Release( &the_mutex->Mutex, queue_context );
    235154    return STATUS_SUCCESSFUL;
     
    253172}
    254173
    255 RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Surrender_no_protocol(
     174RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Surrender(
    256175  CORE_recursive_mutex_Control  *the_mutex,
    257176  const Thread_queue_Operations *operations,
     
    260179)
    261180{
    262   unsigned int    nest_level;
    263   Thread_Control *new_owner;
     181  unsigned int        nest_level;
     182  Thread_queue_Heads *heads;
    264183
    265184  _CORE_mutex_Acquire_critical( &the_mutex->Mutex, queue_context );
     
    278197  }
    279198
    280   new_owner = _Thread_queue_First_locked(
    281     &the_mutex->Mutex.Wait_queue,
    282     operations
    283   );
    284   _CORE_mutex_Set_owner( &the_mutex->Mutex, new_owner );
    285 
    286   if ( new_owner == NULL ) {
     199  --executing->resource_count;
     200  _CORE_mutex_Set_owner( &the_mutex->Mutex, NULL );
     201
     202  heads = the_mutex->Mutex.Wait_queue.Queue.heads;
     203
     204  if ( heads == NULL ) {
    287205    _CORE_mutex_Release( &the_mutex->Mutex, queue_context );
    288206    return STATUS_SUCCESSFUL;
    289207  }
    290208
    291   _Thread_queue_Extract_critical(
     209  _Thread_queue_Surrender(
    292210    &the_mutex->Mutex.Wait_queue.Queue,
    293     operations,
    294     new_owner,
    295     queue_context
     211    heads,
     212    executing,
     213    queue_context,
     214    operations
    296215  );
    297216  return STATUS_SUCCESSFUL;
  • cpukit/score/src/apimutexlock.c

    r4e02681 r8797c76  
    3737  _CORE_recursive_mutex_Seize(
    3838    &the_mutex->Mutex,
     39    CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
    3940    _Thread_Executing,
    4041    true,
  • cpukit/score/src/apimutexunlock.c

    r4e02681 r8797c76  
    3636  _CORE_recursive_mutex_Surrender(
    3737    &the_mutex->Mutex,
     38    CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
    3839    _Thread_Executing,
    3940    &queue_context
Note: See TracChangeset for help on using the changeset viewer.