[PATCH 2/5] score: Simplify _Thread_Set_state()

Joel Sherrill joel.sherrill at oarcorp.com
Tue Mar 31 14:47:15 UTC 2015



On 3/31/2015 1:00 AM, Sebastian Huber wrote:
> ---
>  cpukit/score/src/threadsetstate.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/cpukit/score/src/threadsetstate.c b/cpukit/score/src/threadsetstate.c
> index 02ee70e..8114d70 100644
> --- a/cpukit/score/src/threadsetstate.c
> +++ b/cpukit/score/src/threadsetstate.c
> @@ -22,7 +22,6 @@
>  #endif
>  
>  #include <rtems/score/threadimpl.h>
> -#include <rtems/score/isrlevel.h>
>  #include <rtems/score/schedulerimpl.h>
>  
>  void _Thread_Set_state(
> @@ -31,17 +30,17 @@ void _Thread_Set_state(
>  )
>  {
>    ISR_lock_Context lock_context;
> -  States_Control   current_state;
> +  States_Control   previous_state;
> +  States_Control   next_state;
>  
Would it make sense to put a debug assert here that the state being
set is non-zero?

Otherwise, unless there are logically more self-checks, I don't have
a problem with this patch set.

Did it reduce code size any?
>    _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 );

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the devel mailing list