From 83df49f697d770276c16af18884e2c4aeb393ab8 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 11 Jul 2006 21:05:12 +0000 Subject: 2006-07-11 Joel Sherrill PR 1124/rtems * score/include/rtems/score/threadq.h, score/src/coremutexseize.c, score/src/coremutexsurrender.c, score/src/threadqenqueue.c, score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c: The placement of the changing a thread's priority when using priority ceiling should be on the successful transfer of the mutex -- not when the thread tries to acquire. Plus the lack of a dispatch disable point lead to the potential for a thread timing out and already having inherited the ceiling priority. --- cpukit/score/src/coremutexsurrender.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'cpukit/score/src/coremutexsurrender.c') diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c index 917eef6051..e6f52e229d 100644 --- a/cpukit/score/src/coremutexsurrender.c +++ b/cpukit/score/src/coremutexsurrender.c @@ -127,16 +127,27 @@ CORE_mutex_Status _CORE_mutex_Surrender( the_mutex->holder = the_thread; the_mutex->holder_id = the_thread->Object.id; - 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; - /* - * No special action for priority inheritance or priority ceiling - * because the_thread is guaranteed to be the highest priority - * thread waiting for the mutex. - */ + switch ( the_mutex->Attributes.discipline ) { + case CORE_MUTEX_DISCIPLINES_FIFO: + case CORE_MUTEX_DISCIPLINES_PRIORITY: + break; + case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: + the_thread->resource_count++; + break; + case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: + the_thread->resource_count++; + if (the_mutex->Attributes.priority_ceiling < + the_thread->current_priority){ + _Thread_Change_priority( + the_thread, + the_mutex->Attributes.priority_ceiling, + FALSE + ); + } + break; + } } } else the_mutex->lock = CORE_MUTEX_UNLOCKED; -- cgit v1.2.3