summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/include/rtems/score')
-rw-r--r--cpukit/score/include/rtems/score/coremsgimpl.h3
-rw-r--r--cpukit/score/include/rtems/score/coresemimpl.h6
-rw-r--r--cpukit/score/include/rtems/score/thread.h2
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h4
-rw-r--r--cpukit/score/include/rtems/score/threadq.h79
-rw-r--r--cpukit/score/include/rtems/score/threadqimpl.h114
6 files changed, 128 insertions, 80 deletions
diff --git a/cpukit/score/include/rtems/score/coremsgimpl.h b/cpukit/score/include/rtems/score/coremsgimpl.h
index 51b5f3780f..382ce92815 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 da57ad1dd4..a6a30bcc15 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 9d8382cf88..f9ba3a030e 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 0dfdb8a263..4dcef0b7d8 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 06ea36a905..599a81c23c 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 b8982ecf1f..330b18c5bf 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 );
}
/**