Changeset b503e0b9 in rtems


Ignore:
Timestamp:
Jul 9, 2009, 9:55:23 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
744379e
Parents:
7f8dd57
Message:

2009-07-09 Joel Sherrill <joel.sherrill@…>

  • rtems/src/semcreate.c: Clean up rework to eliminate the goto and fix a bug introduced by rework.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r7f8dd57 rb503e0b9  
     12009-07-09      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * rtems/src/semcreate.c: Clean up rework to eliminate the goto and fix
     4        a bug introduced by rework.
     5
    162009-07-09      Joel Sherrill <joel.sherrill@OARcorp.com>
    27
  • cpukit/rtems/src/semcreate.c

    r7f8dd57 rb503e0b9  
    8383  CORE_mutex_Status           mutex_status;
    8484
    85 
    8685  if ( !rtems_is_name_valid( name ) )
    8786    return RTEMS_INVALID_NAME;
     
    9695      return RTEMS_MP_NOT_CONFIGURED;
    9796
    98     if ( _Attributes_Is_inherit_priority( attribute_set ) )
     97    if ( _Attributes_Is_inherit_priority( attribute_set ) ||
     98         _Attributes_Is_priority_ceiling( attribute_set ) ) {
    9999      return RTEMS_NOT_DEFINED;
    100100
     
    105105              _Attributes_Is_priority_ceiling( attribute_set ) ) {
    106106
    107     if ( ! ( (_Attributes_Is_binary_semaphore( attribute_set ) ||
    108               _Attributes_Is_simple_binary_semaphore( attribute_set )) &&
    109 
    110              _Attributes_Is_priority( attribute_set ) ) )
     107    if ( ! (_Attributes_Is_binary_semaphore( attribute_set ) &&
     108            _Attributes_Is_priority( attribute_set ) ) )
    111109      return RTEMS_NOT_DEFINED;
    112110
     
    166164      count
    167165    );
    168     goto open_object;
     166  } else {
     167    /*
     168     *  It is either simple binary semaphore or a more powerful mutex
     169     *  style binary semaphore.  This is the mutex style.
     170     */
     171    if ( _Attributes_Is_priority( attribute_set ) )
     172      the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY;
     173    else
     174      the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_FIFO;
     175
     176    if ( _Attributes_Is_binary_semaphore( attribute_set ) ) {
     177      the_mutex_attr.priority_ceiling      = priority_ceiling;
     178      the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES;
     179      the_mutex_attr.only_owner_release    = false;
     180
     181      if ( the_mutex_attr.discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) {
     182        if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
     183          the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
     184          the_mutex_attr.only_owner_release = true;
     185        } else if ( _Attributes_Is_priority_ceiling( attribute_set ) ) {
     186          the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
     187          the_mutex_attr.only_owner_release = true;
     188        }
     189      }
     190    } else /* must be simple binary semaphore */ {
     191      the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_BLOCKS;
     192      the_mutex_attr.only_owner_release = false;
     193    }
     194
     195    mutex_status = _CORE_mutex_Initialize(
     196      &the_semaphore->Core_control.mutex,
     197      &the_mutex_attr,
     198      (count == 1) ? CORE_MUTEX_UNLOCKED : CORE_MUTEX_LOCKED
     199    );
     200
     201    if ( mutex_status == CORE_MUTEX_STATUS_CEILING_VIOLATED ) {
     202      _Semaphore_Free( the_semaphore );
     203      _Thread_Enable_dispatch();
     204      return RTEMS_INVALID_PRIORITY;
     205    }
    169206  }
    170207
    171208  /*
    172    *  It is either simple binary semaphore or a more powerful mutex
    173    *  style binary semaphore.  This is the mutex style.
     209   *  Whether we initialized it as a mutex or counting semaphore, it is
     210   *  now ready to be "offered" for use as a Classic API Semaphore.
    174211   */
    175 
    176   if ( _Attributes_Is_priority( attribute_set ) )
    177     the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY;
    178   else
    179     the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_FIFO;
    180 
    181   if ( _Attributes_Is_binary_semaphore( attribute_set ) ) {
    182     the_mutex_attr.priority_ceiling      = priority_ceiling;
    183     the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES;
    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 {
    190         the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
    191         the_mutex_attr.only_owner_release = true;
    192       }
    193     } else
    194       the_mutex_attr.only_owner_release = false;
    195   } else /* must be simple binary semaphore */ {
    196     the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_BLOCKS;
    197     the_mutex_attr.only_owner_release = false;
    198   }
    199 
    200   mutex_status = _CORE_mutex_Initialize(
    201     &the_semaphore->Core_control.mutex,
    202     &the_mutex_attr,
    203     (count == 1) ? CORE_MUTEX_UNLOCKED : CORE_MUTEX_LOCKED
    204   );
    205 
    206   if ( mutex_status == CORE_MUTEX_STATUS_CEILING_VIOLATED ) {
    207     _Semaphore_Free( the_semaphore );
    208     _Thread_Enable_dispatch();
    209     return RTEMS_INVALID_PRIORITY;
    210   }
    211 
    212 open_object:
    213212  _Objects_Open(
    214213    &_Semaphore_Information,
Note: See TracChangeset for help on using the changeset viewer.