mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 13:15:54 +08:00
score: Use _RBTree_Insert_inline()
Use _RBTree_Insert_inline() for priority thread queues. Update #2556.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user