[PATCH 11/27] score: Use extract from scheduled callbacks

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Nov 15 17:12:43 UTC 2021


Use the extract from scheduled callback provided by the scheduler
implementation in the SMP scheduler framework.

Update #4531.
---
 cpukit/include/rtems/score/schedulersmpimpl.h | 25 +++++++++++++++----
 cpukit/score/src/scheduleredfsmp.c            |  5 ++++
 .../score/src/schedulerpriorityaffinitysmp.c  |  3 +++
 cpukit/score/src/schedulerprioritysmp.c       |  4 +++
 cpukit/score/src/schedulersimplesmp.c         |  4 +++
 cpukit/score/src/schedulerstrongapa.c         |  5 ++++
 6 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/cpukit/include/rtems/score/schedulersmpimpl.h b/cpukit/include/rtems/score/schedulersmpimpl.h
index d7c08116b6..499cff5c6c 100644
--- a/cpukit/include/rtems/score/schedulersmpimpl.h
+++ b/cpukit/include/rtems/score/schedulersmpimpl.h
@@ -1328,6 +1328,8 @@ static inline void _Scheduler_SMP_Unblock(
  * @param context The scheduler instance context.
  * @param thread The thread for the operation.
  * @param[in, out] node The node to update the priority of.
+ * @param extract_from_scheduled Function to extract a node from the set of
+ *      scheduled nodes.
  * @param extract_from_ready Function to extract a node from the ready
  *      queue of the scheduler context.
  * @param update Function to update the priority of a node in the scheduler
@@ -1340,6 +1342,7 @@ static inline void _Scheduler_SMP_Update_priority(
   Scheduler_Context              *context,
   Thread_Control                 *thread,
   Scheduler_Node                 *node,
+  Scheduler_SMP_Extract           extract_from_scheduled,
   Scheduler_SMP_Extract           extract_from_ready,
   Scheduler_SMP_Update            update,
   Scheduler_SMP_Enqueue           enqueue,
@@ -1365,7 +1368,7 @@ static inline void _Scheduler_SMP_Update_priority(
   node_state = _Scheduler_SMP_Node_state( node );
 
   if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
-    _Scheduler_SMP_Extract_from_scheduled( context, node );
+    ( *extract_from_scheduled )( context, node );
     ( *update )( context, node, priority );
     ( *enqueue_scheduled )( context, node, insert_priority );
   } else if ( node_state == SCHEDULER_SMP_NODE_READY ) {
@@ -1387,6 +1390,8 @@ static inline void _Scheduler_SMP_Update_priority(
  * @param context The scheduler instance context.
  * @param thread The thread for the operation.
  * @param node The node of the thread that yields.
+ * @param extract_from_scheduled Function to extract a node from the set of
+ *      scheduled nodes.
  * @param extract_from_ready Function to extract a node from the ready
  *      queue of the scheduler context.
  * @param enqueue Function to enqueue a node with a given priority.
@@ -1396,6 +1401,7 @@ static inline void _Scheduler_SMP_Yield(
   Scheduler_Context              *context,
   Thread_Control                 *thread,
   Scheduler_Node                 *node,
+  Scheduler_SMP_Extract           extract_from_scheduled,
   Scheduler_SMP_Extract           extract_from_ready,
   Scheduler_SMP_Enqueue           enqueue,
   Scheduler_SMP_Enqueue_scheduled enqueue_scheduled
@@ -1410,7 +1416,7 @@ static inline void _Scheduler_SMP_Yield(
   insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority );
 
   if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
-    _Scheduler_SMP_Extract_from_scheduled( context, node );
+    ( *extract_from_scheduled )( context, node );
     ( *enqueue_scheduled )( context, node, insert_priority );
     needs_help = false;
   } else if ( node_state == SCHEDULER_SMP_NODE_READY ) {
@@ -1606,6 +1612,8 @@ static inline void _Scheduler_SMP_Reconsider_help_request(
  * @param[in, out] thread The thread to change to @a next_state.
  * @param[in, out] node The node to withdraw.
  * @param next_state The new state for @a thread.
+ * @param extract_from_scheduled Function to extract a node from the set of
+ *      scheduled nodes.
  * @param extract_from_ready Function to extract a node from the ready queue
  *      of the scheduler context.
  * @param get_highest_ready Function to get the highest ready node.
@@ -1619,6 +1627,7 @@ static inline void _Scheduler_SMP_Withdraw_node(
   Thread_Control                   *thread,
   Scheduler_Node                   *node,
   Thread_Scheduler_state            next_state,
+  Scheduler_SMP_Extract             extract_from_scheduled,
   Scheduler_SMP_Extract             extract_from_ready,
   Scheduler_SMP_Get_highest_ready   get_highest_ready,
   Scheduler_SMP_Move                move_from_ready_to_scheduled,
@@ -1640,7 +1649,7 @@ static inline void _Scheduler_SMP_Withdraw_node(
     _Scheduler_Thread_change_state( thread, next_state );
     _Thread_Scheduler_release_critical( thread, &lock_context );
 
-    _Scheduler_SMP_Extract_from_scheduled( context, node );
+    ( *extract_from_scheduled )( context, node );
     _Scheduler_SMP_Schedule_highest_ready(
       context,
       node,
@@ -1732,6 +1741,8 @@ static inline void _Scheduler_SMP_Add_processor(
  *
  * @param context The scheduler context instance.
  * @param cpu The processor to remove from.
+ * @param extract_from_scheduled Function to extract a node from the set of
+ *      scheduled nodes.
  * @param extract_from_ready Function to extract a node from the ready queue
  *      of the scheduler context.
  * @param enqueue Function to enqueue a node with a given priority.
@@ -1741,6 +1752,7 @@ static inline void _Scheduler_SMP_Add_processor(
 static inline Thread_Control *_Scheduler_SMP_Remove_processor(
   Scheduler_Context     *context,
   Per_CPU_Control       *cpu,
+  Scheduler_SMP_Extract  extract_from_scheduled,
   Scheduler_SMP_Extract  extract_from_ready,
   Scheduler_SMP_Enqueue  enqueue
 )
@@ -1762,7 +1774,7 @@ static inline Thread_Control *_Scheduler_SMP_Remove_processor(
     chain_node = _Chain_Next( chain_node );
   } while ( _Thread_Get_CPU( victim_user ) != cpu );
 
-  _Scheduler_SMP_Extract_from_scheduled( context, victim_node );
+  ( *extract_from_scheduled )( context, victim_node );
   victim_owner = _Scheduler_Node_get_owner( victim_node );
 
   if ( !victim_owner->is_idle ) {
@@ -1810,6 +1822,8 @@ static inline Thread_Control *_Scheduler_SMP_Remove_processor(
  * @param[in, out] node The node to set the affinity of.
  * @param arg The affinity for @a node.
  * @param set_affinity Function to set the affinity of a node.
+ * @param extract_from_scheduled Function to extract a node from the set of
+ *      scheduled nodes.
  * @param extract_from_ready Function to extract a node from the ready queue
  *      of the scheduler context.
  * @param get_highest_ready Function to get the highest ready node.
@@ -1825,6 +1839,7 @@ static inline void _Scheduler_SMP_Set_affinity(
   Scheduler_Node                  *node,
   void                            *arg,
   Scheduler_SMP_Set_affinity       set_affinity,
+  Scheduler_SMP_Extract            extract_from_scheduled,
   Scheduler_SMP_Extract            extract_from_ready,
   Scheduler_SMP_Get_highest_ready  get_highest_ready,
   Scheduler_SMP_Move               move_from_ready_to_scheduled,
@@ -1840,7 +1855,7 @@ static inline void _Scheduler_SMP_Set_affinity(
   insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority );
 
   if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) {
-    _Scheduler_SMP_Extract_from_scheduled( context, node );
+    ( *extract_from_scheduled )( context, node );
     _Scheduler_SMP_Preempt_and_schedule_highest_ready(
       context,
       node,
diff --git a/cpukit/score/src/scheduleredfsmp.c b/cpukit/score/src/scheduleredfsmp.c
index 8b0467e893..a915dbe511 100644
--- a/cpukit/score/src/scheduleredfsmp.c
+++ b/cpukit/score/src/scheduleredfsmp.c
@@ -529,6 +529,7 @@ void _Scheduler_EDF_SMP_Update_priority(
     context,
     thread,
     node,
+    _Scheduler_EDF_SMP_Extract_from_scheduled,
     _Scheduler_EDF_SMP_Extract_from_ready,
     _Scheduler_EDF_SMP_Do_update,
     _Scheduler_EDF_SMP_Enqueue,
@@ -578,6 +579,7 @@ void _Scheduler_EDF_SMP_Withdraw_node(
     the_thread,
     node,
     next_state,
+    _Scheduler_EDF_SMP_Extract_from_scheduled,
     _Scheduler_EDF_SMP_Extract_from_ready,
     _Scheduler_EDF_SMP_Get_highest_ready,
     _Scheduler_EDF_SMP_Move_from_ready_to_scheduled,
@@ -625,6 +627,7 @@ Thread_Control *_Scheduler_EDF_SMP_Remove_processor(
   return _Scheduler_SMP_Remove_processor(
     context,
     cpu,
+    _Scheduler_EDF_SMP_Extract_from_scheduled,
     _Scheduler_EDF_SMP_Extract_from_ready,
     _Scheduler_EDF_SMP_Enqueue
   );
@@ -642,6 +645,7 @@ void _Scheduler_EDF_SMP_Yield(
     context,
     thread,
     node,
+    _Scheduler_EDF_SMP_Extract_from_scheduled,
     _Scheduler_EDF_SMP_Extract_from_ready,
     _Scheduler_EDF_SMP_Enqueue,
     _Scheduler_EDF_SMP_Enqueue_scheduled
@@ -758,6 +762,7 @@ Status_Control _Scheduler_EDF_SMP_Set_affinity(
       node_base,
       &rqi,
       _Scheduler_EDF_SMP_Do_set_affinity,
+      _Scheduler_EDF_SMP_Extract_from_scheduled,
       _Scheduler_EDF_SMP_Extract_from_ready,
       _Scheduler_EDF_SMP_Get_highest_ready,
       _Scheduler_EDF_SMP_Move_from_ready_to_scheduled,
diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c
index b328fae590..4bbf2f6e17 100644
--- a/cpukit/score/src/schedulerpriorityaffinitysmp.c
+++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c
@@ -449,6 +449,7 @@ void _Scheduler_priority_affinity_SMP_Update_priority(
     context,
     thread,
     node,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_priority_SMP_Extract_from_ready,
     _Scheduler_priority_SMP_Do_update,
     _Scheduler_priority_affinity_SMP_Enqueue,
@@ -503,6 +504,7 @@ void _Scheduler_priority_affinity_SMP_Withdraw_node(
     the_thread,
     node,
     next_state,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_priority_SMP_Extract_from_ready,
     _Scheduler_priority_affinity_SMP_Get_highest_ready,
     _Scheduler_priority_SMP_Move_from_ready_to_scheduled,
@@ -536,6 +538,7 @@ Thread_Control *_Scheduler_priority_affinity_SMP_Remove_processor(
   return _Scheduler_SMP_Remove_processor(
     context,
     cpu,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_priority_SMP_Extract_from_ready,
     _Scheduler_priority_affinity_SMP_Enqueue
   );
diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c
index 99eb52bf86..b0b920c960 100644
--- a/cpukit/score/src/schedulerprioritysmp.c
+++ b/cpukit/score/src/schedulerprioritysmp.c
@@ -207,6 +207,7 @@ void _Scheduler_priority_SMP_Update_priority(
     context,
     thread,
     node,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_priority_SMP_Extract_from_ready,
     _Scheduler_priority_SMP_Do_update,
     _Scheduler_priority_SMP_Enqueue,
@@ -256,6 +257,7 @@ void _Scheduler_priority_SMP_Withdraw_node(
     the_thread,
     node,
     next_state,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_priority_SMP_Extract_from_ready,
     _Scheduler_priority_SMP_Get_highest_ready,
     _Scheduler_priority_SMP_Move_from_ready_to_scheduled,
@@ -289,6 +291,7 @@ Thread_Control *_Scheduler_priority_SMP_Remove_processor(
   return _Scheduler_SMP_Remove_processor(
     context,
     cpu,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_priority_SMP_Extract_from_ready,
     _Scheduler_priority_SMP_Enqueue
   );
@@ -306,6 +309,7 @@ void _Scheduler_priority_SMP_Yield(
     context,
     thread,
     node,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_priority_SMP_Extract_from_ready,
     _Scheduler_priority_SMP_Enqueue,
     _Scheduler_priority_SMP_Enqueue_scheduled
diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c
index efc71dce84..02e4579aa1 100644
--- a/cpukit/score/src/schedulersimplesmp.c
+++ b/cpukit/score/src/schedulersimplesmp.c
@@ -277,6 +277,7 @@ void _Scheduler_simple_SMP_Update_priority(
     context,
     thread,
     node,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_simple_SMP_Extract_from_ready,
     _Scheduler_simple_SMP_Do_update,
     _Scheduler_simple_SMP_Enqueue,
@@ -326,6 +327,7 @@ void _Scheduler_simple_SMP_Withdraw_node(
     the_thread,
     node,
     next_state,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_simple_SMP_Extract_from_ready,
     _Scheduler_simple_SMP_Get_highest_ready,
     _Scheduler_simple_SMP_Move_from_ready_to_scheduled,
@@ -359,6 +361,7 @@ Thread_Control *_Scheduler_simple_SMP_Remove_processor(
   return _Scheduler_SMP_Remove_processor(
     context,
     cpu,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_simple_SMP_Extract_from_ready,
     _Scheduler_simple_SMP_Enqueue
   );
@@ -376,6 +379,7 @@ void _Scheduler_simple_SMP_Yield(
     context,
     thread,
     node,
+    _Scheduler_SMP_Extract_from_scheduled,
     _Scheduler_simple_SMP_Extract_from_ready,
     _Scheduler_simple_SMP_Enqueue,
     _Scheduler_simple_SMP_Enqueue_scheduled
diff --git a/cpukit/score/src/schedulerstrongapa.c b/cpukit/score/src/schedulerstrongapa.c
index 6643005288..afd9fcc709 100644
--- a/cpukit/score/src/schedulerstrongapa.c
+++ b/cpukit/score/src/schedulerstrongapa.c
@@ -809,6 +809,7 @@ void _Scheduler_strong_APA_Yield(
     context,
     thread,
     node,
+    _Scheduler_strong_APA_Extract_from_scheduled,
     _Scheduler_strong_APA_Extract_from_ready,
     _Scheduler_strong_APA_Enqueue,
     _Scheduler_strong_APA_Enqueue_scheduled
@@ -872,6 +873,7 @@ void _Scheduler_strong_APA_Update_priority(
     context,
     thread,
     node,
+    _Scheduler_strong_APA_Extract_from_scheduled,
     _Scheduler_strong_APA_Extract_from_ready,
     _Scheduler_strong_APA_Do_update,
     _Scheduler_strong_APA_Enqueue,
@@ -925,6 +927,7 @@ void _Scheduler_strong_APA_Withdraw_node(
     the_thread,
     node,
     next_state,
+    _Scheduler_strong_APA_Extract_from_scheduled,
     _Scheduler_strong_APA_Extract_from_ready,
     _Scheduler_strong_APA_Get_highest_ready,
     _Scheduler_strong_APA_Move_from_ready_to_scheduled,
@@ -988,6 +991,7 @@ Thread_Control *_Scheduler_strong_APA_Remove_processor(
   return _Scheduler_SMP_Remove_processor(
     context,
     cpu,
+    _Scheduler_strong_APA_Extract_from_scheduled,
     _Scheduler_strong_APA_Extract_from_ready,
     _Scheduler_strong_APA_Enqueue
   );
@@ -1045,6 +1049,7 @@ Status_Control _Scheduler_strong_APA_Set_affinity(
    node_base,
    &local_affinity,
    _Scheduler_strong_APA_Do_set_affinity,
+   _Scheduler_strong_APA_Extract_from_scheduled,
    _Scheduler_strong_APA_Extract_from_ready,
    _Scheduler_strong_APA_Get_highest_ready,
    _Scheduler_strong_APA_Move_from_ready_to_scheduled,
-- 
2.26.2



More information about the devel mailing list