diff options
Diffstat (limited to 'cpukit/score/include/rtems/score/thread.h')
-rw-r--r-- | cpukit/score/include/rtems/score/thread.h | 171 |
1 files changed, 101 insertions, 70 deletions
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index 72e011ccff..39fcb1707f 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -249,56 +249,6 @@ typedef struct { } Thread_Start_information; /** - * @brief Priority change handler. - * - * @param[in] the_thread The thread. - * @param[in] new_priority The new priority value. - * @param[in] context The handler context. - * - * @see _Thread_Priority_set_change_handler(). - */ -typedef void (*Thread_Priority_change_handler)( - Thread_Control *the_thread, - Priority_Control new_priority, - void *context -); - -/** - * @brief Thread priority control. - */ -typedef struct { - /** - * @brief Generation of the current priority value. - * - * It is used in _Thread_Change_priority() to serialize the update of - * priority related data structures. - */ - uint32_t generation; - - /** - * @brief Priority change handler. - * - * Called by _Thread_Change_priority() to notify a thread about a priority - * change. In case this thread waits currently for a resource the handler - * may adjust its data structures according to the new priority value. This - * handler must not be NULL, instead the default handler - * _Thread_Priority_change_do_nothing() should be used in case nothing needs - * to be done during a priority change. - * - * @see _Thread_Priority_set_change_handler() and - * _Thread_Priority_restore_default_change_handler(). - */ - Thread_Priority_change_handler change_handler; - - /** - * @brief Context for priority change handler. - * - * @see _Thread_Priority_set_change_handler(). - */ - void *change_handler_context; -} Thread_Priority_control; - -/** * @brief Union type to hold a pointer to an immutable or a mutable object. * * The main purpose is to enable passing of pointers to read-only send buffers @@ -324,11 +274,8 @@ typedef union { * * The mutually exclusive wait state flags are * - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK, - * - @ref THREAD_WAIT_STATE_BLOCKED, - * - @ref THREAD_WAIT_STATE_SATISFIED, - * - @ref THREAD_WAIT_STATE_TIMEOUT, - * - @ref THREAD_WAIT_STATE_INTERRUPT_SATISFIED, and - * - @ref THREAD_WAIT_STATE_INTERRUPT_TIMEOUT, + * - @ref THREAD_WAIT_STATE_BLOCKED, and + * - @ref THREAD_WAIT_STATE_READY_AGAIN. */ typedef unsigned int Thread_Wait_flags; @@ -339,6 +286,21 @@ typedef unsigned int Thread_Wait_flags; * blocked and to return information to it. */ typedef struct { + /** + * @brief Node for thread queues. + */ + union { + /** + * @brief A node for chains. + */ + Chain_Node Chain; + + /** + * @brief A node for red-black trees. + */ + RBTree_Node RBTree; + } Node; + /** This field is the Id of the object this thread is waiting upon. */ Objects_Id id; /** This field is used to return an integer while when blocked. */ @@ -357,7 +319,19 @@ typedef struct { */ uint32_t return_code; - /** This field points to the thread queue on which this thread is blocked. */ + /** + * @brief Code to set the timeout return code in _Thread_Timeout(). + */ + uint32_t timeout_code; + + /** + * @brief The current thread queue. + * + * In case this field is @c NULL, then the thread is not blocked on a thread + * queue. This field is protected by the thread lock. + * + * @see _Thread_Lock_set() and _Thread_Wait_set_queue(). + */ Thread_queue_Control *queue; /** @@ -369,6 +343,15 @@ typedef struct { #else Thread_Wait_flags flags; #endif + + /** + * @brief The current thread queue operations. + * + * This field is protected by the thread lock. + * + * @see _Thread_Lock_set() and _Thread_Wait_set_operations(). + */ + const Thread_queue_Operations *operations; } Thread_Wait_information; /** @@ -381,19 +364,43 @@ typedef struct { typedef struct { /** This field is the object management structure for each proxy. */ Objects_Control Object; - /** This field is used to enqueue the thread on RBTrees. */ - RBTree_Node RBNode; /** This field is the current execution state of this proxy. */ States_Control current_state; - /** This field is the current priority state of this proxy. */ + + /** + * @brief This field is the current priority state of this thread. + * + * Writes to this field are only allowed in _Thread_Initialize() or via + * _Thread_Change_priority(). + */ Priority_Control current_priority; - /** This field is the base priority of this proxy. */ + + /** + * @brief This field is the base priority of this thread. + * + * Writes to this field are only allowed in _Thread_Initialize() or via + * _Thread_Change_priority(). + */ Priority_Control real_priority; /** - * @brief Thread priority control. + * @brief Generation of the current priority value. + * + * It is used in _Thread_Change_priority() to serialize the update of + * priority related data structures. + */ + uint32_t priority_generation; + + /** + * @brief Hints if a priority restore is necessary once the resource count + * changes from one to zero. + * + * This is an optimization to speed up the mutex surrender sequence in case + * no attempt to change the priority was made during the mutex ownership. On + * SMP configurations atomic fences must synchronize writes to + * Thread_Control::priority_restore_hint and Thread_Control::resource_count. */ - Thread_Priority_control Priority; + bool priority_restore_hint; /** This field is the number of mutexes currently held by this proxy. */ uint32_t resource_count; @@ -636,8 +643,8 @@ typedef struct { * * The thread lock protects the following thread variables * - Thread_Control::current_priority, - * - Thread_Control::Priority::change_handler, and - * - Thread_Control::Priority::change_handler_context. + * - Thread_Control::Wait::queue, and + * - Thread_Control::Wait::operations. * * @see _Thread_Lock_acquire(), _Thread_Lock_release(), _Thread_Lock_set() and * _Thread_Lock_restore_default(). @@ -667,19 +674,43 @@ typedef struct { struct Thread_Control_struct { /** This field is the object management structure for each thread. */ Objects_Control Object; - /** This field is used to enqueue the thread on RBTrees. */ - RBTree_Node RBNode; /** This field is the current execution state of this thread. */ States_Control current_state; - /** This field is the current priority state of this thread. */ + + /** + * @brief This field is the current priority state of this thread. + * + * Writes to this field are only allowed in _Thread_Initialize() or via + * _Thread_Change_priority(). + */ Priority_Control current_priority; - /** This field is the base priority of this thread. */ + + /** + * @brief This field is the base priority of this thread. + * + * Writes to this field are only allowed in _Thread_Initialize() or via + * _Thread_Change_priority(). + */ Priority_Control real_priority; /** - * @brief Thread priority control. + * @brief Generation of the current priority value. + * + * It is used in _Thread_Change_priority() to serialize the update of + * priority related data structures. + */ + uint32_t priority_generation; + + /** + * @brief Hints if a priority restore is necessary once the resource count + * changes from one to zero. + * + * This is an optimization to speed up the mutex surrender sequence in case + * no attempt to change the priority was made during the mutex ownership. On + * SMP configurations atomic fences must synchronize writes to + * Thread_Control::priority_restore_hint and Thread_Control::resource_count. */ - Thread_Priority_control Priority; + bool priority_restore_hint; /** This field is the number of mutexes currently held by this thread. */ uint32_t resource_count; |