summaryrefslogtreecommitdiffstats
path: root/cpukit
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
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')
-rw-r--r--cpukit/ChangeLog7
-rw-r--r--cpukit/posix/src/mutexsetprioceiling.c20
-rw-r--r--cpukit/score/src/coremutexsurrender.c32
3 files changed, 43 insertions, 16 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 3b9a35d2e4..596e87016d 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
2009-07-06 Joel Sherrill <joel.sherrill@OARcorp.com>
* posix/src/mutexget.c: Restructure to improve ability to do coverage
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)
diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c
index 16268934af..28d4b5d876 100644
--- a/cpukit/score/src/coremutexsurrender.c
+++ b/cpukit/score/src/coremutexsurrender.c
@@ -84,17 +84,27 @@ CORE_mutex_Status _CORE_mutex_Surrender(
the_mutex->nest_count--;
- if ( the_mutex->nest_count != 0 ) {
- switch ( the_mutex->Attributes.lock_nesting_behavior ) {
- case CORE_MUTEX_NESTING_ACQUIRES:
- return CORE_MUTEX_STATUS_SUCCESSFUL;
- case CORE_MUTEX_NESTING_IS_ERROR:
- /* should never occur */
- return CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED;
- case CORE_MUTEX_NESTING_BLOCKS:
- /* Currently no API exercises this behavior. */
- break;
- }
+ if ( the_mutex->nest_count != 0 ) {
+ /*
+ * All error checking is on the locking side, so if the lock was
+ * allowed to acquired multiple times, then we should just deal with
+ * that. The RTEMS_DEBUG is just a validation.
+ */
+ #if defined(RTEMS_DEBUG)
+ switch ( the_mutex->Attributes.lock_nesting_behavior ) {
+ case CORE_MUTEX_NESTING_ACQUIRES:
+ return CORE_MUTEX_STATUS_SUCCESSFUL;
+ case CORE_MUTEX_NESTING_IS_ERROR:
+ /* should never occur */
+ return CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED;
+ case CORE_MUTEX_NESTING_BLOCKS:
+ /* Currently no API exercises this behavior. */
+ break;
+ }
+ #else
+ /* must be CORE_MUTEX_NESTING_ACQUIRES or we wouldn't be here */
+ return CORE_MUTEX_STATUS_SUCCESSFUL;
+ #endif
}
/*