summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/coremutexsurrender.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2001-08-30 18:33:57 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2001-08-30 18:33:57 +0000
commitfb1d8f81a0e38540fb470da89d044dd28b0134ad (patch)
treecaa751896d100e3e7eaf54fa4edfe18bb8454daf /cpukit/score/src/coremutexsurrender.c
parent760045f0f34ce2b801066128f340b2267d91b26d (diff)
downloadrtems-fb1d8f81a0e38540fb470da89d044dd28b0134ad.tar.bz2
2001-08-30 Joel Sherrill <joel@OARcorp.com>
* src/coremutex.c, src/coremutexseize.c, src/coremutexsurrender.c, inline/rtems/score/coremutex.inl: The per thread field resource_count should only be manipulated when a mutex is priority ceiling or priority inherit. This was reported by Chris Johns <ccj@acm.org> who also noticed that the use of switches for all disciplines generated less efficient code than using explicit tests for the one or two cases we were really interested in. Further review of his modifications made it apparent that the "isa" methods to test mutex discipline were not being used so this modification was swept into the code as well.
Diffstat (limited to 'cpukit/score/src/coremutexsurrender.c')
-rw-r--r--cpukit/score/src/coremutexsurrender.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c
index f60faba558..bd9cc5bf65 100644
--- a/cpukit/score/src/coremutexsurrender.c
+++ b/cpukit/score/src/coremutexsurrender.c
@@ -86,7 +86,9 @@ CORE_mutex_Status _CORE_mutex_Surrender(
}
}
- holder->resource_count--;
+ if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
+ _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) )
+ holder->resource_count--;
the_mutex->holder = NULL;
the_mutex->holder_id = 0;
@@ -96,20 +98,14 @@ CORE_mutex_Status _CORE_mutex_Surrender(
* mutex (i.e. resource) this task has.
*/
- switch ( the_mutex->Attributes.discipline ) {
- case CORE_MUTEX_DISCIPLINES_FIFO:
- case CORE_MUTEX_DISCIPLINES_PRIORITY:
- break;
- case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
- case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
- if ( holder->resource_count == 0 &&
- holder->real_priority != holder->current_priority ) {
- _Thread_Change_priority( holder, holder->real_priority, TRUE );
- }
- break;
+ if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
+ _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
+ if ( holder->resource_count == 0 &&
+ holder->real_priority != holder->current_priority ) {
+ _Thread_Change_priority( holder, holder->real_priority, TRUE );
+ }
}
-
if ( ( the_thread = _Thread_queue_Dequeue( &the_mutex->Wait_queue ) ) ) {
#if defined(RTEMS_MULTIPROCESSING)
@@ -127,7 +123,9 @@ CORE_mutex_Status _CORE_mutex_Surrender(
the_mutex->holder = the_thread;
the_mutex->holder_id = the_thread->Object.id;
- the_thread->resource_count++;
+ if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
+ _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) )
+ the_thread->resource_count++;
the_mutex->nest_count = 1;
/*