Changeset 12f9c5b7 in rtems


Ignore:
Timestamp:
Apr 27, 2017, 11:52:01 PM (3 years ago)
Author:
Joel Sherrill <joel@…>
Branches:
master
Children:
20775247
Parents:
c16d45a5
Message:

posix/src/mutexinit.c: Reorder to make priority a scoped variable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/mutexinit.c

    rc16d45a5 r12f9c5b7  
    116116  the_mutex->is_recursive = ( the_attr->type == PTHREAD_MUTEX_RECURSIVE );
    117117
    118   switch ( protocol ) {
    119     case POSIX_MUTEX_PRIORITY_CEILING: {
    120       int               prio_ceiling;
    121       bool              valid;
    122       Priority_Control  priority;
     118  if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
     119    int               prio_ceiling;
     120    bool              valid;
     121    Priority_Control  priority;
    123122
    124       scheduler = _Thread_Scheduler_get_home( _Thread_Get_executing() );
    125       prio_ceiling = the_attr->prio_ceiling;
     123    scheduler = _Thread_Scheduler_get_home( _Thread_Get_executing() );
     124    prio_ceiling = the_attr->prio_ceiling;
    126125
    127       if ( prio_ceiling == INT_MAX ) {
    128         prio_ceiling = _POSIX_Priority_Get_maximum( scheduler );
    129       }
     126    if ( prio_ceiling == INT_MAX ) {
     127      prio_ceiling = _POSIX_Priority_Get_maximum( scheduler );
     128    }
    130129
    131       priority = _POSIX_Priority_To_core( scheduler, prio_ceiling, &valid );
    132       if ( !valid ) {
    133         _POSIX_Mutex_Free(the_mutex);
    134         _Objects_Allocator_unlock();
    135         return EINVAL;
    136       }
    137       _CORE_ceiling_mutex_Initialize( &the_mutex->Mutex, scheduler, priority );
    138       break;
     130    priority = _POSIX_Priority_To_core( scheduler, prio_ceiling, &valid );
     131    if ( !valid ) {
     132      _POSIX_Mutex_Free(the_mutex);
     133      _Objects_Allocator_unlock();
     134      return EINVAL;
    139135    }
    140     default:
    141       _Assert(
    142         the_mutex->protocol == POSIX_MUTEX_NO_PROTOCOL
    143           || the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT
    144       );
    145       _CORE_recursive_mutex_Initialize( &the_mutex->Mutex.Recursive );
    146       break;
     136    _CORE_ceiling_mutex_Initialize( &the_mutex->Mutex, scheduler, priority );
     137  } else {
     138    _Assert(
     139      the_mutex->protocol == POSIX_MUTEX_NO_PROTOCOL
     140        || the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT
     141    );
     142    _CORE_recursive_mutex_Initialize( &the_mutex->Mutex.Recursive );
    147143  }
    148144
Note: See TracChangeset for help on using the changeset viewer.