[PATCH 1/2] score: Introduce Thread_queue_Queue
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Jul 20 06:02:30 UTC 2015
Separate the thread queue heads and lock from the operations. This
enables the support for light weight objects which only support one
queueing discipline.
---
cpukit/posix/src/killinfo.c | 2 +-
cpukit/posix/src/sigtimedwait.c | 3 +-
cpukit/score/include/rtems/score/coremsgimpl.h | 3 +-
cpukit/score/include/rtems/score/coresemimpl.h | 6 +-
cpukit/score/include/rtems/score/thread.h | 2 +-
cpukit/score/include/rtems/score/threadimpl.h | 4 +-
cpukit/score/include/rtems/score/threadq.h | 79 +++++++++--------
cpukit/score/include/rtems/score/threadqimpl.h | 114 +++++++++++++++++--------
cpukit/score/src/corebarrierwait.c | 3 +-
cpukit/score/src/coremsgseize.c | 6 +-
cpukit/score/src/coremsgsubmit.c | 3 +-
cpukit/score/src/coremutexseize.c | 3 +-
cpukit/score/src/coremutexsurrender.c | 8 +-
cpukit/score/src/corerwlockobtainread.c | 3 +-
cpukit/score/src/corerwlockobtainwrite.c | 3 +-
cpukit/score/src/threadq.c | 4 +-
cpukit/score/src/threadqenqueue.c | 85 ++++++++++--------
cpukit/score/src/threadqflush.c | 3 +-
cpukit/score/src/threadqops.c | 58 ++++++-------
testsuites/sptests/spthreadq01/init.c | 4 +-
20 files changed, 234 insertions(+), 162 deletions(-)
diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c
index c8c59d6..d08e686 100644
--- a/cpukit/posix/src/killinfo.c
+++ b/cpukit/posix/src/killinfo.c
@@ -140,7 +140,7 @@ int killinfo(
/* XXX violation of visibility -- need to define thread queue support */
- the_chain = &_POSIX_signals_Wait_queue.Queues.Fifo;
+ the_chain = &_POSIX_signals_Wait_queue.Queue.Heads.Fifo;
for ( the_node = _Chain_First( the_chain );
!_Chain_Is_tail( the_chain, the_node ) ;
diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c
index fb8a243..7a8c29e 100644
--- a/cpukit/posix/src/sigtimedwait.c
+++ b/cpukit/posix/src/sigtimedwait.c
@@ -156,7 +156,8 @@ int sigtimedwait(
executing->Wait.option = *set;
executing->Wait.return_argument = the_info;
_Thread_queue_Enqueue_critical(
- &_POSIX_signals_Wait_queue,
+ &_POSIX_signals_Wait_queue.Queue,
+ _POSIX_signals_Wait_queue.operations,
executing,
STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL,
interval,
diff --git a/cpukit/score/include/rtems/score/coremsgimpl.h b/cpukit/score/include/rtems/score/coremsgimpl.h
index 51b5f37..382ce92 100644
--- a/cpukit/score/include/rtems/score/coremsgimpl.h
+++ b/cpukit/score/include/rtems/score/coremsgimpl.h
@@ -599,7 +599,8 @@ RTEMS_INLINE_ROUTINE Thread_Control *_CORE_message_queue_Dequeue_receiver(
);
_Thread_queue_Extract_critical(
- &the_message_queue->Wait_queue,
+ &the_message_queue->Wait_queue.Queue,
+ the_message_queue->Wait_queue.operations,
the_thread,
lock_context
);
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
index da57ad1..a6a30bc 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -140,7 +140,8 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
#endif
_Thread_queue_Extract_critical(
- &the_semaphore->Wait_queue,
+ &the_semaphore->Wait_queue.Queue,
+ the_semaphore->Wait_queue.operations,
the_thread,
lock_context
);
@@ -263,7 +264,8 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize(
executing->Wait.id = id;
_Thread_queue_Enqueue_critical(
- &the_semaphore->Wait_queue,
+ &the_semaphore->Wait_queue.Queue,
+ the_semaphore->Wait_queue.operations,
executing,
STATES_WAITING_FOR_SEMAPHORE,
timeout,
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 9d8382c..f9ba3a0 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -329,7 +329,7 @@ typedef struct {
*
* @see _Thread_Lock_set() and _Thread_Wait_set_queue().
*/
- Thread_queue_Control *queue;
+ Thread_queue_Queue *queue;
/**
* @brief This field contains several flags used to control the wait class
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index 0dfdb8a..4dcef0b 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -1368,8 +1368,8 @@ RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change(
* @see _Thread_Lock_set().
*/
RTEMS_INLINE_ROUTINE void _Thread_Wait_set_queue(
- Thread_Control *the_thread,
- Thread_queue_Control *new_queue
+ Thread_Control *the_thread,
+ Thread_queue_Queue *new_queue
)
{
the_thread->Wait.queue = new_queue;
diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h
index 06ea36a..599a81c 100644
--- a/cpukit/score/include/rtems/score/threadq.h
+++ b/cpukit/score/include/rtems/score/threadq.h
@@ -41,64 +41,85 @@ extern "C" {
typedef struct Thread_Control Thread_Control;
-typedef struct Thread_queue_Control Thread_queue_Control;
+typedef struct {
+ /** This union contains the data structures used to manage the blocked
+ * set of tasks which varies based upon the discipline.
+ */
+ union {
+ /** This is the FIFO discipline list. */
+ Chain_Control Fifo;
+ /** This is the set of threads for priority discipline waiting. */
+ RBTree_Control Priority;
+ } Heads;
+
+ /**
+ * @brief Lock to protect this thread queue.
+ *
+ * It may be used to protect additional state of the object embedding this
+ * thread queue.
+ *
+ * @see _Thread_queue_Acquire(), _Thread_queue_Acquire_critical() and
+ * _Thread_queue_Release().
+ */
+ ISR_LOCK_MEMBER( Lock )
+} Thread_queue_Queue;
/**
* @brief Thread queue priority change operation.
*
* @param[in] the_thread The thread.
* @param[in] new_priority The new priority value.
- * @param[in] the_thread_queue The thread queue.
+ * @param[in] queue The actual thread queue.
*
* @see Thread_queue_Operations.
*/
typedef void ( *Thread_queue_Priority_change_operation )(
- Thread_Control *the_thread,
- Priority_Control new_priority,
- Thread_queue_Control *the_thread_queue
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ Thread_queue_Queue *queue
);
/**
* @brief Thread queue initialize operation.
*
- * @param[in] the_thread_queue The thread queue.
+ * @param[in] queue The actual thread queue.
*
* @see _Thread_Wait_set_operations().
*/
typedef void ( *Thread_queue_Initialize_operation )(
- Thread_queue_Control *the_thread_queue
+ Thread_queue_Queue *queue
);
/**
* @brief Thread queue enqueue operation.
*
- * @param[in] the_thread_queue The thread queue.
+ * @param[in] queue The actual thread queue.
* @param[in] the_thread The thread to enqueue on the queue.
*
* @see _Thread_Wait_set_operations().
*/
typedef void ( *Thread_queue_Enqueue_operation )(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread
);
/**
* @brief Thread queue extract operation.
*
- * @param[in] the_thread_queue The thread queue.
+ * @param[in] queue The actual thread queue.
* @param[in] the_thread The thread to extract from the thread queue.
*
* @see _Thread_Wait_set_operations().
*/
typedef void ( *Thread_queue_Extract_operation )(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread
);
/**
* @brief Thread queue first operation.
*
- * @param[in] the_thread_queue The thread queue.
+ * @param[in] queue The actual thread queue.
*
* @retval NULL No thread is present on the thread queue.
* @retval first The first thread of the thread queue according to the insert
@@ -107,7 +128,7 @@ typedef void ( *Thread_queue_Extract_operation )(
* @see _Thread_Wait_set_operations().
*/
typedef Thread_Control *( *Thread_queue_First_operation )(
- Thread_queue_Control *the_thread_queue
+ Thread_queue_Queue *queue
);
/**
@@ -168,33 +189,17 @@ typedef enum {
* This is the structure used to manage sets of tasks which are blocked
* waiting to acquire a resource.
*/
-struct Thread_queue_Control {
- /** This union contains the data structures used to manage the blocked
- * set of tasks which varies based upon the discipline.
- */
- union {
- /** This is the FIFO discipline list. */
- Chain_Control Fifo;
- /** This is the set of threads for priority discipline waiting. */
- RBTree_Control Priority;
- } Queues;
-
+typedef struct {
/**
- * @brief The operations for this thread queue.
+ * @brief The actual thread queue.
*/
- const Thread_queue_Operations *operations;
+ Thread_queue_Queue Queue;
/**
- * @brief Lock to protect this thread queue.
- *
- * It may be used to protect additional state of the object embedding this
- * thread queue.
- *
- * @see _Thread_queue_Acquire(), _Thread_queue_Acquire_critical() and
- * _Thread_queue_Release().
+ * @brief The operations for the actual thread queue.
*/
- ISR_LOCK_MEMBER( Lock )
-};
+ const Thread_queue_Operations *operations;
+} Thread_queue_Control;
/**@}*/
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index b8982ec..330b18c 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -33,12 +33,31 @@ extern "C" {
*/
/**@{*/
+RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_acquire_critical(
+ Thread_queue_Queue *queue,
+ ISR_lock_Context *lock_context
+)
+{
+ _ISR_lock_Acquire( &queue->Lock, lock_context );
+}
+
+RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release(
+ Thread_queue_Queue *queue,
+ ISR_lock_Context *lock_context
+)
+{
+ _ISR_lock_Release_and_ISR_enable( &queue->Lock, lock_context );
+}
+
RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(
Thread_queue_Control *the_thread_queue,
ISR_lock_Context *lock_context
)
{
- _ISR_lock_Acquire( &the_thread_queue->Lock, lock_context );
+ _Thread_queue_Queue_acquire_critical(
+ &the_thread_queue->Queue,
+ lock_context
+ );
}
RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire(
@@ -55,7 +74,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Release(
ISR_lock_Context *lock_context
)
{
- _ISR_lock_Release_and_ISR_enable( &the_thread_queue->Lock, lock_context );
+ _Thread_queue_Queue_release( &the_thread_queue->Queue, lock_context );
}
/**
@@ -120,7 +139,8 @@ Thread_Control *_Thread_queue_Dequeue(
* _Thread_queue_Release( &mutex->Queue, &lock_context );
* } else {
* _Thread_queue_Enqueue_critical(
- * &mutex->Queue,
+ * &mutex->Queue.Queue,
+ * mutex->Queue.operations,
* executing,
* STATES_WAITING_FOR_MUTEX,
* WATCHDOG_NO_TIMEOUT,
@@ -131,7 +151,8 @@ Thread_Control *_Thread_queue_Dequeue(
* }
* @endcode
*
- * @param[in] the_thread_queue The thread queue.
+ * @param[in] queue The actual thread queue.
+ * @param[in] operations The thread queue operations.
* @param[in] the_thread The thread to enqueue.
* @param[in] state The new state of the thread.
* @param[in] timeout Interval to wait. Use WATCHDOG_NO_TIMEOUT to block
@@ -140,12 +161,13 @@ Thread_Control *_Thread_queue_Dequeue(
* @param[in] lock_context The lock context of the lock acquire.
*/
void _Thread_queue_Enqueue_critical(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread,
- States_Control state,
- Watchdog_Interval timeout,
- uint32_t timeout_code,
- ISR_lock_Context *lock_context
+ Thread_queue_Queue *queue,
+ const Thread_queue_Operations *operations,
+ Thread_Control *the_thread,
+ States_Control state,
+ Watchdog_Interval timeout,
+ uint32_t timeout_code,
+ ISR_lock_Context *lock_context
);
/**
@@ -164,7 +186,8 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
_Thread_queue_Acquire( the_thread_queue, &lock_context );
_Thread_queue_Enqueue_critical(
- the_thread_queue,
+ &the_thread_queue->Queue,
+ the_thread_queue->operations,
the_thread,
state,
timeout,
@@ -180,12 +203,14 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
* The caller must be the owner of the thread queue lock. The thread queue
* lock is not released.
*
- * @param[in] the_thread_queue The thread queue.
+ * @param[in] queue The actual thread queue.
+ * @param[in] operations The thread queue operations.
* @param[in] the_thread The thread to extract.
*/
void _Thread_queue_Extract_locked(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread
+ Thread_queue_Queue *queue,
+ const Thread_queue_Operations *operations,
+ Thread_Control *the_thread
);
/**
@@ -196,14 +221,14 @@ void _Thread_queue_Extract_locked(
* thread queue lock is released and an unblock is necessary. Thread
* dispatching is enabled once the sequence to unblock the thread is complete.
*
- * @param[in] the_thread_queue The thread queue.
+ * @param[in] queue The actual thread queue.
* @param[in] the_thread The thread to extract.
* @param[in] lock_context The lock context of the lock acquire.
*/
void _Thread_queue_Unblock_critical(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread,
+ ISR_lock_Context *lock_context
);
/**
@@ -238,21 +263,24 @@ void _Thread_queue_Unblock_critical(
*
* if ( first != NULL ) {
* _Thread_queue_Extract_critical(
- * &mutex->Queue,
+ * &mutex->Queue.Queue,
+ * mutex->Queue.operations,
* first,
* &lock_context
* );
* }
* @endcode
*
- * @param[in] the_thread_queue The thread queue.
+ * @param[in] queue The actual thread queue.
+ * @param[in] operations The thread queue operations.
* @param[in] the_thread The thread to extract.
* @param[in] lock_context The lock context of the lock acquire.
*/
void _Thread_queue_Extract_critical(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
+ Thread_queue_Queue *queue,
+ const Thread_queue_Operations *operations,
+ Thread_Control *the_thread,
+ ISR_lock_Context *lock_context
);
/**
@@ -294,7 +322,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked(
Thread_queue_Control *the_thread_queue
)
{
- return ( *the_thread_queue->operations->first )( the_thread_queue );
+ return ( *the_thread_queue->operations->first )( &the_thread_queue->Queue );
}
/**
@@ -346,31 +374,43 @@ void _Thread_queue_Initialize(
#if defined(RTEMS_SMP)
#define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
- .Queues = { \
- .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queues.Fifo ) \
+ .Queue = { \
+ .Heads = { \
+ .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queue.Heads.Fifo ) \
+ }, \
+ .Lock = ISR_LOCK_INITIALIZER( name ), \
}, \
- .operations = &_Thread_queue_Operations_FIFO, \
- .Lock = ISR_LOCK_INITIALIZER( name ) \
+ .operations = &_Thread_queue_Operations_FIFO \
}
#define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
- .Queues = { \
- .Priority = RBTREE_INITIALIZER_EMPTY( designator.Queues.Priority ) \
+ .Queue = { \
+ .Heads = { \
+ .Priority = RBTREE_INITIALIZER_EMPTY( \
+ designator.Queue.Heads.Priority \
+ ) \
+ }, \
+ .Lock = ISR_LOCK_INITIALIZER( name ), \
}, \
- .operations = &_Thread_queue_Operations_priority, \
- .Lock = ISR_LOCK_INITIALIZER( name ) \
+ .operations = &_Thread_queue_Operations_priority \
}
#else
#define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
- .Queues = { \
- .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queues.Fifo ) \
+ .Queue = { \
+ .Heads = { \
+ .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queue.Heads.Fifo ) \
+ } \
}, \
.operations = &_Thread_queue_Operations_FIFO \
}
#define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
- .Queues = { \
- .Priority = RBTREE_INITIALIZER_EMPTY( designator.Queues.Priority ) \
+ .Queue = { \
+ .Heads = { \
+ .Priority = RBTREE_INITIALIZER_EMPTY( \
+ designator.Queue.Heads.Priority \
+ ) \
+ } \
}, \
.operations = &_Thread_queue_Operations_priority \
}
@@ -380,7 +420,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(
Thread_queue_Control *the_thread_queue
)
{
- _ISR_lock_Destroy( &the_thread_queue->Lock );
+ _ISR_lock_Destroy( &the_thread_queue->Queue.Lock );
}
/**
diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c
index 39687d3..b7f424d 100644
--- a/cpukit/score/src/corebarrierwait.c
+++ b/cpukit/score/src/corebarrierwait.c
@@ -50,7 +50,8 @@ void _CORE_barrier_Wait(
executing->Wait.id = id;
_Thread_queue_Enqueue_critical(
- &the_barrier->Wait_queue,
+ &the_barrier->Wait_queue.Queue,
+ the_barrier->Wait_queue.operations,
executing,
STATES_WAITING_FOR_BARRIER,
timeout,
diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c
index 0d1c36f..b6ba8e9 100644
--- a/cpukit/score/src/coremsgseize.c
+++ b/cpukit/score/src/coremsgseize.c
@@ -107,7 +107,8 @@ void _CORE_message_queue_Seize(
_CORE_message_queue_Get_message_priority( the_message )
);
_Thread_queue_Extract_critical(
- &the_message_queue->Wait_queue,
+ &the_message_queue->Wait_queue.Queue,
+ the_message_queue->Wait_queue.operations,
the_thread,
lock_context
);
@@ -131,7 +132,8 @@ void _CORE_message_queue_Seize(
/* Wait.count will be filled in with the message priority */
_Thread_queue_Enqueue_critical(
- &the_message_queue->Wait_queue,
+ &the_message_queue->Wait_queue.Queue,
+ the_message_queue->Wait_queue.operations,
executing,
STATES_WAITING_FOR_MESSAGE,
timeout,
diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c
index 37f8579..351c76b 100644
--- a/cpukit/score/src/coremsgsubmit.c
+++ b/cpukit/score/src/coremsgsubmit.c
@@ -132,7 +132,8 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
executing->Wait.count = submit_type;
_Thread_queue_Enqueue_critical(
- &the_message_queue->Wait_queue,
+ &the_message_queue->Wait_queue.Queue,
+ the_message_queue->Wait_queue.operations,
executing,
STATES_WAITING_FOR_MESSAGE,
timeout,
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index d5f85c5..ddc5d6b 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -83,7 +83,8 @@ void _CORE_mutex_Seize_interrupt_blocking(
}
_Thread_queue_Enqueue_critical(
- &the_mutex->Wait_queue,
+ &the_mutex->Wait_queue.Queue,
+ the_mutex->Wait_queue.operations,
executing,
STATES_WAITING_FOR_MUTEX,
timeout,
diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c
index d5dde1e..e3f0d6f 100644
--- a/cpukit/score/src/coremutexsurrender.c
+++ b/cpukit/score/src/coremutexsurrender.c
@@ -185,7 +185,11 @@ CORE_mutex_Status _CORE_mutex_Surrender(
* _Thread_Change_priority() below due to a recursive thread queue lock
* acquire.
*/
- _Thread_queue_Extract_locked( &the_mutex->Wait_queue, the_thread );
+ _Thread_queue_Extract_locked(
+ &the_mutex->Wait_queue.Queue,
+ the_mutex->Wait_queue.operations,
+ the_thread
+ );
#if defined(RTEMS_MULTIPROCESSING)
_Thread_Dispatch_disable();
@@ -216,7 +220,7 @@ CORE_mutex_Status _CORE_mutex_Surrender(
}
_Thread_queue_Unblock_critical(
- &the_mutex->Wait_queue,
+ &the_mutex->Wait_queue.Queue,
the_thread,
lock_context
);
diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c
index 0dea50f..73ebddf 100644
--- a/cpukit/score/src/corerwlockobtainread.c
+++ b/cpukit/score/src/corerwlockobtainread.c
@@ -83,7 +83,8 @@ void _CORE_RWLock_Obtain_for_reading(
executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
_Thread_queue_Enqueue_critical(
- &the_rwlock->Wait_queue,
+ &the_rwlock->Wait_queue.Queue,
+ the_rwlock->Wait_queue.operations,
executing,
STATES_WAITING_FOR_RWLOCK,
timeout,
diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c
index 76dfae2..b5b31dc 100644
--- a/cpukit/score/src/corerwlockobtainwrite.c
+++ b/cpukit/score/src/corerwlockobtainwrite.c
@@ -73,7 +73,8 @@ void _CORE_RWLock_Obtain_for_writing(
executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
_Thread_queue_Enqueue_critical(
- &the_rwlock->Wait_queue,
+ &the_rwlock->Wait_queue.Queue,
+ the_rwlock->Wait_queue.operations,
executing,
STATES_WAITING_FOR_RWLOCK,
timeout,
diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c
index 3b1b47b..fc50601 100644
--- a/cpukit/score/src/threadq.c
+++ b/cpukit/score/src/threadq.c
@@ -50,7 +50,7 @@ void _Thread_queue_Initialize(
{
const Thread_queue_Operations *operations;
- _ISR_lock_Initialize( &the_thread_queue->Lock, "Thread Queue" );
+ _ISR_lock_Initialize( &the_thread_queue->Queue.Lock, "Thread Queue" );
if ( the_discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) {
operations = &_Thread_queue_Operations_priority;
@@ -60,5 +60,5 @@ void _Thread_queue_Initialize(
}
the_thread_queue->operations = operations;
- ( *operations->initialize )( the_thread_queue );
+ ( *operations->initialize )( &the_thread_queue->Queue );
}
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index f73fa01..5ed01b7 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -46,29 +46,28 @@ static void _Thread_queue_Unblock( Thread_Control *the_thread )
}
void _Thread_queue_Enqueue_critical(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread,
- States_Control state,
- Watchdog_Interval timeout,
- uint32_t timeout_code,
- ISR_lock_Context *lock_context
+ Thread_queue_Queue *queue,
+ const Thread_queue_Operations *operations,
+ Thread_Control *the_thread,
+ States_Control state,
+ Watchdog_Interval timeout,
+ uint32_t timeout_code,
+ ISR_lock_Context *lock_context
)
{
- const Thread_queue_Operations *operations;
- Per_CPU_Control *cpu_self;
- bool success;
+ Per_CPU_Control *cpu_self;
+ bool success;
- _Thread_Lock_set( the_thread, &the_thread_queue->Lock );
+ _Thread_Lock_set( the_thread, &queue->Lock );
- operations = the_thread_queue->operations;
- _Thread_Wait_set_queue( the_thread, the_thread_queue );
+ _Thread_Wait_set_queue( the_thread, queue );
_Thread_Wait_set_operations( the_thread, operations );
- ( *operations->enqueue )( the_thread_queue, the_thread );
+ ( *operations->enqueue )( queue, the_thread );
_Thread_Wait_flags_set( the_thread, THREAD_QUEUE_INTEND_TO_BLOCK );
cpu_self = _Thread_Dispatch_disable_critical( lock_context );
- _Thread_queue_Release( the_thread_queue, lock_context );
+ _Thread_queue_Queue_release( queue, lock_context );
#if defined(RTEMS_MULTIPROCESSING)
if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet )
@@ -102,11 +101,12 @@ void _Thread_queue_Enqueue_critical(
}
void _Thread_queue_Extract_locked(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread
+ Thread_queue_Queue *queue,
+ const Thread_queue_Operations *operations,
+ Thread_Control *the_thread
)
{
- ( *the_thread_queue->operations->extract )( the_thread_queue, the_thread );
+ ( *operations->extract )( queue, the_thread );
_Thread_Wait_set_queue( the_thread, NULL );
_Thread_Wait_restore_default_operations( the_thread );
@@ -114,9 +114,9 @@ void _Thread_queue_Extract_locked(
}
void _Thread_queue_Unblock_critical(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread,
+ ISR_lock_Context *lock_context
)
{
bool success;
@@ -139,40 +139,46 @@ void _Thread_queue_Unblock_critical(
Per_CPU_Control *cpu_self;
cpu_self = _Thread_Dispatch_disable_critical( lock_context );
- _Thread_queue_Release( the_thread_queue, lock_context );
+ _Thread_queue_Queue_release( queue, lock_context );
_Thread_queue_Unblock( the_thread );
_Thread_Dispatch_enable( cpu_self );
} else {
- _Thread_queue_Release( the_thread_queue, lock_context );
+ _Thread_queue_Queue_release( queue, lock_context );
}
}
void _Thread_queue_Extract_critical(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
+ Thread_queue_Queue *queue,
+ const Thread_queue_Operations *operations,
+ Thread_Control *the_thread,
+ ISR_lock_Context *lock_context
)
{
- _Thread_queue_Extract_locked( the_thread_queue, the_thread );
- _Thread_queue_Unblock_critical( the_thread_queue, the_thread, lock_context );
+ _Thread_queue_Extract_locked( queue, operations, the_thread );
+ _Thread_queue_Unblock_critical( queue, the_thread, lock_context );
}
void _Thread_queue_Extract( Thread_Control *the_thread )
{
- ISR_lock_Context lock_context;
- ISR_lock_Control *lock;
- Thread_queue_Control *the_thread_queue;
+ ISR_lock_Context lock_context;
+ ISR_lock_Control *lock;
+ Thread_queue_Queue *queue;
lock = _Thread_Lock_acquire( the_thread, &lock_context );
- the_thread_queue = the_thread->Wait.queue;
+ queue = the_thread->Wait.queue;
- if ( the_thread_queue != NULL ) {
- _SMP_Assert( lock == &the_thread_queue->Lock );
+ if ( queue != NULL ) {
+ _SMP_Assert( lock == &queue->Lock );
- _Thread_queue_Extract_critical( the_thread_queue, the_thread, &lock_context );
+ _Thread_queue_Extract_critical(
+ queue,
+ the_thread->Wait.operations,
+ the_thread,
+ &lock_context
+ );
} else {
_Thread_Lock_release( lock, &lock_context );
}
@@ -188,9 +194,14 @@ Thread_Control *_Thread_queue_Dequeue( Thread_queue_Control *the_thread_queue )
the_thread = _Thread_queue_First_locked( the_thread_queue );
if ( the_thread != NULL ) {
- _SMP_Assert( the_thread->Lock.current == &the_thread_queue->Lock );
-
- _Thread_queue_Extract_critical( the_thread_queue, the_thread, &lock_context );
+ _SMP_Assert( the_thread->Lock.current == &the_thread_queue->Queue.Lock );
+
+ _Thread_queue_Extract_critical(
+ &the_thread_queue->Queue,
+ the_thread_queue->operations,
+ the_thread,
+ &lock_context
+ );
} else {
_Thread_queue_Release( the_thread_queue, &lock_context );
}
diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c
index d37b9e8..530941b 100644
--- a/cpukit/score/src/threadqflush.c
+++ b/cpukit/score/src/threadqflush.c
@@ -43,7 +43,8 @@ void _Thread_queue_Flush(
the_thread->Wait.return_code = status;
_Thread_queue_Extract_critical(
- the_thread_queue,
+ &the_thread_queue->Queue,
+ the_thread_queue->operations,
the_thread,
&lock_context
);
diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c
index 2967a0e..e0be491 100644
--- a/cpukit/score/src/threadqops.c
+++ b/cpukit/score/src/threadqops.c
@@ -21,70 +21,70 @@
#include <rtems/score/rbtreeimpl.h>
static void _Thread_queue_Do_nothing_priority_change(
- Thread_Control *the_thread,
- Priority_Control new_priority,
- Thread_queue_Control *the_thread_queue
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ Thread_queue_Queue *queue
)
{
/* Do nothing */
}
static void _Thread_queue_Do_nothing_extract(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread
)
{
/* Do nothing */
}
static void _Thread_queue_FIFO_initialize(
- Thread_queue_Control *the_thread_queue
+ Thread_queue_Queue *queue
)
{
- _Chain_Initialize_empty( &the_thread_queue->Queues.Fifo );
+ _Chain_Initialize_empty( &queue->Heads.Fifo );
}
static void _Thread_queue_FIFO_enqueue(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread
)
{
_Chain_Append_unprotected(
- &the_thread_queue->Queues.Fifo,
+ &queue->Heads.Fifo,
&the_thread->Wait.Node.Chain
);
}
static void _Thread_queue_FIFO_extract(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread
)
{
_Chain_Extract_unprotected( &the_thread->Wait.Node.Chain );
}
static Thread_Control *_Thread_queue_FIFO_first(
- Thread_queue_Control *the_thread_queue
+ Thread_queue_Queue *queue
)
{
- Chain_Control *fifo = &the_thread_queue->Queues.Fifo;
+ Chain_Control *fifo = &queue->Heads.Fifo;
return _Chain_Is_empty( fifo ) ?
NULL : THREAD_CHAIN_NODE_TO_THREAD( _Chain_First( fifo ) );
}
static void _Thread_queue_Priority_priority_change(
- Thread_Control *the_thread,
- Priority_Control new_priority,
- Thread_queue_Control *the_thread_queue
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ Thread_queue_Queue *queue
)
{
_RBTree_Extract(
- &the_thread_queue->Queues.Priority,
+ &queue->Heads.Priority,
&the_thread->Wait.Node.RBTree
);
_RBTree_Insert(
- &the_thread_queue->Queues.Priority,
+ &queue->Heads.Priority,
&the_thread->Wait.Node.RBTree,
_Thread_queue_Compare_priority,
false
@@ -92,19 +92,19 @@ static void _Thread_queue_Priority_priority_change(
}
static void _Thread_queue_Priority_initialize(
- Thread_queue_Control *the_thread_queue
+ Thread_queue_Queue *queue
)
{
- _RBTree_Initialize_empty( &the_thread_queue->Queues.Priority );
+ _RBTree_Initialize_empty( &queue->Heads.Priority );
}
static void _Thread_queue_Priority_enqueue(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread
)
{
_RBTree_Insert(
- &the_thread_queue->Queues.Priority,
+ &queue->Heads.Priority,
&the_thread->Wait.Node.RBTree,
_Thread_queue_Compare_priority,
false
@@ -112,23 +112,23 @@ static void _Thread_queue_Priority_enqueue(
}
static void _Thread_queue_Priority_extract(
- Thread_queue_Control *the_thread_queue,
- Thread_Control *the_thread
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread
)
{
_RBTree_Extract(
- &the_thread_queue->Queues.Priority,
+ &queue->Heads.Priority,
&the_thread->Wait.Node.RBTree
);
}
static Thread_Control *_Thread_queue_Priority_first(
- Thread_queue_Control *the_thread_queue
+ Thread_queue_Queue *queue
)
{
RBTree_Node *first;
- first = _RBTree_First( &the_thread_queue->Queues.Priority, RBT_LEFT );
+ first = _RBTree_First( &queue->Heads.Priority, RBT_LEFT );
return first != NULL ? THREAD_RBTREE_NODE_TO_THREAD( first ) : NULL;
}
diff --git a/testsuites/sptests/spthreadq01/init.c b/testsuites/sptests/spthreadq01/init.c
index 07118a3..2c27057 100644
--- a/testsuites/sptests/spthreadq01/init.c
+++ b/testsuites/sptests/spthreadq01/init.c
@@ -36,10 +36,10 @@ static rtems_task Init(
_Thread_Enable_dispatch();
/* is there more to check? */
- rtems_test_assert( _Chain_Is_empty( &fifo_queue.Queues.Fifo ) );
+ rtems_test_assert( _Chain_Is_empty( &fifo_queue.Queue.Heads.Fifo ) );
rtems_test_assert( fifo_queue.operations == &_Thread_queue_Operations_FIFO );
- rtems_test_assert( _RBTree_Is_empty( &fifo_queue.Queues.Priority ) );
+ rtems_test_assert( _RBTree_Is_empty( &fifo_queue.Queue.Heads.Priority ) );
rtems_test_assert(
prio_queue.operations == &_Thread_queue_Operations_priority
);
--
1.8.4.5
More information about the devel
mailing list