[rtems commit] score: Add PER_CPU_OFFSET_EXECUTING

Sebastian Huber sebh at rtems.org
Tue Jul 1 14:56:00 UTC 2014


Module:    rtems
Branch:    master
Commit:    bec47309011551f6b18fc6f4de2558cfaa6b796e
Changeset: http://git.rtems.org/rtems/commit/?id=bec47309011551f6b18fc6f4de2558cfaa6b796e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jun 30 12:55:50 2014 +0200

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 30d61d5..4be4de6 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -271,22 +271,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.
    *
    * This field is not protected by a lock.  The only writer is 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 d422a0d..15b49c7 100644
--- a/cpukit/score/src/percpuasm.c
+++ b/cpukit/score/src/percpuasm.c
@@ -88,6 +88,16 @@ RTEMS_STATIC_ASSERT(
 );
 
 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
 );



More information about the vc mailing list