summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadchangepriority.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-05-16 21:51:40 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-05-16 21:51:40 +0000
commitd9aca5f5376cea0053c5c099111c8adc8191974e (patch)
tree8dbb8e437a8b32f4eed503e41f7b581bba17a2c8 /cpukit/score/src/threadchangepriority.c
parent2008-05-16 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-d9aca5f5376cea0053c5c099111c8adc8191974e.tar.bz2
2008-05-16 Till Straumann <strauman@slac.stanford.edu>
* 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.
Diffstat (limited to 'cpukit/score/src/threadchangepriority.c')
-rw-r--r--cpukit/score/src/threadchangepriority.c38
1 files changed, 24 insertions, 14 deletions
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
@@ -74,6 +74,11 @@ void _Thread_Change_priority(
*/
/*
+ * 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
* ISR.
@@ -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 );