Changeset 09c5ca4 in rtems for cpukit/rtems


Ignore:
Timestamp:
May 26, 2016, 8:29:56 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
8a77ef63
Parents:
2581a56
git-author:
Sebastian Huber <sebastian.huber@…> (05/26/16 20:29:56)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/30/16 14:16:22)
Message:

score: Simplify CORE mutex

Remove superfluous support for simple binary semaphores. With this we
can get rid of the CORE_MUTEX_NESTING_BLOCKS variant.

Location:
cpukit/rtems
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/include/rtems/rtems/semimpl.h

    r2581a56 r09c5ca4  
    2929typedef enum {
    3030  SEMAPHORE_VARIANT_MUTEX,
     31  SEMAPHORE_VARIANT_SIMPLE_BINARY,
    3132  SEMAPHORE_VARIANT_COUNTING
    3233#if defined(RTEMS_SMP)
  • cpukit/rtems/src/semcreate.c

    r2581a56 r09c5ca4  
    144144  }
    145145
    146   /*
    147    *  Initialize it as a counting semaphore.
    148    */
    149146  if ( _Attributes_Is_counting_semaphore( attribute_set ) ) {
    150147    the_semaphore->variant = SEMAPHORE_VARIANT_COUNTING;
     
    152149      &the_semaphore->Core_control.semaphore,
    153150      count
     151    );
     152    status = STATUS_SUCCESSFUL;
     153  } else if ( _Attributes_Is_simple_binary_semaphore( attribute_set ) ) {
     154    the_semaphore->variant = SEMAPHORE_VARIANT_SIMPLE_BINARY;
     155    _CORE_semaphore_Initialize(
     156      &the_semaphore->Core_control.semaphore,
     157      count != 0
    154158    );
    155159    status = STATUS_SUCCESSFUL;
     
    167171    the_semaphore->variant = SEMAPHORE_VARIANT_MUTEX;
    168172
     173    _Assert( _Attributes_Is_binary_semaphore( attribute_set ) );
     174
    169175    /*
    170176     *  It is either simple binary semaphore or a more powerful mutex
     
    176182      the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_FIFO;
    177183
    178     if ( _Attributes_Is_binary_semaphore( attribute_set ) ) {
    179       the_mutex_attr.priority_ceiling      = _RTEMS_tasks_Priority_to_Core(
    180                                                priority_ceiling
    181                                              );
    182       the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES;
    183       the_mutex_attr.only_owner_release    = false;
    184 
    185       if ( the_mutex_attr.discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) {
    186         if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
    187           the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
    188           the_mutex_attr.only_owner_release = true;
    189         } else if ( _Attributes_Is_priority_ceiling( attribute_set ) ) {
    190           the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
    191           the_mutex_attr.only_owner_release = true;
    192         }
     184    the_mutex_attr.priority_ceiling      = _RTEMS_tasks_Priority_to_Core(
     185                                             priority_ceiling
     186                                           );
     187    the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES;
     188    the_mutex_attr.only_owner_release    = false;
     189
     190    if ( the_mutex_attr.discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) {
     191      if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
     192        the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
     193        the_mutex_attr.only_owner_release = true;
     194      } else if ( _Attributes_Is_priority_ceiling( attribute_set ) ) {
     195        the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
     196        the_mutex_attr.only_owner_release = true;
    193197      }
    194     } else /* must be simple binary semaphore */ {
    195       the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_BLOCKS;
    196       the_mutex_attr.only_owner_release = false;
    197198    }
    198199
  • cpukit/rtems/src/semdelete.c

    r2581a56 r09c5ca4  
    2020
    2121#include <rtems/rtems/semimpl.h>
    22 #include <rtems/rtems/attrimpl.h>
    2322#include <rtems/rtems/statusimpl.h>
    2423
     
    2928  Semaphore_Control    *the_semaphore;
    3029  Thread_queue_Context  queue_context;
    31   rtems_attribute       attribute_set;
    3230  Status_Control        status;
    3331
     
    4745  }
    4846
    49   attribute_set = the_semaphore->attribute_set;
    50 
    5147  _Thread_queue_Acquire_critical(
    5248    &the_semaphore->Core_control.Wait_queue,
     
    5652  switch ( the_semaphore->variant ) {
    5753    case SEMAPHORE_VARIANT_MUTEX:
    58       if (
    59         _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex )
    60           && !_Attributes_Is_simple_binary_semaphore( attribute_set )
    61       ) {
     54      if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) ) {
    6255        status = STATUS_RESOURCE_IN_USE;
    6356      } else {
     
    7265#endif
    7366    default:
    74       _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING );
     67      _Assert(
     68        the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
     69          || the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING
     70      );
    7571      status = STATUS_SUCCESSFUL;
    7672      break;
     
    10399#endif
    104100    default:
    105       _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING );
     101      _Assert(
     102        the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
     103          || the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING
     104      );
    106105      _CORE_semaphore_Destroy(
    107106        &the_semaphore->Core_control.semaphore,
  • cpukit/rtems/src/semflush.c

    r2581a56 r09c5ca4  
    6464      break;
    6565    default:
    66       _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING );
     66      _Assert(
     67        the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
     68          || the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING
     69      );
    6770      _CORE_semaphore_Flush(
    6871        &the_semaphore->Core_control.semaphore,
  • cpukit/rtems/src/semobtain.c

    r2581a56 r09c5ca4  
    9292      break;
    9393    default:
    94       _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING );
     94      _Assert(
     95        the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
     96          || the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING
     97      );
    9598      status = _CORE_semaphore_Seize(
    9699        &the_semaphore->Core_control.semaphore,
  • cpukit/rtems/src/semrelease.c

    r2581a56 r09c5ca4  
    6262      );
    6363      break;
     64    case SEMAPHORE_VARIANT_SIMPLE_BINARY:
     65      status = _CORE_semaphore_Surrender(
     66        &the_semaphore->Core_control.semaphore,
     67        _Semaphore_Get_operations( the_semaphore ),
     68        1,
     69        &queue_context
     70      );
     71      _Assert(
     72        status == STATUS_SUCCESSFUL
     73          || status == STATUS_MAXIMUM_COUNT_EXCEEDED
     74      );
     75      status = STATUS_SUCCESSFUL;
     76      break;
    6477    default:
    6578      _Assert( the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING );
Note: See TracChangeset for help on using the changeset viewer.