score: Move _Thread_queue_Requeue()

Now all the main thread queue operations are in one module.
This commit is contained in:
Sebastian Huber
2015-03-22 11:58:10 +01:00
parent 688fbc4401
commit d2bdf5cc4d
3 changed files with 43 additions and 68 deletions
+1 -1
View File
@@ -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
+42
View File
@@ -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 );
}
}
-67
View File
@@ -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 <rtems/score/threadqimpl.h>
#include <rtems/score/isrlevel.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/watchdogimpl.h>
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 );
}
}