2006-07-11 Joel Sherrill <joel@OARcorp.com>

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.
This commit is contained in:
Joel Sherrill
2006-07-11 21:05:12 +00:00
parent e8f5da0d2d
commit 83df49f697
7 changed files with 40 additions and 41 deletions

View File

@@ -1,3 +1,15 @@
2006-07-11 Joel Sherrill <joel@OARcorp.com>
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.
2006-06-28 Ralf Corsépius <ralf.corsepius@rtems.org>
* Makefile.am: Add ampolish3.

View File

@@ -143,8 +143,7 @@ Thread_Control *_Thread_queue_Dequeue_priority(
*/
void _Thread_queue_Enqueue_priority(
Thread_queue_Control *the_thread_queue,
Thread_Control *the_thread,
Watchdog_Interval timeout
Thread_Control *the_thread
);
/** @brief Thread queue Extract priority
@@ -185,8 +184,7 @@ Thread_Control *_Thread_queue_Dequeue_fifo(
*/
void _Thread_queue_Enqueue_fifo(
Thread_queue_Control *the_thread_queue,
Thread_Control *the_thread,
Watchdog_Interval timeout
Thread_Control *the_thread
);
/** @brief Thread queue Extract FIFO

View File

@@ -6,7 +6,7 @@
* This package is the implementation of the Mutex Handler.
* This handler provides synchronization and mutual exclusion capabilities.
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2006.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -60,22 +60,6 @@ void _CORE_mutex_Seize_interrupt_blocking(
the_mutex->blocked_count++;
_Thread_queue_Enqueue( &the_mutex->Wait_queue, timeout );
if ( _Thread_Executing->Wait.return_code == CORE_MUTEX_STATUS_SUCCESSFUL ) {
/*
* if CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT then nothing to do
* because this task is already the highest priority.
*/
if ( _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
if (the_mutex->Attributes.priority_ceiling < executing->current_priority){
_Thread_Change_priority(
executing,
the_mutex->Attributes.priority_ceiling,
FALSE
);
}
}
}
_Thread_Enable_dispatch();
}

View File

@@ -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;

View File

@@ -74,10 +74,10 @@ void _Thread_queue_Enqueue(
switch( the_thread_queue->discipline ) {
case THREAD_QUEUE_DISCIPLINE_FIFO:
_Thread_queue_Enqueue_fifo( the_thread_queue, the_thread, timeout );
_Thread_queue_Enqueue_fifo( the_thread_queue, the_thread );
break;
case THREAD_QUEUE_DISCIPLINE_PRIORITY:
_Thread_queue_Enqueue_priority( the_thread_queue, the_thread, timeout );
_Thread_queue_Enqueue_priority( the_thread_queue, the_thread );
break;
}
}

View File

@@ -29,13 +29,11 @@
*
* _Thread_queue_Enqueue_fifo
*
* This routine blocks a thread, places it on a thread, and optionally
* starts a timeout timer.
* This routine places a blocked thread on a FIFO thread queue.
*
* Input parameters:
* the_thread_queue - pointer to threadq
* the_thread - pointer to the thread to block
* timeout - interval to wait
*
* Output parameters: NONE
*
@@ -45,8 +43,7 @@
void _Thread_queue_Enqueue_fifo (
Thread_queue_Control *the_thread_queue,
Thread_Control *the_thread,
Watchdog_Interval timeout
Thread_Control *the_thread
)
{
ISR_Level level;

View File

@@ -29,13 +29,11 @@
*
* _Thread_queue_Enqueue_priority
*
* This routine blocks a thread, places it on a thread, and optionally
* starts a timeout timer.
* This routine places a blocked thread on a priority thread queue.
*
* Input parameters:
* the_thread_queue - pointer to threadq
* thread - thread to insert
* timeout - timeout interval in ticks
*
* Output parameters: NONE
*
@@ -46,8 +44,7 @@
void _Thread_queue_Enqueue_priority(
Thread_queue_Control *the_thread_queue,
Thread_Control *the_thread,
Watchdog_Interval timeout
Thread_Control *the_thread
)
{
Priority_Control search_priority;