summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-19 17:03:31 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-20 16:11:02 +0200
commit8a040fe4eeb9f7ba5c9f95f8abd45b9b6d5f7c4b (patch)
tree9eae69fdf0cbda0635d6f2c9e13c04a50dab0742
parentscore: Add per scheduler instance maximum priority (diff)
downloadrtems-8a040fe4eeb9f7ba5c9f95f8abd45b9b6d5f7c4b.tar.bz2
score: Use _RBTree_Insert_inline()
Use _RBTree_Insert_inline() for priority thread queues. Update #2556.
-rw-r--r--cpukit/score/include/rtems/score/threadqimpl.h15
-rw-r--r--cpukit/score/src/threadq.c21
-rw-r--r--cpukit/score/src/threadqops.c28
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 b09cc97790..5ce89e76f4 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 b3ccbd6f4b..00d9cb13cf 100644
--- a/cpukit/score/src/threadq.c
+++ b/cpukit/score/src/threadq.c
@@ -58,27 +58,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 5a82aaa33e..c3221b94b6 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
+ &current_priority,
+ _Thread_queue_Priority_less
);
}