[rtems commit] score: Optimize thread queue first operation

Sebastian Huber sebh at rtems.org
Wed Sep 2 13:05:24 UTC 2015


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Sep  2 15:02:27 2015 +0200

score: Optimize thread queue first operation

In case the thread queue heads exist, then the queue is not empty.  See
_Thread_queue_First_locked().

---

 cpukit/score/src/threadqops.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c
index c9e2b5d..d9dc944 100644
--- a/cpukit/score/src/threadqops.c
+++ b/cpukit/score/src/threadqops.c
@@ -142,9 +142,12 @@ static Thread_Control *_Thread_queue_FIFO_first(
 )
 {
   Chain_Control *fifo = &heads->Heads.Fifo;
+  Chain_Node    *first;
 
-  return _Chain_Is_empty( fifo ) ?
-    NULL : THREAD_CHAIN_NODE_TO_THREAD( _Chain_First( fifo ) );
+  _Assert( !_Chain_Is_empty( fifo ) );
+  first = _Chain_First( fifo );
+
+  return THREAD_CHAIN_NODE_TO_THREAD( first );
 }
 
 static void _Thread_queue_Priority_priority_change(
@@ -229,11 +232,13 @@ static Thread_Control *_Thread_queue_Priority_first(
   Thread_queue_Heads *heads
 )
 {
-  RBTree_Node *first;
+  RBTree_Control *priority_queue = &heads->Heads.Priority;
+  RBTree_Node    *first;
 
-  first = _RBTree_Minimum( &heads->Heads.Priority );
+  _Assert( !_RBTree_Is_empty( priority_queue ) );
+  first = _RBTree_Minimum( priority_queue );
 
-  return first != NULL ? THREAD_RBTREE_NODE_TO_THREAD( first ) : NULL;
+  return THREAD_RBTREE_NODE_TO_THREAD( first );
 }
 
 const Thread_queue_Operations _Thread_queue_Operations_default = {



More information about the vc mailing list