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.
This commit is contained in:
Joel Sherrill
2009-07-07 17:29:47 +00:00
parent 9a845e175b
commit 06f5ec9ce0
3 changed files with 43 additions and 16 deletions
+7
View File
@@ -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
+15 -5
View File
@@ -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)
+21 -11
View File
@@ -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
}
/*