diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-03-26 21:16:09 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-04-08 10:25:33 +0200 |
commit | ca10004ef252b3ef7da95d3b9e7437c5c9256d20 (patch) | |
tree | be51aebf46b16b37639abbe8b7719adea9b82e7e | |
parent | fstests/fsfseeko01: Fix for long == off_t (diff) | |
download | rtems-ca10004ef252b3ef7da95d3b9e7437c5c9256d20.tar.bz2 |
score: Simplify _Thread_Set_state()
-rw-r--r-- | cpukit/score/include/rtems/score/threadimpl.h | 15 | ||||
-rw-r--r-- | 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 <rtems/score/threadimpl.h> -#include <rtems/score/isrlevel.h> +#include <rtems/score/assert.h> #include <rtems/score/schedulerimpl.h> 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 ); |