summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mutexsetprioceiling.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-07 17:29:47 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-07 17:29:47 +0000
commit06f5ec9ce0fc6e876f40a4f07975049751fee669 (patch)
treeeed4c95664050c92cd77533429feb583ecab9e2f /cpukit/posix/src/mutexsetprioceiling.c
parent2009-07-07 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-06f5ec9ce0fc6e876f40a4f07975049751fee669.tar.bz2
2009-07-07 Joel Sherrill <joel.sherrill@OARcorp.com>
* posix/src/mutexsetprioceiling.c: Restructure to eliminate code paths which are unreachable. Also add more comments. * score/src/coremutexsurrender.c: Mark some code as RTEMS_DEBUG only since it cannot be hit unless coremutexseize.c is broken.
Diffstat (limited to 'cpukit/posix/src/mutexsetprioceiling.c')
-rw-r--r--cpukit/posix/src/mutexsetprioceiling.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/cpukit/posix/src/mutexsetprioceiling.c b/cpukit/posix/src/mutexsetprioceiling.c
index de35bbae23..8d7b40adf3 100644
--- a/cpukit/posix/src/mutexsetprioceiling.c
+++ b/cpukit/posix/src/mutexsetprioceiling.c
@@ -48,13 +48,19 @@ int pthread_mutex_setprioceiling(
the_priority = _POSIX_Priority_To_core( prioceiling );
/*
- * Must acquire the mutex before we can change it's ceiling
+ * Must acquire the mutex before we can change it's ceiling.
+ * POSIX says block until we acquire it.
*/
+ (void) pthread_mutex_lock( mutex );
- status = pthread_mutex_lock( mutex );
- if ( status )
- return status;
-
+ /*
+ * Do not worry about the return code from this. The Get operation
+ * will also fail if it is a bad id or was deleted between the two
+ * operations.
+ *
+ * NOTE: This makes it easier to get 100% binary coverage since the
+ * bad Id case is handled by the switch.
+ */
the_mutex = _POSIX_Mutex_Get( mutex, &location );
switch ( location ) {
@@ -63,12 +69,16 @@ int pthread_mutex_setprioceiling(
the_mutex->Mutex.Attributes.priority_ceiling
);
the_mutex->Mutex.Attributes.priority_ceiling = the_priority;
+ /*
+ * We are required to unlock the mutex before we return.
+ */
_CORE_mutex_Surrender(
&the_mutex->Mutex,
the_mutex->Object.id,
NULL
);
_Thread_Enable_dispatch();
+
return 0;
#if defined(RTEMS_MULTIPROCESSING)