From d2bdf5cc4d16d0f7041e876486fca3f66b4b7a26 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Sun, 22 Mar 2015 11:58:10 +0100 Subject: score: Move _Thread_queue_Requeue() Now all the main thread queue operations are in one module. --- cpukit/score/Makefile.am | 2 +- cpukit/score/src/threadqenqueue.c | 42 ++++++++++++++++++++++++ cpukit/score/src/threadqrequeue.c | 67 --------------------------------------- 3 files changed, 43 insertions(+), 68 deletions(-) delete mode 100644 cpukit/score/src/threadqrequeue.c diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 265a49689b..090f7f676e 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -298,7 +298,7 @@ endif ## THREADQ_C_FILES libscore_a_SOURCES += src/threadq.c \ - src/threadqenqueue.c src/threadqrequeue.c \ + src/threadqenqueue.c \ src/threadqextractwithproxy.c src/threadqfirst.c \ src/threadqflush.c src/threadqprocesstimeout.c src/threadqtimeout.c diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index fbc0ba0ff5..e1e876c885 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -296,3 +296,45 @@ Thread_Control *_Thread_queue_Dequeue( return the_thread; } + +void _Thread_queue_Requeue( + Thread_queue_Control *the_thread_queue, + Thread_Control *the_thread +) +{ + /* + * Just in case the thread really wasn't blocked on a thread queue + * when we get here. + */ + if ( !the_thread_queue ) + return; + + /* + * If queueing by FIFO, there is nothing to do. This only applies to + * priority blocking discipline. + */ + if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) { + Thread_queue_Control *tq = the_thread_queue; + ISR_Level level; + + _ISR_Disable( level ); + if ( _States_Is_waiting_on_thread_queue( the_thread->current_state ) ) { + _Thread_queue_Enter_critical_section( tq ); + + /* extract the thread */ + _RBTree_Extract( + &the_thread->Wait.queue->Queues.Priority, + &the_thread->RBNode + ); + + /* enqueue the thread at the new priority */ + _RBTree_Insert( + &the_thread_queue->Queues.Priority, + &the_thread->RBNode, + _Thread_queue_Compare_priority, + false + ); + } + _ISR_Enable( level ); + } +} diff --git a/cpukit/score/src/threadqrequeue.c b/cpukit/score/src/threadqrequeue.c deleted file mode 100644 index 791a59e73c..0000000000 --- a/cpukit/score/src/threadqrequeue.c +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file - * - * @brief Thread Queue Requeue - * @ingroup ScoreThreadQ - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include - -void _Thread_queue_Requeue( - Thread_queue_Control *the_thread_queue, - Thread_Control *the_thread -) -{ - /* - * Just in case the thread really wasn't blocked on a thread queue - * when we get here. - */ - if ( !the_thread_queue ) - return; - - /* - * If queueing by FIFO, there is nothing to do. This only applies to - * priority blocking discipline. - */ - if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) { - Thread_queue_Control *tq = the_thread_queue; - ISR_Level level; - - _ISR_Disable( level ); - if ( _States_Is_waiting_on_thread_queue( the_thread->current_state ) ) { - _Thread_queue_Enter_critical_section( tq ); - - /* extract the thread */ - _RBTree_Extract( - &the_thread->Wait.queue->Queues.Priority, - &the_thread->RBNode - ); - - /* enqueue the thread at the new priority */ - _RBTree_Insert( - &the_thread_queue->Queues.Priority, - &the_thread->RBNode, - _Thread_queue_Compare_priority, - false - ); - } - _ISR_Enable( level ); - } -} - -- cgit v1.2.3