diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-30 06:59:55 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-30 16:16:23 +0200 |
commit | 0b713f8940d90b480f8cd36663c11aa0688587d8 (patch) | |
tree | c71a01748c3749e0243518b486c2bb32a1c67df1 /cpukit/posix/src/mutexinit.c | |
parent | score: Rework CORE priority ceiling mutex (diff) | |
download | rtems-0b713f8940d90b480f8cd36663c11aa0688587d8.tar.bz2 |
score: Rework CORE inherit priority mutex
Provide dedicated seize and surrender methods for inherit priority
mutexes. This eliminates CORE_mutex_Attributes.
Diffstat (limited to 'cpukit/posix/src/mutexinit.c')
-rw-r--r-- | cpukit/posix/src/mutexinit.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c index 6c5705b20b..73f0544965 100644 --- a/cpukit/posix/src/mutexinit.c +++ b/cpukit/posix/src/mutexinit.c @@ -119,33 +119,22 @@ int pthread_mutex_init( the_mutex->protocol = protocol; the_mutex->is_recursive = ( the_attr->type == PTHREAD_MUTEX_RECURSIVE ); - if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) { - _CORE_ceiling_mutex_Initialize( - &the_mutex->Mutex, - _POSIX_Priority_To_core( the_attr->prio_ceiling ) - ); - } else if ( protocol == POSIX_MUTEX_NO_PROTOCOL ) { - _CORE_recursive_mutex_Initialize( - &the_mutex->Mutex.Recursive - ); - } else { - CORE_mutex_Attributes the_mutex_attr; - - if ( the_attr->type == PTHREAD_MUTEX_RECURSIVE ) { - the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES; - } else { - the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_IS_ERROR; - } - - /* - * Must be initialized to unlocked. - */ - _CORE_mutex_Initialize( - &the_mutex->Mutex.Recursive.Mutex, - NULL, - &the_mutex_attr, - false - ); + switch ( the_mutex->protocol ) { + case POSIX_MUTEX_PRIORITY_CEILING: + _CORE_ceiling_mutex_Initialize( + &the_mutex->Mutex, + _POSIX_Priority_To_core( the_attr->prio_ceiling ) + ); + break; + default: + _Assert( + the_mutex->protocol == POSIX_MUTEX_NO_PROTOCOL + || the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT + ); + _CORE_recursive_mutex_Initialize( + &the_mutex->Mutex.Recursive + ); + break; } _Objects_Open_u32( &_POSIX_Mutex_Information, &the_mutex->Object, 0 ); |