From bec47309011551f6b18fc6f4de2558cfaa6b796e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 30 Jun 2014 12:55:50 +0200 Subject: score: Add PER_CPU_OFFSET_EXECUTING Add PER_CPU_OFFSET_HEIR. Move Per_CPU_Control::executing and Per_CPU_Control::heir for easy offset calculation. --- cpukit/score/include/rtems/score/percpu.h | 38 +++++++++++++++++-------------- cpukit/score/src/percpuasm.c | 10 ++++++++ 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h index 30d61d519f..4be4de6974 100644 --- a/cpukit/score/include/rtems/score/percpu.h +++ b/cpukit/score/include/rtems/score/percpu.h @@ -270,22 +270,6 @@ typedef struct Per_CPU_Control { */ volatile uint32_t thread_dispatch_disable_level; - /** - * @brief This is set to true when this processor needs to run the - * dispatcher. - * - * It is volatile since interrupts may alter this flag. - * - * This field is not protected by a lock. There are two writers after - * multitasking start. The scheduler owning this processor sets this - * indicator to true, after it updated the heir field. This processor sets - * this indicator to false, before it reads the heir. This field is used in - * combination with the heir field. - * - * @see _Thread_Get_heir_and_make_it_executing(). - */ - volatile bool dispatch_necessary; - /** * @brief This is the thread executing on this processor. * @@ -312,6 +296,22 @@ typedef struct Per_CPU_Control { */ Thread_Control *heir; + /** + * @brief This is set to true when this processor needs to run the + * dispatcher. + * + * It is volatile since interrupts may alter this flag. + * + * This field is not protected by a lock. There are two writers after + * multitasking start. The scheduler owning this processor sets this + * indicator to true, after it updated the heir field. This processor sets + * this indicator to false, before it reads the heir. This field is used in + * combination with the heir field. + * + * @see _Thread_Get_heir_and_make_it_executing(). + */ + volatile bool dispatch_necessary; + /** This is the time of the last context switch on this CPU. */ Timestamp_Control time_of_last_context_switch; @@ -634,8 +634,12 @@ bool _Per_CPU_State_wait_for_non_initial_state( PER_CPU_END_STACK #define PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL \ PER_CPU_ISR_NEST_LEVEL + 4 -#define PER_CPU_DISPATCH_NEEDED \ +#define PER_CPU_OFFSET_EXECUTING \ PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL + 4 +#define PER_CPU_OFFSET_HEIR \ + PER_CPU_OFFSET_EXECUTING + CPU_SIZEOF_POINTER +#define PER_CPU_DISPATCH_NEEDED \ + PER_CPU_OFFSET_HEIR + CPU_SIZEOF_POINTER #define THREAD_DISPATCH_DISABLE_LEVEL \ (SYM(_Per_CPU_Information) + PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL) diff --git a/cpukit/score/src/percpuasm.c b/cpukit/score/src/percpuasm.c index d422a0deb6..15b49c72e1 100644 --- a/cpukit/score/src/percpuasm.c +++ b/cpukit/score/src/percpuasm.c @@ -87,6 +87,16 @@ RTEMS_STATIC_ASSERT( PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL ); +RTEMS_STATIC_ASSERT( + offsetof(Per_CPU_Control, executing) == PER_CPU_OFFSET_EXECUTING, + PER_CPU_OFFSET_EXECUTING +); + +RTEMS_STATIC_ASSERT( + offsetof(Per_CPU_Control, heir) == PER_CPU_OFFSET_HEIR, + PER_CPU_OFFSET_HEIR +); + RTEMS_STATIC_ASSERT( offsetof(Per_CPU_Control, dispatch_necessary) == PER_CPU_DISPATCH_NEEDED, PER_CPU_DISPATCH_NEEDED -- cgit v1.2.3