From d9aca5f5376cea0053c5c099111c8adc8191974e Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 16 May 2008 21:51:40 +0000 Subject: 2008-05-16 Till Straumann * score/src/threadchangepriority.c: Just in case the transient state was set when we entered, ensure that it is still set when we exit. * score/src/threadclose.c: When a thread is being deleted, it should go into the dormant state -- not the transient state. --- cpukit/score/src/threadchangepriority.c | 38 +++++++++++++++++++++------------ cpukit/score/src/threadclose.c | 4 ++-- 2 files changed, 26 insertions(+), 16 deletions(-) (limited to 'cpukit/score/src') diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c index 70ec45cb51..df3ad0983f 100644 --- a/cpukit/score/src/threadchangepriority.c +++ b/cpukit/score/src/threadchangepriority.c @@ -56,7 +56,7 @@ void _Thread_Change_priority( ) { ISR_Level level; - States_Control state; + States_Control state, original_state; /* * If this is a case where prepending the task to its priority is @@ -73,6 +73,11 @@ void _Thread_Change_priority( prepend_it = TRUE; */ + /* + * Save original state + */ + original_state = the_thread->current_state; + /* * Set a transient state for the thread so it is pulled off the Ready chains. * This will prevent it from being scheduled no matter what happens in an @@ -95,7 +100,9 @@ void _Thread_Change_priority( */ state = the_thread->current_state; if ( state != STATES_TRANSIENT ) { - the_thread->current_state = _States_Clear( STATES_TRANSIENT, state ); + /* Only clear the transient state if it wasn't set already */ + if ( ! _States_Is_transient( original_state ) ) + the_thread->current_state = _States_Clear( STATES_TRANSIENT, state ); _ISR_Enable( level ); if ( _States_Is_waiting_on_thread_queue( state ) ) { _Thread_queue_Requeue( the_thread->Wait.queue, the_thread ); @@ -103,19 +110,22 @@ void _Thread_Change_priority( return; } - /* - * Interrupts are STILL disabled. - * We now know the thread will be in the READY state when we remove - * the TRANSIENT state. So we have to place it on the appropriate - * Ready Queue with interrupts off. - */ - the_thread->current_state = _States_Clear( STATES_TRANSIENT, state ); + /* Only clear the transient state if it wasn't set already */ + if ( ! _States_Is_transient( original_state ) ) { + /* + * Interrupts are STILL disabled. + * We now know the thread will be in the READY state when we remove + * the TRANSIENT state. So we have to place it on the appropriate + * Ready Queue with interrupts off. + */ + the_thread->current_state = _States_Clear( STATES_TRANSIENT, state ); - _Priority_Add_to_bit_map( &the_thread->Priority_map ); - if ( prepend_it ) - _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node ); - else - _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node ); + _Priority_Add_to_bit_map( &the_thread->Priority_map ); + if ( prepend_it ) + _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node ); + else + _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node ); + } _ISR_Flash( level ); diff --git a/cpukit/score/src/threadclose.c b/cpukit/score/src/threadclose.c index f8231a1192..a29aebdca7 100644 --- a/cpukit/score/src/threadclose.c +++ b/cpukit/score/src/threadclose.c @@ -66,10 +66,10 @@ void _Thread_Close( _Objects_Close( information, &the_thread->Object ); /* - * By setting the transient state, the thread will not be considered + * By setting the dormant state, the thread will not be considered * for scheduling when we remove any blocking states. */ - _Thread_Set_state( the_thread, STATES_TRANSIENT ); + _Thread_Set_state( the_thread, STATES_DORMANT ); if ( !_Thread_queue_Extract_with_proxy( the_thread ) ) { if ( _Watchdog_Is_active( &the_thread->Timer ) ) -- cgit v1.2.3