From fb1d8f81a0e38540fb470da89d044dd28b0134ad Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 30 Aug 2001 18:33:57 +0000 Subject: 2001-08-30 Joel Sherrill * 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 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. --- c/src/exec/score/src/coremutexsurrender.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'c/src/exec/score/src/coremutexsurrender.c') diff --git a/c/src/exec/score/src/coremutexsurrender.c b/c/src/exec/score/src/coremutexsurrender.c index f60faba558..bd9cc5bf65 100644 --- a/c/src/exec/score/src/coremutexsurrender.c +++ b/c/src/exec/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; /* -- cgit v1.2.3