[rtems commit] score: Optimize SMP EDF move to ready operation

Sebastian Huber sebh at rtems.org
Tue Nov 23 13:34:54 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Oct 27 09:46:06 2021 +0200

score: Optimize SMP EDF move to ready operation

If a node is moved from the scheduled chain to the ready queue, then we
know that it is the highest priority ready node.  So, it can be
prepended to the ready queue without doing any comparisons.

Update #4531.

---

 cpukit/score/src/scheduleredfsmp.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/cpukit/score/src/scheduleredfsmp.c b/cpukit/score/src/scheduleredfsmp.c
index 7da777e..27be08a 100644
--- a/cpukit/score/src/scheduleredfsmp.c
+++ b/cpukit/score/src/scheduleredfsmp.c
@@ -374,15 +374,21 @@ static inline void _Scheduler_EDF_SMP_Move_from_scheduled_to_ready(
   Scheduler_Node    *scheduled_to_ready
 )
 {
-  Priority_Control insert_priority;
+  Scheduler_EDF_SMP_Context     *self;
+  Scheduler_EDF_SMP_Node        *node;
+  uint8_t                        rqi;
+  Scheduler_EDF_SMP_Ready_queue *ready_queue;
 
   _Scheduler_EDF_SMP_Extract_from_scheduled( context, scheduled_to_ready );
-  insert_priority = _Scheduler_SMP_Node_priority( scheduled_to_ready );
-  _Scheduler_EDF_SMP_Insert_ready(
-    context,
-    scheduled_to_ready,
-    insert_priority
-  );
+
+  self = _Scheduler_EDF_SMP_Get_self( context );
+  node = _Scheduler_EDF_SMP_Node_downcast( scheduled_to_ready );
+  rqi = node->ready_queue_index;
+  ready_queue = &self->Ready[ rqi ];
+
+  _Scheduler_EDF_SMP_Activate_ready_queue_if_necessary( self, rqi, ready_queue );
+  _RBTree_Initialize_node( &node->Base.Base.Node.RBTree );
+  _RBTree_Prepend( &ready_queue->Queue, &node->Base.Base.Node.RBTree );
 }
 
 static inline void _Scheduler_EDF_SMP_Move_from_ready_to_scheduled(



More information about the vc mailing list