summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/threadqimpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/include/rtems/score/threadqimpl.h')
-rw-r--r--cpukit/include/rtems/score/threadqimpl.h353
1 files changed, 184 insertions, 169 deletions
diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h
index 44efc1fcd0..44b2010226 100644
--- a/cpukit/include/rtems/score/threadqimpl.h
+++ b/cpukit/include/rtems/score/threadqimpl.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/**
* @file
*
@@ -11,9 +13,26 @@
* 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.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RTEMS_SCORE_THREADQIMPL_H
@@ -147,7 +166,7 @@ void _Thread_queue_Deadlock_fatal( Thread_Control *the_thread );
*
* @param[out] queue_context The thread queue context to initialize.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(
+static inline void _Thread_queue_Context_initialize(
Thread_queue_Context *queue_context
)
{
@@ -172,7 +191,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(
*
* @see _Thread_queue_Enqueue().
*/
-RTEMS_INLINE_ROUTINE void
+static inline void
_Thread_queue_Context_set_thread_state(
Thread_queue_Context *queue_context,
States_Control thread_state
@@ -189,7 +208,7 @@ _Thread_queue_Context_set_thread_state(
*
* @see _Thread_queue_Enqueue().
*/
-RTEMS_INLINE_ROUTINE void
+static inline void
_Thread_queue_Context_set_timeout_ticks(
Thread_queue_Context *queue_context,
Watchdog_Interval ticks
@@ -210,7 +229,7 @@ _Thread_queue_Context_set_timeout_ticks(
*
* @see _Thread_queue_Enqueue().
*/
-RTEMS_INLINE_ROUTINE void
+static inline void
_Thread_queue_Context_set_timeout_argument(
Thread_queue_Context *queue_context,
const void *arg,
@@ -229,7 +248,7 @@ _Thread_queue_Context_set_timeout_argument(
*
* @see _Thread_queue_Enqueue().
*/
-RTEMS_INLINE_ROUTINE void
+static inline void
_Thread_queue_Context_set_enqueue_callout(
Thread_queue_Context *queue_context,
Thread_queue_Enqueue_callout enqueue_callout
@@ -245,7 +264,7 @@ _Thread_queue_Context_set_enqueue_callout(
*
* @see _Thread_queue_Enqueue().
*/
-RTEMS_INLINE_ROUTINE void
+static inline void
_Thread_queue_Context_set_enqueue_do_nothing_extra(
Thread_queue_Context *queue_context
)
@@ -262,7 +281,7 @@ _Thread_queue_Context_set_enqueue_do_nothing_extra(
*
* @see _Thread_queue_Enqueue().
*/
-RTEMS_INLINE_ROUTINE void
+static inline void
_Thread_queue_Context_set_enqueue_timeout_ticks(
Thread_queue_Context *queue_context,
Watchdog_Interval ticks
@@ -285,7 +304,7 @@ _Thread_queue_Context_set_enqueue_timeout_ticks(
*
* @see _Thread_queue_Enqueue().
*/
-RTEMS_INLINE_ROUTINE void
+static inline void
_Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
Thread_queue_Context *queue_context,
const struct timespec *timeout,
@@ -311,7 +330,7 @@ _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
*
* @see _Thread_queue_Enqueue().
*/
-RTEMS_INLINE_ROUTINE void
+static inline void
_Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
Thread_queue_Context *queue_context,
const struct timespec *timeout,
@@ -337,7 +356,7 @@ _Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
*
* @see _Thread_queue_Enqueue().
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout(
+static inline void _Thread_queue_Context_set_deadlock_callout(
Thread_queue_Context *queue_context,
Thread_queue_Deadlock_callout deadlock_callout
)
@@ -351,7 +370,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout(
* @param[out] queue_context The thread queue context to clear the priority
* update count.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates(
+static inline void _Thread_queue_Context_clear_priority_updates(
Thread_queue_Context *queue_context
)
{
@@ -366,8 +385,8 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates(
*
* @return The priority update count of @a queue_context.
*/
-RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_save_priority_updates(
- Thread_queue_Context *queue_context
+static inline size_t _Thread_queue_Context_get_priority_updates(
+ const Thread_queue_Context *queue_context
)
{
return queue_context->Priority.update_count;
@@ -380,7 +399,7 @@ RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_save_priority_updates(
* update count of.
* @param update_count The priority update count.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Context_restore_priority_updates(
+static inline void _Thread_queue_Context_restore_priority_updates(
Thread_queue_Context *queue_context,
size_t update_count
)
@@ -396,7 +415,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_restore_priority_updates(
* array.
* @param the_thread The thread for the priority update.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Context_add_priority_update(
+static inline void _Thread_queue_Context_add_priority_update(
Thread_queue_Context *queue_context,
Thread_Control *the_thread
)
@@ -424,7 +443,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_add_priority_update(
* @param[out] queue_context The thread queue context to set the ISR level of.
* @param level The ISR level to set @a queue_context to.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level(
+static inline void _Thread_queue_Context_set_ISR_level(
Thread_queue_Context *queue_context,
ISR_Level level
)
@@ -442,7 +461,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level(
*
* @return The current processor.
*/
-RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_queue_Dispatch_disable(
+static inline Per_CPU_Control *_Thread_queue_Dispatch_disable(
Thread_queue_Context *queue_context
)
{
@@ -461,7 +480,7 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_queue_Dispatch_disable(
* objects with multiprocessing (MP) support.
*/
#if defined(RTEMS_MULTIPROCESSING)
-RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_MP_callout(
+static inline void _Thread_queue_Context_set_MP_callout(
Thread_queue_Context *queue_context,
Thread_queue_MP_callout mp_callout
)
@@ -481,7 +500,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_MP_callout(
*
* @param[out] gate The gate to close.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_close(
+static inline void _Thread_queue_Gate_close(
Thread_queue_Gate *gate
)
{
@@ -494,7 +513,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_close(
* @param[in, out] chain The chain to add the gate to.
* @param gate The gate to add to the chain.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_add(
+static inline void _Thread_queue_Gate_add(
Chain_Control *chain,
Thread_queue_Gate *gate
)
@@ -507,7 +526,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_add(
*
* @param[out] gate The gate to open.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_open(
+static inline void _Thread_queue_Gate_open(
Thread_queue_Gate *gate
)
{
@@ -521,7 +540,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_open(
*
* @param gate The gate to wait for.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_wait(
+static inline void _Thread_queue_Gate_wait(
Thread_queue_Gate *gate
)
{
@@ -536,7 +555,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_wait(
*
* @param[out] heads The thread queue heads to initialize.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize(
+static inline void _Thread_queue_Heads_initialize(
Thread_queue_Heads *heads
)
{
@@ -560,7 +579,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize(
* @param[out] queue The thread queue queue to initialize.
* @param name The name for the @a queue.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(
+static inline void _Thread_queue_Queue_initialize(
Thread_queue_Queue *queue,
const char *name
)
@@ -580,7 +599,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(
* @param lock_stats The lock statistics.
* @param[out] lock_context The interrupt lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical(
+static inline void _Thread_queue_Queue_do_acquire_critical(
Thread_queue_Queue *queue,
#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
SMP_lock_Stats *lock_stats,
@@ -616,7 +635,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical(
* @param queue The thread queue queue to release in a critical section.
* @param[out] lock_context The interrupt lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical(
+static inline void _Thread_queue_Queue_release_critical(
Thread_queue_Queue *queue,
ISR_lock_Context *lock_context
)
@@ -638,7 +657,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical(
* @param queue The thread queue queue to release.
* @param[out] lock_context The interrupt lock context to enable interrupts.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release(
+static inline void _Thread_queue_Queue_release(
Thread_queue_Queue *queue,
ISR_lock_Context *lock_context
)
@@ -678,7 +697,7 @@ void _Thread_queue_Do_acquire_critical(
ISR_lock_Context *lock_context
);
#else
-RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical(
+static inline void _Thread_queue_Do_acquire_critical(
Thread_queue_Control *the_thread_queue,
ISR_lock_Context *lock_context
)
@@ -694,7 +713,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical(
* @param the_thread_queue The thread queue control to acquire.
* @param[out] lock_context The interrupt lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(
+static inline void _Thread_queue_Acquire_critical(
Thread_queue_Control *the_thread_queue,
Thread_queue_Context *queue_context
)
@@ -717,7 +736,7 @@ void _Thread_queue_Acquire(
Thread_queue_Context *queue_context
);
#else
-RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire(
+static inline void _Thread_queue_Acquire(
Thread_queue_Control *the_thread_queue,
Thread_queue_Context *queue_context
)
@@ -736,7 +755,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire(
* @retval false The thread queue control is not the owner of the lock.
*/
#if defined(RTEMS_DEBUG)
-RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_lock_owner(
+static inline bool _Thread_queue_Is_lock_owner(
const Thread_queue_Control *the_thread_queue
)
{
@@ -760,7 +779,7 @@ void _Thread_queue_Do_release_critical(
ISR_lock_Context *lock_context
);
#else
-RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical(
+static inline void _Thread_queue_Do_release_critical(
Thread_queue_Control *the_thread_queue,
ISR_lock_Context *lock_context
)
@@ -777,7 +796,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical(
* @param the_thread_queue The thread queue control to release.
* @param[out] queue_context The thread queue context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical(
+static inline void _Thread_queue_Release_critical(
Thread_queue_Control *the_thread_queue,
Thread_queue_Context *queue_context
)
@@ -800,7 +819,7 @@ void _Thread_queue_Release(
Thread_queue_Context *queue_context
);
#else
-RTEMS_INLINE_ROUTINE void _Thread_queue_Release(
+static inline void _Thread_queue_Release(
Thread_queue_Control *the_thread_queue,
Thread_queue_Context *queue_context
)
@@ -938,13 +957,12 @@ Status_Control _Thread_queue_Enqueue_sticky(
* @param[in, out] the_thread The thread to extract.
* @param[in, out] queue_context The thread queue context.
*
- * @return Returns the unblock indicator for _Thread_queue_Unblock_critical().
- * True indicates, that this thread must be unblocked by the scheduler later in
- * _Thread_queue_Unblock_critical(), and false otherwise. In case false is
- * returned, then the thread queue enqueue procedure was interrupted. Thus it
- * will unblock itself and the thread wait information is no longer accessible,
- * since this thread may already block on another resource in an SMP
- * configuration.
+ * @return Returns the unblock indicator. True indicates, that this thread
+ * must be unblocked by the scheduler using _Thread_Remove_timer_and_unblock(),
+ * and false otherwise. In case false is returned, then the thread queue
+ * enqueue procedure was interrupted. Thus it will unblock itself and the
+ * thread wait information is no longer accessible, since this thread may
+ * already block on another resource in an SMP configuration.
*/
bool _Thread_queue_Extract_locked(
Thread_queue_Queue *queue,
@@ -954,77 +972,23 @@ bool _Thread_queue_Extract_locked(
);
/**
- * @brief Unblocks the thread which was on the thread queue before.
- *
- * The caller must be the owner of the thread queue lock. This function will
- * release the thread queue lock. Thread dispatching is disabled before the
- * thread queue lock is released and an unblock is necessary. Thread
- * dispatching is enabled once the sequence to unblock the thread is complete.
- *
- * @param unblock The unblock indicator returned by
- * _Thread_queue_Extract_locked().
- * @param queue The actual thread queue.
- * @param[in, out] the_thread The thread to extract.
- * @param[in, out] lock_context The lock context of the lock acquire.
- */
-void _Thread_queue_Unblock_critical(
- bool unblock,
- Thread_queue_Queue *queue,
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
-);
-
-/**
- * @brief Extracts the thread from the thread queue and unblocks it.
+ * @brief Resumes the extracted or surrendered thread.
*
- * The caller must be the owner of the thread queue lock. This function will
- * release the thread queue lock and restore the default thread lock. Thread
- * dispatching is disabled before the thread queue lock is released and an
- * unblock is necessary. Thread dispatching is enabled once the sequence to
- * unblock the thread is complete. This makes it possible to use the thread
- * queue lock to protect the state of objects embedding the thread queue and
- * directly enter _Thread_queue_Extract_critical() to finalize an operation in
- * case a waiting thread exists.
+ * This function makes the thread ready again. If necessary, the thread is
+ * unblocked and its thread timer removed.
*
- * @code
- * #include <rtems/score/threadqimpl.h>
+ * The thread shall have been extracted from the thread queue or surrendered by
+ * the thread queue right before the call to this function. The caller shall
+ * be the owner of the thread queue lock.
*
- * typedef struct {
- * Thread_queue_Control Queue;
- * Thread_Control *owner;
- * } Mutex;
- *
- * void _Mutex_Release( Mutex *mutex )
- * {
- * Thread_queue_Context queue_context;
- * Thread_Control *first;
- *
- * _Thread_queue_Context_initialize( &queue_context, NULL );
- * _Thread_queue_Acquire( &mutex->Queue, queue_context );
- *
- * first = _Thread_queue_First_locked( &mutex->Queue );
- * mutex->owner = first;
- *
- * if ( first != NULL ) {
- * _Thread_queue_Extract_critical(
- * &mutex->Queue.Queue,
- * mutex->Queue.operations,
- * first,
- * &queue_context
- * );
- * }
- * @endcode
- *
- * @param queue The actual thread queue.
- * @param operations The thread queue operations.
- * @param[in, out] the_thread The thread to extract.
- * @param[in, out] queue_context The thread queue context of the lock acquire.
+ * @param queue is the actual thread queue.
+ * @param[in, out] the_thread is the thread to make ready and unblock.
+ * @param[in, out] queue_context is the thread queue context.
*/
-void _Thread_queue_Extract_critical(
- Thread_queue_Queue *queue,
- const Thread_queue_Operations *operations,
- Thread_Control *the_thread,
- Thread_queue_Context *queue_context
+void _Thread_queue_Resume(
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread,
+ Thread_queue_Context *queue_context
);
/**
@@ -1039,21 +1003,27 @@ void _Thread_queue_Extract_critical(
void _Thread_queue_Extract( Thread_Control *the_thread );
/**
- * @brief Extracts the_thread from the_thread_queue.
+ * @brief Surrenders the thread queue previously owned by the thread to the
+ * first enqueued thread.
*
- * This routine extracts the_thread from the_thread_queue
- * and ensures that if there is a proxy for this task on
- * another node, it is also dealt with. A proxy is a data
- * data that is on the thread queue on the remote node and
- * acts as a proxy for the local thread. If the local thread
- * was waiting on a remote operation, then the remote side
- * of the operation must be cleaned up.
+ * The owner of the thread queue must be set to NULL by the caller.
*
- * @param[in, out] the_thread The pointer to a thread control block that
- * is to be removed
+ * This function releases the thread queue lock. In addition it performs a
+ * thread dispatch if necessary.
+ *
+ * @param[in, out] queue The actual thread queue.
+ * @param heads The thread queue heads. It must not be NULL.
+ * @param previous_owner The previous owner thread surrendering the thread
+ * queue.
+ * @param queue_context The thread queue context of the lock acquire.
+ * @param operations The thread queue operations.
*/
-void _Thread_queue_Extract_with_proxy(
- Thread_Control *the_thread
+void _Thread_queue_Surrender(
+ Thread_queue_Queue *queue,
+ Thread_queue_Heads *heads,
+ Thread_Control *previous_owner,
+ Thread_queue_Context *queue_context,
+ const Thread_queue_Operations *operations
);
/**
@@ -1067,15 +1037,34 @@ void _Thread_queue_Extract_with_proxy(
*
* @param[in, out] queue The actual thread queue.
* @param heads The thread queue heads. It must not be NULL.
- * @param previous_owner The previous owner thread surrendering the thread
- * queue.
* @param queue_context The thread queue context of the lock acquire.
* @param operations The thread queue operations.
*/
-void _Thread_queue_Surrender(
+void _Thread_queue_Surrender_no_priority(
Thread_queue_Queue *queue,
Thread_queue_Heads *heads,
- Thread_Control *previous_owner,
+ Thread_queue_Context *queue_context,
+ const Thread_queue_Operations *operations
+);
+
+/**
+ * @brief Surrenders the thread queue previously owned by the thread to the
+ * first enqueued thread.
+ *
+ * The owner of the thread queue must be set to NULL by the caller.
+ *
+ * This function releases the thread queue lock. In addition it performs a
+ * thread dispatch if necessary.
+ *
+ * @param[in, out] queue The actual thread queue.
+ * @param heads The thread queue heads. It must not be NULL.
+ * @param queue_context The thread queue context of the lock acquire.
+ * @param operations The thread queue operations.
+ */
+Status_Control _Thread_queue_Surrender_priority_ceiling(
+ Thread_queue_Queue *queue,
+ Thread_Control *executing,
+ Priority_Node *ceiling_priority,
Thread_queue_Context *queue_context,
const Thread_queue_Operations *operations
);
@@ -1118,7 +1107,7 @@ void _Thread_queue_Surrender_sticky(
* @retval true @a queue is empty.
* @retval false @a queue is not empty.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_empty(
+static inline bool _Thread_queue_Is_empty(
const Thread_queue_Queue *queue
)
{
@@ -1129,34 +1118,6 @@ RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_empty(
* @brief Returns the first thread on the thread queue if it exists, otherwise
* @c NULL.
*
- * The caller must be the owner of the thread queue lock. The thread queue
- * lock is not released.
- *
- * @param the_thread_queue The thread queue.
- * @param operations The thread queue operations.
- *
-* @retval first The first thread on the thread queue according to the enqueue
- * order.
- * @retval NULL No thread is present on the thread queue.
- */
-RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked(
- Thread_queue_Control *the_thread_queue,
- const Thread_queue_Operations *operations
-)
-{
- Thread_queue_Heads *heads = the_thread_queue->Queue.heads;
-
- if ( heads != NULL ) {
- return ( *operations->first )( heads );
- } else {
- return NULL;
- }
-}
-
-/**
- * @brief Returns the first thread on the thread queue if it exists, otherwise
- * @c NULL.
- *
* @param the_thread_queue The thread queue.
*
* @retval first The first thread on the thread queue according to the enqueue
@@ -1344,7 +1305,7 @@ void _Thread_queue_Initialize(
*
* @param[out] the_thread_queue The thread queue to destroy.
*/
-RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(
+static inline void _Thread_queue_Destroy(
Thread_queue_Control *the_thread_queue
)
{
@@ -1354,18 +1315,23 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(
#endif
}
+#if defined(RTEMS_MULTIPROCESSING)
/**
* @brief Does nothing.
*
* @param the_proxy This parameter is unused.
* @param mp_id This parameter is unused.
*/
-#if defined(RTEMS_MULTIPROCESSING)
void _Thread_queue_MP_callout_do_nothing(
Thread_Control *the_proxy,
Objects_Id mp_id
);
+bool _Thread_queue_MP_set_callout(
+ Thread_Control *the_thread,
+ const Thread_queue_Context *queue_context
+);
+
/**
* @brief Unblocks the proxy of the thread.
*
@@ -1379,28 +1345,56 @@ void _Thread_queue_Unblock_proxy(
#endif
/**
- * @brief Acquires the thread queue path in a critical section.
+ * @brief This is a status code to indicate if a deadlock was detected or not.
+ */
+typedef enum {
+ /**
+ * @brief The operation did not detect a deadlock.
+ */
+ THREAD_QUEUE_NO_DEADLOCK,
+
+ /**
+ * @brief The operation detected a deadlock.
+ */
+ THREAD_QUEUE_DEADLOCK_DETECTED
+} Thread_queue_Deadlock_status;
+
+#if defined(RTEMS_SMP)
+/**
+ * @brief Acquires the thread queue path.
*
- * @param queue The thread queue queue.
- * @param the_thread The thread for the operation.
- * @param queue_context The thread queue context.
+ * The caller must own the thread queue lock.
*
- * @retval true The operation was successful.
- * @retval false The operation failed.
+ * An acquired thread queue path must be released by calling
+ * _Thread_queue_Path_release() with the same thread queue context.
+ *
+ * @param queue is the thread queue queue.
+ *
+ * @param the_thread is the thread for the operation.
+ *
+ * @param queue_context is the thread queue context.
+ *
+ * @retval THREAD_QUEUE_NO_DEADLOCK No deadlock was detected.
+ *
+ * @retval THREAD_QUEUE_DEADLOCK_DETECTED A deadlock was detected while
+ * acquiring the thread queue path. The thread queue path must still be
+ * released by _Thread_queue_Path_release() in this case.
*/
-#if defined(RTEMS_SMP)
-bool _Thread_queue_Path_acquire_critical(
+Thread_queue_Deadlock_status _Thread_queue_Path_acquire(
Thread_queue_Queue *queue,
Thread_Control *the_thread,
Thread_queue_Context *queue_context
);
/**
- * @brief Releases the thread queue path in a critical section.
+ * @brief Releases the thread queue path.
*
- * @param queue_context The thread queue context.
+ * The caller must have acquired the thread queue path with a corresponding
+ * _Thread_queue_Path_acquire().
+ *
+ * @param queue_context is the thread queue context.
*/
-void _Thread_queue_Path_release_critical(
+void _Thread_queue_Path_release(
Thread_queue_Context *queue_context
);
#endif
@@ -1436,12 +1430,33 @@ typedef struct {
Wait_queue.Queue \
)
+/**
+ * @brief The default thread queue operations are used when a thread is not
+ * enqueued on a thread queue.
+ *
+ * The default operations may be used by _Thread_Priority_apply() and
+ * _Thread_Continue() if the thread is not enqueued on a thread queue. The
+ * default operations do nothing.
+ */
extern const Thread_queue_Operations _Thread_queue_Operations_default;
+/**
+ * @brief The FIFO thread queue operations are used when a thread is enqueued
+ * on a thread queue and provide FIFO ordering of enqueued threads.
+ */
extern const Thread_queue_Operations _Thread_queue_Operations_FIFO;
+/**
+ * @brief The FIFO thread queue operations are used when a thread is enqueued
+ * on a thread queue and provide priority ordering of enqueued threads.
+ */
extern const Thread_queue_Operations _Thread_queue_Operations_priority;
+/**
+ * @brief The FIFO thread queue operations are used when a thread is enqueued
+ * on a thread queue and provide priority ordering of enqueued threads with
+ * support for priority inheritance.
+ */
extern const Thread_queue_Operations _Thread_queue_Operations_priority_inherit;
/**