[PATCH 02/15] score: Use _RBTree_Insert_inline()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri May 20 13:33:39 UTC 2016
Use _RBTree_Insert_inline() for priority thread queues.
Update #2556.
---
cpukit/score/include/rtems/score/threadqimpl.h | 15 --------------
cpukit/score/src/threadq.c | 21 -------------------
cpukit/score/src/threadqops.c | 28 ++++++++++++++++++++------
3 files changed, 22 insertions(+), 42 deletions(-)
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index ec222bd..03879fc 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -826,21 +826,6 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Boost_priority(
}
#endif
-/**
- * @brief Compare two thread's priority for RBTree Insertion.
- *
- * @param[in] left points to the left thread's RBnode
- * @param[in] right points to the right thread's RBnode
- *
- * @retval 1 The @a left node is more important than @a right node.
- * @retval 0 The @a left node is of equal importance with @a right node.
- * @retval 1 The @a left node is less important than @a right node.
- */
-RBTree_Compare_result _Thread_queue_Compare_priority(
- const RBTree_Node *left,
- const RBTree_Node *right
-);
-
#if defined(RTEMS_MULTIPROCESSING)
void _Thread_queue_MP_callout_do_nothing(
Thread_Control *the_proxy,
diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c
index fdb2bee..ca2b900 100644
--- a/cpukit/score/src/threadq.c
+++ b/cpukit/score/src/threadq.c
@@ -64,27 +64,6 @@ RTEMS_STATIC_ASSERT(
#endif /* HAVE_STRUCT__THREAD_QUEUE_QUEUE */
-RBTree_Compare_result _Thread_queue_Compare_priority(
- const RBTree_Node *left,
- const RBTree_Node *right
-)
-{
- const Thread_Control *left_thread;
- const Thread_Control *right_thread;
- Priority_Control left_prio;
- Priority_Control right_prio;
-
- left_thread = THREAD_RBTREE_NODE_TO_THREAD( left );
- right_thread = THREAD_RBTREE_NODE_TO_THREAD( right );
- left_prio = left_thread->current_priority;
- right_prio = right_thread->current_priority;
-
- /*
- * SuperCore priorities use lower numbers to indicate greater importance.
- */
- return ( left_prio > right_prio ) - ( left_prio < right_prio );
-}
-
void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue )
{
_Thread_queue_Queue_initialize( &the_thread_queue->Queue );
diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c
index 5a82aaa..c3221b9 100644
--- a/cpukit/score/src/threadqops.c
+++ b/cpukit/score/src/threadqops.c
@@ -167,6 +167,20 @@ static Thread_queue_Priority_queue *_Thread_queue_Priority_queue(
#endif
}
+static bool _Thread_queue_Priority_less(
+ const void *left,
+ const RBTree_Node *right
+)
+{
+ const Priority_Control *the_left;
+ const Thread_Control *the_right;
+
+ the_left = left;
+ the_right = THREAD_RBTREE_NODE_TO_THREAD( right );
+
+ return *the_left < the_right->current_priority;
+}
+
static void _Thread_queue_Priority_priority_change(
Thread_Control *the_thread,
Priority_Control new_priority,
@@ -184,11 +198,11 @@ static void _Thread_queue_Priority_priority_change(
&priority_queue->Queue,
&the_thread->Wait.Node.RBTree
);
- _RBTree_Insert(
+ _RBTree_Insert_inline(
&priority_queue->Queue,
&the_thread->Wait.Node.RBTree,
- _Thread_queue_Compare_priority,
- false
+ &new_priority,
+ _Thread_queue_Priority_less
);
}
@@ -210,6 +224,7 @@ static void _Thread_queue_Priority_do_enqueue(
{
Thread_queue_Priority_queue *priority_queue =
_Thread_queue_Priority_queue( heads, the_thread );
+ Priority_Control current_priority;
#if defined(RTEMS_SMP)
if ( _RBTree_Is_empty( &priority_queue->Queue ) ) {
@@ -217,11 +232,12 @@ static void _Thread_queue_Priority_do_enqueue(
}
#endif
- _RBTree_Insert(
+ current_priority = the_thread->current_priority;
+ _RBTree_Insert_inline(
&priority_queue->Queue,
&the_thread->Wait.Node.RBTree,
- _Thread_queue_Compare_priority,
- false
+ ¤t_priority,
+ _Thread_queue_Priority_less
);
}
--
1.8.4.5
More information about the devel
mailing list