[PATCH 2/4] score: Prevent assignment to _Thread_Executing

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Nov 4 15:40:48 UTC 2016


----- Gedare Bloom <gedare at rtems.org> schrieb:
> On Fri, Nov 4, 2016 at 9:08 AM, Sebastian Huber
> <sebastian.huber at embedded-brains.de> wrote:
> > ---
> >  cpukit/score/include/rtems/score/percpu.h |  2 +-
> >  testsuites/tmtests/tm26/task1.c           | 12 +-----------
> >  testsuites/tmtests/tm27/task1.c           | 15 +++++++++++----
> >  3 files changed, 13 insertions(+), 16 deletions(-)
> >
> > diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h
> > index 066bf4c..1ccbc3b 100644
> > --- a/cpukit/score/include/rtems/score/percpu.h
> > +++ b/cpukit/score/include/rtems/score/percpu.h
> > @@ -688,7 +688,7 @@ bool _Per_CPU_State_wait_for_non_initial_state(
> >  #define _Thread_Heir \
> >    _Per_CPU_Get()->heir
> >  #define _Thread_Executing \
> > -  _Per_CPU_Get()->executing
> > +  _Per_CPU_Get_executing( _Per_CPU_Get() )
> >  #define _ISR_Nest_level \
> >    _Per_CPU_Get()->isr_nest_level
> >  #define _CPU_Interrupt_stack_low \
> > diff --git a/testsuites/tmtests/tm26/task1.c b/testsuites/tmtests/tm26/task1.c
> > index 173cf7f..9d157e9 100644
> > --- a/testsuites/tmtests/tm26/task1.c
> > +++ b/testsuites/tmtests/tm26/task1.c
> > @@ -123,17 +123,7 @@ static void set_thread_heir( Thread_Control *thread )
> >
> >  static void set_thread_executing( Thread_Control *thread )
> >  {
> > -#if defined( PREVENT_SMP_ASSERT_FAILURES )
> > -  ISR_Level level;
> > -
> > -  _ISR_Local_disable( level );
> > -#endif
> > -
> > -  _Thread_Executing = thread;
> > -
> > -#if defined( PREVENT_SMP_ASSERT_FAILURES )
> > -  _ISR_Local_enable( level );
> > -#endif
> > +  _Per_CPU_Get_snapshot()->executing = thread;
> Normally one thinks of a snapshot as a read-only kind of thing, like a
> picture. So I was a little confused by this terminology--for some
> reason I hadn't noticed this _Per_CPU_Get_snapshot() before now.

Its good that you didn't notice this before, since it should be rarely used:

/*
 * If we get the current processor index in a context which allows thread
 * dispatching, then we may already run on another processor right after the
 * read instruction.  There are very few cases in which this makes sense (here
 * we can use _Per_CPU_Get_snapshot()).  All other places must use
 * _Per_CPU_Get() so that we can add checks for RTEMS_DEBUG.
 */
#if defined( _CPU_Get_current_per_CPU_control )
  #define _Per_CPU_Get_snapshot() _CPU_Get_current_per_CPU_control()
#else
  #define _Per_CPU_Get_snapshot() \
    ( &_Per_CPU_Information[ _SMP_Get_current_processor() ].per_cpu )
#endif

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list