diff options
author | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-07-07 14:26:13 -0500 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-07-15 12:43:44 -0500 |
commit | ed7a02895e3bedda5edb33c91f0ffc956e9cab06 (patch) | |
tree | 0266870aab25e0eca278237aca3e11a621a12c9e /cpukit/score/src/threadq.c | |
parent | rbtree: Reduce RBTree_Control size (diff) | |
download | rtems-ed7a02895e3bedda5edb33c91f0ffc956e9cab06.tar.bz2 |
Thread Queue Priority Discipline Reimplemented with RBTree
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/src/threadq.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c index 69b687fe1c..0ffbfada09 100644 --- a/cpukit/score/src/threadq.c +++ b/cpukit/score/src/threadq.c @@ -6,7 +6,7 @@ */ /* - * COPYRIGHT (c) 1989-2008. + * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -22,6 +22,28 @@ #include <rtems/score/chainimpl.h> #include <rtems/score/scheduler.h> +#include <rtems/score/rbtreeimpl.h> + +int _Thread_queue_Compare_priority( + const RBTree_Node *left, + const RBTree_Node *right +) +{ + Priority_Control left_priority = _RBTree_Container_of + (left,Thread_Control,RBNode)->current_priority; + Priority_Control right_priority = _RBTree_Container_of + (right,Thread_Control,RBNode)->current_priority; + + /* + * SuperCore priorities use lower numbers to indicate greater importance. + */ + if ( left_priority == right_priority ) + return 0; + if ( left_priority < right_priority ) + return -1; + return 1; +} + void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue, Thread_queue_Disciplines the_discipline, @@ -39,12 +61,7 @@ void _Thread_queue_Initialize( the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED; if ( the_discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) { - uint32_t index; - - for( index=0 ; - index < TASK_QUEUE_DATA_NUMBER_OF_PRIORITY_HEADERS ; - index++) - _Chain_Initialize_empty( &the_thread_queue->Queues.Priority[index] ); + _RBTree_Initialize_empty( &the_thread_queue->Queues.Priority ); } else { /* must be THREAD_QUEUE_DISCIPLINE_FIFO */ _Chain_Initialize_empty( &the_thread_queue->Queues.Fifo ); } |