[rtems commit] score: Change scheduler node init and destroy

Sebastian Huber sebh at rtems.org
Fri Jul 1 13:17:42 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jul  1 14:47:07 2016 +0200

score: Change scheduler node init and destroy

Provide the scheduler node to initialize or destroy to the corresponding
operations.  This makes it possible to have more than one scheduler node
per thread.

---

 cpukit/score/include/rtems/score/scheduler.h         |  9 ++++++---
 cpukit/score/include/rtems/score/schedulercbs.h      |  1 +
 cpukit/score/include/rtems/score/schedulercbsimpl.h  |  7 +++++++
 cpukit/score/include/rtems/score/scheduleredf.h      |  4 +++-
 cpukit/score/include/rtems/score/scheduleredfimpl.h  |  7 +++++++
 cpukit/score/include/rtems/score/schedulerimpl.h     | 20 ++++++++++++++------
 cpukit/score/include/rtems/score/schedulerpriority.h |  1 +
 .../rtems/score/schedulerpriorityaffinitysmp.h       |  4 +++-
 .../include/rtems/score/schedulerpriorityimpl.h      |  7 +++++++
 .../score/include/rtems/score/schedulerprioritysmp.h |  1 +
 .../score/include/rtems/score/schedulersimplesmp.h   |  1 +
 .../score/include/rtems/score/schedulerstrongapa.h   |  1 +
 cpukit/score/src/schedulercbsnodeinit.c              |  9 +++++----
 cpukit/score/src/schedulerdefaultnodedestroy.c       |  4 ++--
 cpukit/score/src/schedulerdefaultnodeinit.c          |  3 +--
 cpukit/score/src/scheduleredfnodeinit.c              |  8 +++++---
 cpukit/score/src/schedulerpriority.c                 | 11 ++++++-----
 cpukit/score/src/schedulerpriorityaffinitysmp.c      | 20 ++++++--------------
 cpukit/score/src/schedulerprioritysmp.c              | 13 ++++++-------
 cpukit/score/src/schedulersimplesmp.c                | 13 ++++++++-----
 cpukit/score/src/schedulerstrongapa.c                | 13 ++++++-------
 cpukit/score/src/threadinitialize.c                  |  9 ++++++---
 cpukit/score/src/threadrestart.c                     |  5 ++++-
 23 files changed, 107 insertions(+), 64 deletions(-)

diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h
index 9f31d7a..120fdfd 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -130,12 +130,13 @@ typedef struct {
   /** @see _Scheduler_Node_initialize() */
   void ( *node_initialize )(
     const Scheduler_Control *,
+    Scheduler_Node *,
     Thread_Control *,
     Priority_Control
   );
 
   /** @see _Scheduler_Node_destroy() */
-  void ( *node_destroy )( const Scheduler_Control *, Thread_Control * );
+  void ( *node_destroy )( const Scheduler_Control *, Scheduler_Node * );
 
   /** @see _Scheduler_Release_job() */
   void ( *release_job ) (
@@ -498,11 +499,13 @@ void _Scheduler_default_Schedule(
  * @brief Performs the scheduler base node initialization.
  *
  * @param[in] scheduler Unused.
+ * @param[in] node The node to initialize.
  * @param[in] the_thread Unused.
  * @param[in] priority The thread priority.
  */
 void _Scheduler_default_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 );
@@ -511,11 +514,11 @@ void _Scheduler_default_Node_initialize(
  * @brief Does nothing.
  *
  * @param[in] scheduler Unused.
- * @param[in] the_thread Unused.
+ * @param[in] node Unused.
  */
 void _Scheduler_default_Node_destroy(
   const Scheduler_Control *scheduler,
-  Thread_Control          *the_thread
+  Scheduler_Node          *node
 );
 
 /**
diff --git a/cpukit/score/include/rtems/score/schedulercbs.h b/cpukit/score/include/rtems/score/schedulercbs.h
index 91e69d0..a46314c 100644
--- a/cpukit/score/include/rtems/score/schedulercbs.h
+++ b/cpukit/score/include/rtems/score/schedulercbs.h
@@ -345,6 +345,7 @@ void _Scheduler_CBS_Budget_callout(
  */
 void _Scheduler_CBS_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 );
diff --git a/cpukit/score/include/rtems/score/schedulercbsimpl.h b/cpukit/score/include/rtems/score/schedulercbsimpl.h
index ddc79fe..84f6b5d 100644
--- a/cpukit/score/include/rtems/score/schedulercbsimpl.h
+++ b/cpukit/score/include/rtems/score/schedulercbsimpl.h
@@ -43,6 +43,13 @@ RTEMS_INLINE_ROUTINE Scheduler_CBS_Node *_Scheduler_CBS_Thread_get_node(
   return (Scheduler_CBS_Node *) _Scheduler_Thread_get_node( the_thread );
 }
 
+RTEMS_INLINE_ROUTINE Scheduler_CBS_Node *_Scheduler_CBS_Node_downcast(
+  Scheduler_Node *node
+)
+{
+  return (Scheduler_CBS_Node *) node;
+}
+
 /** @} */
 
 #ifdef __cplusplus
diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h
index 66bc17e..de06344 100644
--- a/cpukit/score/include/rtems/score/scheduleredf.h
+++ b/cpukit/score/include/rtems/score/scheduleredf.h
@@ -152,11 +152,13 @@ void _Scheduler_EDF_Schedule(
  *  @brief Initializes an EDF specific scheduler node of @a the_thread.
  *
  *  @param[in] scheduler The scheduler instance.
- *  @param[in] the_thread being initialized.
+ *  @param[in] node being initialized.
+ *  @param[in] the_thread the thread of the node.
  *  @param[in] priority The thread priority.
  */
 void _Scheduler_EDF_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 );
diff --git a/cpukit/score/include/rtems/score/scheduleredfimpl.h b/cpukit/score/include/rtems/score/scheduleredfimpl.h
index 204660e..844d745 100644
--- a/cpukit/score/include/rtems/score/scheduleredfimpl.h
+++ b/cpukit/score/include/rtems/score/scheduleredfimpl.h
@@ -53,6 +53,13 @@ RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node(
   return (Scheduler_EDF_Node *) _Scheduler_Thread_get_node( the_thread );
 }
 
+RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast(
+  Scheduler_Node *node
+)
+{
+  return (Scheduler_EDF_Node *) node;
+}
+
 RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less(
   const void        *left,
   const RBTree_Node *right
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index 2007b30..db4be99 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -455,17 +455,20 @@ RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Unmap_priority(
  * destroyed.
  *
  * @param[in] scheduler The scheduler instance.
- * @param[in] the_thread The thread containing the scheduler node.
+ * @param[in] node The scheduler node to initialize.
+ * @param[in] the_thread The thread of the scheduler node to initialize.
  * @param[in] priority The thread priority.
  */
 RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 )
 {
   ( *scheduler->Operations.node_initialize )(
     scheduler,
+    node,
     the_thread,
     priority
   );
@@ -478,14 +481,14 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize(
  * after a corresponding _Scheduler_Node_initialize().
  *
  * @param[in] scheduler The scheduler instance.
- * @param[in] the_thread The thread containing the scheduler node.
+ * @param[in] node The scheduler node to destroy.
  */
 RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy(
   const Scheduler_Control *scheduler,
-  Thread_Control          *the_thread
+  Scheduler_Node          *node
 )
 {
-  ( *scheduler->Operations.node_destroy )( scheduler, the_thread );
+  ( *scheduler->Operations.node_destroy )( scheduler, node );
 }
 
 /**
@@ -1464,10 +1467,15 @@ RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set(
         _Scheduler_Block( the_thread );
       }
 
-      _Scheduler_Node_destroy( old_scheduler, the_thread );
+      _Scheduler_Node_destroy( old_scheduler, own_node );
       the_thread->Scheduler.own_control = new_scheduler;
       the_thread->Scheduler.control = new_scheduler;
-      _Scheduler_Node_initialize( new_scheduler, the_thread, priority );
+      _Scheduler_Node_initialize(
+        new_scheduler,
+        own_node,
+        the_thread,
+        priority
+      );
 
       if ( _States_Is_ready( current_state ) ) {
         _Scheduler_Unblock( the_thread );
diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h
index f2e0459..9501e3d 100644
--- a/cpukit/score/include/rtems/score/schedulerpriority.h
+++ b/cpukit/score/include/rtems/score/schedulerpriority.h
@@ -159,6 +159,7 @@ Scheduler_Void_or_thread _Scheduler_priority_Update_priority(
 
 void _Scheduler_priority_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 );
diff --git a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h
index 2c9b496..763523a 100644
--- a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h
+++ b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h
@@ -73,12 +73,14 @@ extern "C" {
  *  This routine allocates @a thread->scheduler.
  *
  *  @param[in] scheduler points to the scheduler specific information.
- *  @param[in] thread is the thread the scheduler is allocating
+ *  @param[in] node is the node the scheduler is allocating
  *             management memory for.
+ *  @param[in] the_thread the thread of the node.
  *  @param[in] priority is the thread priority.
  */
 void _Scheduler_priority_affinity_SMP_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 );
diff --git a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
index d03c8d3..e33866e 100644
--- a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
@@ -48,6 +48,13 @@ RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Thread_get_nod
   return (Scheduler_priority_Node *) _Scheduler_Thread_get_node( the_thread );
 }
 
+RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Node_downcast(
+  Scheduler_Node *node
+)
+{
+  return (Scheduler_priority_Node *) node;
+}
+
 /**
  * @brief Ready queue initialization.
  *
diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmp.h b/cpukit/score/include/rtems/score/schedulerprioritysmp.h
index 051e44f..97370ac 100644
--- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h
+++ b/cpukit/score/include/rtems/score/schedulerprioritysmp.h
@@ -99,6 +99,7 @@ void _Scheduler_priority_SMP_Initialize( const Scheduler_Control *scheduler );
 
 void _Scheduler_priority_SMP_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 );
diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h
index 0a05546..bbcdbdb 100644
--- a/cpukit/score/include/rtems/score/schedulersimplesmp.h
+++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h
@@ -82,6 +82,7 @@ void _Scheduler_simple_SMP_Initialize( const Scheduler_Control *scheduler );
 
 void _Scheduler_simple_SMP_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 );
diff --git a/cpukit/score/include/rtems/score/schedulerstrongapa.h b/cpukit/score/include/rtems/score/schedulerstrongapa.h
index e2a33af..8390c2d 100644
--- a/cpukit/score/include/rtems/score/schedulerstrongapa.h
+++ b/cpukit/score/include/rtems/score/schedulerstrongapa.h
@@ -99,6 +99,7 @@ void _Scheduler_strong_APA_Initialize( const Scheduler_Control *scheduler );
 
 void _Scheduler_strong_APA_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 );
diff --git a/cpukit/score/src/schedulercbsnodeinit.c b/cpukit/score/src/schedulercbsnodeinit.c
index 3aa825b..5380069 100644
--- a/cpukit/score/src/schedulercbsnodeinit.c
+++ b/cpukit/score/src/schedulercbsnodeinit.c
@@ -22,14 +22,15 @@
 
 void _Scheduler_CBS_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 )
 {
-  Scheduler_CBS_Node *node;
+  Scheduler_CBS_Node *the_node;
 
-  _Scheduler_EDF_Node_initialize( scheduler, the_thread, priority );
+  _Scheduler_EDF_Node_initialize( scheduler, node, the_thread, priority );
 
-  node = _Scheduler_CBS_Thread_get_node( the_thread );
-  node->cbs_server = NULL;
+  the_node = _Scheduler_CBS_Node_downcast( node );
+  the_node->cbs_server = NULL;
 }
diff --git a/cpukit/score/src/schedulerdefaultnodedestroy.c b/cpukit/score/src/schedulerdefaultnodedestroy.c
index d1d84f3..537c824 100644
--- a/cpukit/score/src/schedulerdefaultnodedestroy.c
+++ b/cpukit/score/src/schedulerdefaultnodedestroy.c
@@ -23,9 +23,9 @@
 
 void _Scheduler_default_Node_destroy(
   const Scheduler_Control *scheduler,
-  Thread_Control          *the_thread
+  Scheduler_Node          *node
 )
 {
   (void) scheduler;
-  (void) the_thread;
+  (void) node;
 }
diff --git a/cpukit/score/src/schedulerdefaultnodeinit.c b/cpukit/score/src/schedulerdefaultnodeinit.c
index de2b6c8..10e71f8 100644
--- a/cpukit/score/src/schedulerdefaultnodeinit.c
+++ b/cpukit/score/src/schedulerdefaultnodeinit.c
@@ -23,12 +23,11 @@
 
 void _Scheduler_default_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 )
 {
-  Scheduler_Node *node = _Scheduler_Thread_get_own_node( the_thread );
-
   (void) scheduler;
 
   _Scheduler_Node_do_initialize( node, the_thread, priority );
diff --git a/cpukit/score/src/scheduleredfnodeinit.c b/cpukit/score/src/scheduleredfnodeinit.c
index 6005fa0..bde25c1 100644
--- a/cpukit/score/src/scheduleredfnodeinit.c
+++ b/cpukit/score/src/scheduleredfnodeinit.c
@@ -22,15 +22,17 @@
 
 void _Scheduler_EDF_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 )
 {
-  Scheduler_EDF_Node *node = _Scheduler_EDF_Thread_get_node( the_thread );
+  Scheduler_EDF_Node *the_node;
 
   (void) scheduler;
 
-  _Scheduler_Node_do_initialize( &node->Base, the_thread, priority );
+  _Scheduler_Node_do_initialize( node, the_thread, priority );
 
-  node->thread = the_thread;
+  the_node = _Scheduler_EDF_Node_downcast( node );
+  the_node->thread = the_thread;
 }
diff --git a/cpukit/score/src/schedulerpriority.c b/cpukit/score/src/schedulerpriority.c
index 2719697..11cee92 100644
--- a/cpukit/score/src/schedulerpriority.c
+++ b/cpukit/score/src/schedulerpriority.c
@@ -35,19 +35,20 @@ void _Scheduler_priority_Initialize( const Scheduler_Control *scheduler )
 
 void _Scheduler_priority_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 )
 {
   Scheduler_priority_Context *context;
-  Scheduler_priority_Node    *node;
+  Scheduler_priority_Node    *the_node;
 
-  context = _Scheduler_priority_Get_context( scheduler );
-  node = _Scheduler_priority_Thread_get_node( the_thread );
+  _Scheduler_Node_do_initialize( node, the_thread, priority );
 
-  _Scheduler_Node_do_initialize( &node->Base, the_thread, priority );
+  context = _Scheduler_priority_Get_context( scheduler );
+  the_node = _Scheduler_priority_Node_downcast( node );
   _Scheduler_priority_Ready_queue_update(
-    &node->Ready_queue,
+    &the_node->Ready_queue,
     priority,
     &context->Bit_map,
     &context->Ready[ 0 ]
diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c
index cec0972..e171d5e 100644
--- a/cpukit/score/src/schedulerpriorityaffinitysmp.c
+++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c
@@ -60,15 +60,6 @@ static bool _Scheduler_priority_affinity_SMP_Insert_priority_fifo_order(
     && _Scheduler_SMP_Insert_priority_fifo_order( to_insert, next );
 }
 
-static Scheduler_priority_affinity_SMP_Node *
-_Scheduler_priority_affinity_SMP_Thread_get_own_node(
-  Thread_Control *thread
-)
-{
-  return (Scheduler_priority_affinity_SMP_Node *)
-    _Scheduler_Thread_get_own_node( thread );
-}
-
 /*
  * This method returns the scheduler node for the specified thread
  * as a scheduler specific type.
@@ -96,20 +87,21 @@ _Scheduler_priority_affinity_SMP_Node_downcast(
  */
 void _Scheduler_priority_affinity_SMP_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 )
 {
-  Scheduler_priority_affinity_SMP_Node *node =
-    _Scheduler_priority_affinity_SMP_Thread_get_own_node( the_thread );
+  Scheduler_priority_affinity_SMP_Node *the_node;
 
-  _Scheduler_priority_SMP_Node_initialize( scheduler, the_thread, priority );
+  _Scheduler_priority_SMP_Node_initialize( scheduler, node, the_thread, priority );
 
   /*
    *  All we add is affinity information to the basic SMP node.
    */
-  node->Affinity     = *_CPU_set_Default();
-  node->Affinity.set = &node->Affinity.preallocated;
+  the_node = _Scheduler_priority_affinity_SMP_Node_downcast( node );
+  the_node->Affinity     = *_CPU_set_Default();
+  the_node->Affinity.set = &the_node->Affinity.preallocated;
 }
 
 /*
diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c
index aba863e..07e7af4 100644
--- a/cpukit/score/src/schedulerprioritysmp.c
+++ b/cpukit/score/src/schedulerprioritysmp.c
@@ -47,23 +47,22 @@ void _Scheduler_priority_SMP_Initialize( const Scheduler_Control *scheduler )
 
 void _Scheduler_priority_SMP_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 )
 {
   Scheduler_Context              *context;
   Scheduler_priority_SMP_Context *self;
-  Scheduler_priority_SMP_Node    *node;
+  Scheduler_priority_SMP_Node    *the_node;
+
+  the_node = _Scheduler_priority_SMP_Node_downcast( node );
+  _Scheduler_SMP_Node_initialize( &the_node->Base, the_thread, priority );
 
   context = _Scheduler_Get_context( scheduler );
   self = _Scheduler_priority_SMP_Get_self( context );
-  node = _Scheduler_priority_SMP_Node_downcast(
-    _Scheduler_Thread_get_own_node( the_thread )
-  );
-
-  _Scheduler_SMP_Node_initialize( &node->Base, the_thread, priority );
   _Scheduler_priority_Ready_queue_update(
-    &node->Ready_queue,
+    &the_node->Ready_queue,
     priority,
     &self->Bit_map,
     &self->Ready[ 0 ]
diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c
index f368ead..8f86ea8 100644
--- a/cpukit/score/src/schedulersimplesmp.c
+++ b/cpukit/score/src/schedulersimplesmp.c
@@ -44,26 +44,29 @@ void _Scheduler_simple_SMP_Initialize( const Scheduler_Control *scheduler )
 
 void _Scheduler_simple_SMP_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 )
 {
-  Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_own_node( the_thread );
+  Scheduler_SMP_Node *the_node;
 
-  _Scheduler_SMP_Node_initialize( node, the_thread, priority );
+  the_node = _Scheduler_SMP_Node_downcast( node );
+  _Scheduler_SMP_Node_initialize( the_node, the_thread, priority );
 }
 
 static void _Scheduler_simple_SMP_Do_update(
   Scheduler_Context *context,
-  Scheduler_Node    *node_to_update,
+  Scheduler_Node    *node,
   Priority_Control   new_priority
 )
 {
-  Scheduler_SMP_Node *node = _Scheduler_SMP_Node_downcast( node_to_update );
+  Scheduler_SMP_Node *the_node;
 
   (void) context;
 
-  _Scheduler_SMP_Node_update_priority( node, new_priority );
+  the_node = _Scheduler_SMP_Node_downcast( node );
+  _Scheduler_SMP_Node_update_priority( the_node, new_priority );
 }
 
 static Scheduler_Node *_Scheduler_simple_SMP_Get_highest_ready(
diff --git a/cpukit/score/src/schedulerstrongapa.c b/cpukit/score/src/schedulerstrongapa.c
index 14c238e..5d7c7f7 100644
--- a/cpukit/score/src/schedulerstrongapa.c
+++ b/cpukit/score/src/schedulerstrongapa.c
@@ -173,23 +173,22 @@ void _Scheduler_strong_APA_Initialize( const Scheduler_Control *scheduler )
 
 void _Scheduler_strong_APA_Node_initialize(
   const Scheduler_Control *scheduler,
+  Scheduler_Node          *node,
   Thread_Control          *the_thread,
   Priority_Control         priority
 )
 {
   Scheduler_Context            *context;
   Scheduler_strong_APA_Context *self;
-  Scheduler_strong_APA_Node    *node;
+  Scheduler_strong_APA_Node    *the_node;
+
+  the_node = _Scheduler_strong_APA_Node_downcast( node );
+  _Scheduler_SMP_Node_initialize( &the_node->Base, the_thread, priority );
 
   context = _Scheduler_Get_context( scheduler );
   self = _Scheduler_strong_APA_Get_self( context );
-  node = _Scheduler_strong_APA_Node_downcast(
-    _Scheduler_Thread_get_own_node( the_thread )
-  );
-
-  _Scheduler_SMP_Node_initialize( &node->Base, the_thread, priority );
   _Scheduler_priority_Ready_queue_update(
-    &node->Ready_queue,
+    &the_node->Ready_queue,
     priority,
     &self->Bit_map,
     &self->Ready[ 0 ]
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 7237cfe..940537f 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -52,6 +52,7 @@ bool _Thread_Initialize(
   #endif
   bool                     extension_status;
   size_t                   i;
+  Scheduler_Node          *scheduler_node;
   bool                     scheduler_node_initialized = false;
   Per_CPU_Control         *cpu = _Per_CPU_Get_by_index( 0 );
 
@@ -173,11 +174,13 @@ bool _Thread_Initialize(
     #endif
   }
 
+  scheduler_node = the_thread->Scheduler.node;
+
 #if defined(RTEMS_SMP)
   RTEMS_STATIC_ASSERT( THREAD_SCHEDULER_BLOCKED == 0, Scheduler_state );
   the_thread->Scheduler.own_control = scheduler;
   the_thread->Scheduler.control = scheduler;
-  the_thread->Scheduler.own_node = the_thread->Scheduler.node;
+  the_thread->Scheduler.own_node = scheduler_node;
   _Resource_Node_initialize( &the_thread->Resource_node );
   _Atomic_Store_uintptr(
     &the_thread->Lock.current.atomic,
@@ -204,7 +207,7 @@ bool _Thread_Initialize(
 
   RTEMS_STATIC_ASSERT( THREAD_WAIT_FLAGS_INITIAL == 0, Wait_flags );
 
-  _Scheduler_Node_initialize( scheduler, the_thread, priority );
+  _Scheduler_Node_initialize( scheduler, scheduler_node, the_thread, priority );
   scheduler_node_initialized = true;
 
   /* POSIX Keys */
@@ -232,7 +235,7 @@ bool _Thread_Initialize(
 failed:
 
   if ( scheduler_node_initialized ) {
-    _Scheduler_Node_destroy( scheduler, the_thread );
+    _Scheduler_Node_destroy( scheduler, scheduler_node );
   }
 
   _Workspace_Free( the_thread->Start.tls_area );
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 32ecfba..b43c019 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -183,7 +183,10 @@ static void _Thread_Free( Thread_Control *the_thread )
   _User_extensions_Thread_delete( the_thread );
   _User_extensions_Destroy_iterators( the_thread );
   _ISR_lock_Destroy( &the_thread->Keys.Lock );
-  _Scheduler_Node_destroy( _Scheduler_Get( the_thread ), the_thread );
+  _Scheduler_Node_destroy(
+    _Scheduler_Get( the_thread ),
+    _Scheduler_Thread_get_own_node( the_thread )
+  );
   _ISR_lock_Destroy( &the_thread->Timer.Lock );
 
   /*




More information about the vc mailing list