[rtems commit] score: Manage scheduler nodes via thread queues

Sebastian Huber sebh at rtems.org
Wed Sep 21 07:06:04 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Sep  8 14:07:12 2016 +0200

score: Manage scheduler nodes via thread queues

Update #2556.

---

 cpukit/score/include/rtems/score/schedulerimpl.h     |  7 +++++++
 cpukit/score/include/rtems/score/schedulernode.h     | 12 ++++++++++++
 cpukit/score/include/rtems/score/schedulernodeimpl.h |  1 +
 cpukit/score/include/rtems/score/thread.h            |  8 ++++++++
 cpukit/score/src/threadinitialize.c                  |  5 +++++
 5 files changed, 33 insertions(+)

diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index 2fdc01a..7ac8964 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -1423,6 +1423,13 @@ RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set(
   );
 
 #if defined(RTEMS_SMP)
+  _Chain_Extract_unprotected( &old_scheduler_node->Thread.Wait_node );
+  _Assert( _Chain_Is_empty( &the_thread->Scheduler.Wait_nodes ) );
+  _Chain_Initialize_one(
+    &the_thread->Scheduler.Wait_nodes,
+    &new_scheduler_node->Thread.Wait_node
+  );
+
   {
     const Scheduler_Control *old_scheduler;
 
diff --git a/cpukit/score/include/rtems/score/schedulernode.h b/cpukit/score/include/rtems/score/schedulernode.h
index 2954db5..8d00a43 100644
--- a/cpukit/score/include/rtems/score/schedulernode.h
+++ b/cpukit/score/include/rtems/score/schedulernode.h
@@ -138,6 +138,18 @@ typedef struct Scheduler_Node {
    * not SCHEDULER_HELP_YOURSELF.
    */
   struct _Thread_Control *accepts_help;
+
+  /**
+   * @brief Block to register and manage this scheduler node in the thread
+   * control block of the owner of this scheduler node.
+   */
+  struct {
+    /**
+     * @brief Node to add this scheduler node to
+     * Thread_Control::Scheduler::Wait_nodes.
+     */
+    Chain_Node Wait_node;
+  } Thread;
 #endif
 
   /**
diff --git a/cpukit/score/include/rtems/score/schedulernodeimpl.h b/cpukit/score/include/rtems/score/schedulernodeimpl.h
index b0f7d77..cf096aa 100644
--- a/cpukit/score/include/rtems/score/schedulernodeimpl.h
+++ b/cpukit/score/include/rtems/score/schedulernodeimpl.h
@@ -42,6 +42,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize(
   node->Priority.prepend_it = false;
 
 #if defined(RTEMS_SMP)
+  _Chain_Initialize_node( &node->Thread.Wait_node );
   node->Wait.Priority.scheduler = scheduler;
   node->user = the_thread;
   node->help_state = SCHEDULER_HELP_YOURSELF;
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 17aeacd..a86d81b 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -287,6 +287,14 @@ typedef struct {
    * @brief The processor assigned by the current scheduler.
    */
   struct Per_CPU_Control *cpu;
+
+  /**
+   * @brief Scheduler nodes immediately available to the thread by its home
+   * scheduler instance and due to thread queue ownerships.
+   *
+   * This chain is protected by the thread wait lock.
+   */
+  Chain_Control Wait_nodes;
 #endif
 
   /**
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 590d7be..84d2627 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -205,6 +205,11 @@ bool _Thread_Initialize(
     ++scheduler_for_index;
     ++scheduler_index;
   }
+
+  _Chain_Initialize_one(
+    &the_thread->Scheduler.Wait_nodes,
+    &scheduler_node->Thread.Wait_node
+  );
 #else
   scheduler_node = _Thread_Scheduler_get_own_node( the_thread );
   _Scheduler_Node_initialize(




More information about the vc mailing list