diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-05-28 20:38:12 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-05-28 20:38:12 +0000 |
commit | 7c8d65e83558f0d90526b28cba00c5c0aef7ada0 (patch) | |
tree | 2f2289a752951f481a3568cd6ccb4b6c52c5f2cc /cpukit/rtems/src/semcreate.c | |
parent | 2009-05-28 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-7c8d65e83558f0d90526b28cba00c5c0aef7ada0.tar.bz2 |
2009-05-28 Joel Sherrill <joel.sherrill@OARcorp.com>
PR 1415/cpukit
* rtems/src/semcreate.c, rtems/src/semtranslatereturncode.c,
score/include/rtems/score/coremutex.h,
score/inline/rtems/score/coremutex.inl, score/src/coremutex.c:
Address two paths where a task with a priority above the ceiling
could obtain a priority ceiling mutex.
Diffstat (limited to 'cpukit/rtems/src/semcreate.c')
-rw-r--r-- | cpukit/rtems/src/semcreate.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c index d5274daeea..09969d89be 100644 --- a/cpukit/rtems/src/semcreate.c +++ b/cpukit/rtems/src/semcreate.c @@ -80,7 +80,6 @@ rtems_status_code rtems_semaphore_create( register Semaphore_Control *the_semaphore; CORE_mutex_Attributes the_mutex_attributes; CORE_semaphore_Attributes the_semaphore_attributes; - uint32_t lock; if ( !rtems_is_name_valid( name ) ) return RTEMS_INVALID_NAME; @@ -146,6 +145,8 @@ rtems_status_code rtems_semaphore_create( */ if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) { + CORE_mutex_Status mutex_status; + if ( _Attributes_Is_inherit_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; else if ( _Attributes_Is_priority_ceiling( attribute_set ) ) @@ -176,16 +177,17 @@ rtems_status_code rtems_semaphore_create( the_mutex_attributes.priority_ceiling = priority_ceiling; - if ( count == 1 ) - lock = CORE_MUTEX_UNLOCKED; - else - lock = CORE_MUTEX_LOCKED; - - _CORE_mutex_Initialize( + mutex_status = _CORE_mutex_Initialize( &the_semaphore->Core_control.mutex, &the_mutex_attributes, - lock - ); + (count == 1) ? CORE_MUTEX_UNLOCKED : CORE_MUTEX_LOCKED + ); + + if ( mutex_status == CORE_MUTEX_STATUS_CEILING_VIOLATED ) { + _Semaphore_Free( the_semaphore ); + _Thread_Enable_dispatch(); + return RTEMS_INVALID_PRIORITY; + } } else { if ( _Attributes_Is_priority( attribute_set ) ) the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY; |