From ca10004ef252b3ef7da95d3b9e7437c5c9256d20 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 26 Mar 2015 21:16:09 +0100 Subject: score: Simplify _Thread_Set_state() --- cpukit/score/include/rtems/score/threadimpl.h | 15 +++++---------- cpukit/score/src/threadsetstate.c | 16 +++++++++------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index 551df452d6..f32362f7e2 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -258,18 +258,13 @@ void _Thread_Clear_state( ); /** - * @brief Sets the indicated @a state for @a the_thread. + * @brief Sets the specified thread state. * - * This routine sets the indicated @a state for @a the_thread. It performs - * any necessary scheduling operations including the selection of - * a new heir thread. - * - * @param[in] the_thread is the thread to set the state for. - * @param[in] state is the state to set the_thread to. + * In case the previous state is the ready state, then the thread is blocked by + * the scheduler. * - * - INTERRUPT LATENCY: - * + ready chain - * + select map + * @param[in] the_thread The thread. + * @param[in] state The state to set. It must not be zero. */ void _Thread_Set_state( Thread_Control *the_thread, diff --git a/cpukit/score/src/threadsetstate.c b/cpukit/score/src/threadsetstate.c index 02ee70ed9b..2769711dac 100644 --- a/cpukit/score/src/threadsetstate.c +++ b/cpukit/score/src/threadsetstate.c @@ -22,7 +22,7 @@ #endif #include -#include +#include #include void _Thread_Set_state( @@ -31,17 +31,19 @@ void _Thread_Set_state( ) { ISR_lock_Context lock_context; - States_Control current_state; + States_Control previous_state; + States_Control next_state; + + _Assert( state != 0 ); _Scheduler_Acquire( the_thread, &lock_context ); - current_state = the_thread->current_state; - if ( _States_Is_ready( current_state ) ) { - the_thread->current_state = state; + previous_state = the_thread->current_state; + next_state = _States_Set( state, previous_state); + the_thread->current_state = next_state; + if ( _States_Is_ready( previous_state ) ) { _Scheduler_Block( the_thread ); - } else { - the_thread->current_state = _States_Set( state, current_state); } _Scheduler_Release( the_thread, &lock_context ); -- cgit v1.2.3