[rtems commit] score: Move _Scheduler_Unblock_node()

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


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Oct 29 13:44:04 2021 +0200

score: Move _Scheduler_Unblock_node()

Move _Scheduler_Unblock_node() into _Scheduler_SMP_Unblock().  This simplifies
the code and makes it easier to review.

Update #4531.

---

 cpukit/include/rtems/score/schedulerimpl.h    | 42 ------------------
 cpukit/include/rtems/score/schedulersmpimpl.h | 64 +++++++++++++++------------
 2 files changed, 35 insertions(+), 71 deletions(-)

diff --git a/cpukit/include/rtems/score/schedulerimpl.h b/cpukit/include/rtems/score/schedulerimpl.h
index 0081b19..10dd039 100644
--- a/cpukit/include/rtems/score/schedulerimpl.h
+++ b/cpukit/include/rtems/score/schedulerimpl.h
@@ -954,48 +954,6 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Discard_idle_thread(
   _Thread_Set_CPU( the_thread, cpu );
   _Thread_Dispatch_update_heir( _Per_CPU_Get(), cpu, the_thread );
 }
-
-/**
- * @brief Unblocks this scheduler node.
- *
- * @param context The scheduler instance context.
- * @param[in, out] the_thread The thread which wants to get unblocked.
- * @param[in, out] node The node which wants to get unblocked.
- * @param is_scheduled This node is scheduled.
- * @param release_idle_thread Function to release an idle thread.
- *
- * @retval true Continue with the unblocking operation.
- * @retval false Do not continue with the unblocking operation.
- */
-RTEMS_INLINE_ROUTINE bool _Scheduler_Unblock_node(
-  Thread_Control              *the_thread,
-  Scheduler_Node              *node,
-  bool                         is_scheduled,
-  Scheduler_Release_idle_node  release_idle_node,
-  void                        *arg
-)
-{
-  bool unblock;
-
-  ++node->sticky_level;
-  _Assert( node->sticky_level > 0 );
-
-  if ( is_scheduled ) {
-    _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_SCHEDULED );
-    _Scheduler_Discard_idle_thread(
-      the_thread,
-      node,
-      release_idle_node,
-      arg
-    );
-    unblock = false;
-  } else {
-    _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_READY );
-    unblock = true;
-  }
-
-  return unblock;
-}
 #endif
 
 /**
diff --git a/cpukit/include/rtems/score/schedulersmpimpl.h b/cpukit/include/rtems/score/schedulersmpimpl.h
index 8aa41e8..f4383e9 100644
--- a/cpukit/include/rtems/score/schedulersmpimpl.h
+++ b/cpukit/include/rtems/score/schedulersmpimpl.h
@@ -1326,43 +1326,49 @@ static inline void _Scheduler_SMP_Unblock(
 )
 {
   Scheduler_SMP_Node_state  node_state;
-  bool                      unblock;
+  Priority_Control          priority;
+  bool                      needs_help;
+
+  ++node->sticky_level;
+  _Assert( node->sticky_level > 0 );
 
   node_state = _Scheduler_SMP_Node_state( node );
-  unblock = _Scheduler_Unblock_node(
-    thread,
-    node,
-    node_state == SCHEDULER_SMP_NODE_SCHEDULED,
-    release_idle_node,
-    context
-  );
 
-  if ( unblock ) {
-    Priority_Control priority;
-    bool             needs_help;
+  if ( RTEMS_PREDICT_FALSE( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) ) {
+    _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED );
+    _Scheduler_Discard_idle_thread(
+      thread,
+      node,
+      release_idle_node,
+      context
+    );
 
-    priority = _Scheduler_Node_get_priority( node );
-    priority = SCHEDULER_PRIORITY_PURIFY( priority );
+    return;
+  }
 
-    if ( priority != _Scheduler_SMP_Node_priority( node ) ) {
-      ( *update )( context, node, priority );
-    }
+  _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_READY );
 
-    if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) {
-      Priority_Control insert_priority;
+  priority = _Scheduler_Node_get_priority( node );
+  priority = SCHEDULER_PRIORITY_PURIFY( priority );
 
-      insert_priority = SCHEDULER_PRIORITY_APPEND( priority );
-      needs_help = ( *enqueue )( context, node, insert_priority );
-    } else {
-      _Assert( node_state == SCHEDULER_SMP_NODE_READY );
-      _Assert( node->sticky_level > 0 );
-      _Assert( node->idle == NULL );
-      needs_help = true;
-    }
+  if ( priority != _Scheduler_SMP_Node_priority( node ) ) {
+    ( *update )( context, node, priority );
+  }
 
-    if ( needs_help ) {
-      _Scheduler_Ask_for_help( thread );
-    }
+  if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) {
+    Priority_Control insert_priority;
+
+    insert_priority = SCHEDULER_PRIORITY_APPEND( priority );
+    needs_help = ( *enqueue )( context, node, insert_priority );
+  } else {
+    _Assert( node_state == SCHEDULER_SMP_NODE_READY );
+    _Assert( node->sticky_level > 0 );
+    _Assert( node->idle == NULL );
+    needs_help = true;
+  }
+
+  if ( needs_help ) {
+    _Scheduler_Ask_for_help( thread );
   }
 }
 



More information about the vc mailing list