summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/threadimpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/include/rtems/score/threadimpl.h')
-rw-r--r--cpukit/include/rtems/score/threadimpl.h396
1 files changed, 225 insertions, 171 deletions
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index a983975568..36ddb785e9 100644
--- a/cpukit/include/rtems/score/threadimpl.h
+++ b/cpukit/include/rtems/score/threadimpl.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/**
* @file
*
@@ -11,11 +13,28 @@
* COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
- * Copyright (c) 2014, 2017 embedded brains GmbH.
- *
- * 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.
+ * Copyright (C) 2014, 2017 embedded brains GmbH & Co. KG
+ *
+ * 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_THREADIMPL_H
@@ -176,19 +195,9 @@ typedef struct {
Priority_Control priority;
/**
- * @brief The thread's budget algorithm.
+ * @brief The thread's initial CPU budget operations.
*/
- Thread_CPU_budget_algorithms budget_algorithm;
-
- /**
- * @brief The thread's initial budget callout.
- */
- Thread_CPU_budget_algorithm_callout budget_callout;
-
- /**
- * @brief The thread's initial CPU time budget.
- */
- uint32_t cpu_time_budget;
+ const Thread_CPU_budget_operations *cpu_budget_operations;
/**
* @brief 32-bit unsigned integer name of the object for the thread.
@@ -371,15 +380,23 @@ RTEMS_NO_RETURN void _Thread_Exit(
);
/**
- * @brief Joins the currently executing thread with the given thread to wait
- * for.
+ * @brief Joins the currently executing thread with the thread.
+ *
+ * @param[in, out] the_thread is the thread to join.
+ *
+ * @param waiting_for_join is the thread state for the currently executing
+ * thread.
*
- * @param[in, out] the_thread The thread to wait for.
- * @param waiting_for_join The states control for the join.
- * @param[in, out] executing The currently executing thread.
- * @param queue_context The thread queue context.
+ * @param[in, out] executing is the currently executing thread.
+ *
+ * @param queue_context[in, out] is the thread queue context. The caller shall
+ * have acquired the thread state lock using the thread queue context.
+ *
+ * @retval STATUS_SUCCESSFUL The operation was successful.
+ *
+ * @retval STATUS_DEADLOCK A deadlock occurred.
*/
-void _Thread_Join(
+Status_Control _Thread_Join(
Thread_Control *the_thread,
States_Control waiting_for_join,
Thread_Control *executing,
@@ -387,23 +404,38 @@ void _Thread_Join(
);
/**
+ * @brief Indicates the resulting state of _Thread_Cancel().
+ */
+typedef enum {
+ /**
+ * @brief Indicates that the thread cancel operation is done.
+ */
+ THREAD_CANCEL_DONE,
+
+ /**
+ * @brief Indicates that the thread cancel operation is in progress.
+ *
+ * The cancelled thread is terminating. It may be joined.
+ */
+ THREAD_CANCEL_IN_PROGRESS
+} Thread_Cancel_state;
+
+/**
* @brief Cancels the thread.
*
- * @param[in, out] the_thread The thread to cancel.
- * @param executing The currently executing thread.
- * @param exit_value The exit value for the thread.
+ * @param[in, out] the_thread is the thread to cancel.
+
+ * @param[in, out] executing is the currently executing thread.
+
+ * @param[in, out] life_states_to_clear is the set of thread life states to
+ * clear for the thread to cancel.
*/
-void _Thread_Cancel(
- Thread_Control *the_thread,
- Thread_Control *executing,
- void *exit_value
+Thread_Cancel_state _Thread_Cancel(
+ Thread_Control *the_thread,
+ Thread_Control *executing,
+ Thread_Life_state life_states_to_clear
);
-typedef struct {
- Thread_queue_Context Base;
- Thread_Control *cancel;
-} Thread_Close_context;
-
/**
* @brief Closes the thread.
*
@@ -411,14 +443,21 @@ typedef struct {
* case the executing thread is not terminated, then this function waits until
* the terminating thread reached the zombie state.
*
- * @param the_thread The thread to close.
- * @param executing The currently executing thread.
- * @param[in, out] context The thread close context.
+ * @param the_thread is the thread to close.
+ *
+ * @param[in, out] executing is the currently executing thread.
+ *
+ * @param[in, out] queue_context is the thread queue context. The caller shall
+ * have disabled interrupts using the thread queue context.
+ *
+ * @retval STATUS_SUCCESSFUL The operation was successful.
+ *
+ * @retval STATUS_DEADLOCK A deadlock occurred.
*/
-void _Thread_Close(
+Status_Control _Thread_Close(
Thread_Control *the_thread,
Thread_Control *executing,
- Thread_Close_context *context
+ Thread_queue_Context *queue_context
);
/**
@@ -429,7 +468,7 @@ void _Thread_Close(
* @retval true The thread is currently in the ready state.
* @retval false The thread is currently not ready.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_ready( const Thread_Control *the_thread )
+static inline bool _Thread_Is_ready( const Thread_Control *the_thread )
{
return _States_Is_ready( the_thread->current_state );
}
@@ -556,7 +595,7 @@ void _Thread_Handler( void );
* @param the_thread The thread to acquire the lock context.
* @param lock_context The lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_State_acquire_critical(
+static inline void _Thread_State_acquire_critical(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -570,7 +609,7 @@ RTEMS_INLINE_ROUTINE void _Thread_State_acquire_critical(
* @param the_thread The thread to acquire the lock context.
* @param lock_context The lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_State_acquire(
+static inline void _Thread_State_acquire(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -587,7 +626,7 @@ RTEMS_INLINE_ROUTINE void _Thread_State_acquire(
*
* @return The currently executing thread.
*/
-RTEMS_INLINE_ROUTINE Thread_Control *_Thread_State_acquire_for_executing(
+static inline Thread_Control *_Thread_State_acquire_for_executing(
ISR_lock_Context *lock_context
)
{
@@ -606,7 +645,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_State_acquire_for_executing(
* @param the_thread The thread to release the lock context.
* @param lock_context The lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_State_release_critical(
+static inline void _Thread_State_release_critical(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -620,7 +659,7 @@ RTEMS_INLINE_ROUTINE void _Thread_State_release_critical(
* @param[in, out] the_thread The thread to release the lock context.
* @param[out] lock_context The lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_State_release(
+static inline void _Thread_State_release(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -638,7 +677,7 @@ RTEMS_INLINE_ROUTINE void _Thread_State_release(
* @retval false The thread is not owner of the lock of the join queue.
*/
#if defined(RTEMS_DEBUG)
-RTEMS_INLINE_ROUTINE bool _Thread_State_is_owner(
+static inline bool _Thread_State_is_owner(
const Thread_Control *the_thread
)
{
@@ -752,7 +791,7 @@ void _Thread_Priority_changed(
*
* @see _Thread_Wait_acquire().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Priority_change(
+static inline void _Thread_Priority_change(
Thread_Control *the_thread,
Priority_Node *priority_node,
Priority_Control new_priority,
@@ -769,6 +808,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Priority_change(
);
}
+#if defined(RTEMS_SMP)
/**
* @brief Replaces the victim priority node with the replacement priority node
* in the corresponding thread priority aggregation.
@@ -786,6 +826,7 @@ void _Thread_Priority_replace(
Priority_Node *victim_node,
Priority_Node *replacement_node
);
+#endif
/**
* @brief Updates the priority of all threads in the set
@@ -800,17 +841,29 @@ void _Thread_Priority_replace(
*/
void _Thread_Priority_update( Thread_queue_Context *queue_context );
+#if defined(RTEMS_SMP)
/**
- * @brief Updates the priority of the thread and changes it sticky level.
+ * @brief Updates the priority of the thread and makes its home scheduler node
+ * sticky.
*
- * @param the_thread The thread.
- * @param sticky_level_change The new value for the sticky level.
+ * @param the_thread is the thread to work on.
*/
-#if defined(RTEMS_SMP)
-void _Thread_Priority_and_sticky_update(
- Thread_Control *the_thread,
- int sticky_level_change
-);
+void _Thread_Priority_update_and_make_sticky( Thread_Control *the_thread );
+
+/**
+ * @brief Updates the priority of the thread and cleans the sticky property of
+ * its home scheduler node.
+ *
+ * @param the_thread is the thread to work on.
+ */
+void _Thread_Priority_update_and_clean_sticky( Thread_Control *the_thread );
+
+/**
+ * @brief Updates the priority of the thread.
+ *
+ * @param the_thread is the thread to update the priority.
+ */
+void _Thread_Priority_update_ignore_sticky( Thread_Control *the_thread );
#endif
/**
@@ -823,7 +876,7 @@ void _Thread_Priority_and_sticky_update(
* @retval true The left priority is less in the intuitive sense.
* @retval false The left priority is greater or equal in the intuitive sense.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Priority_less_than(
+static inline bool _Thread_Priority_less_than(
Priority_Control left,
Priority_Control right
)
@@ -840,7 +893,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Priority_less_than(
*
* @return The highest priority in the intuitive sense of priority.
*/
-RTEMS_INLINE_ROUTINE Priority_Control _Thread_Priority_highest(
+static inline Priority_Control _Thread_Priority_highest(
Priority_Control left,
Priority_Control right
)
@@ -860,7 +913,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Priority_highest(
* @return Returns the thread object information associated with the API of the
* object identifier.
*/
-RTEMS_INLINE_ROUTINE Objects_Information *_Thread_Get_objects_information_by_id(
+static inline Objects_Information *_Thread_Get_objects_information_by_id(
Objects_Id id
)
{
@@ -888,7 +941,7 @@ RTEMS_INLINE_ROUTINE Objects_Information *_Thread_Get_objects_information_by_id(
*
* @return Returns the thread object information of the thread.
*/
-RTEMS_INLINE_ROUTINE Thread_Information *_Thread_Get_objects_information(
+static inline Thread_Information *_Thread_Get_objects_information(
Thread_Control *the_thread
)
{
@@ -932,7 +985,7 @@ Objects_Id _Thread_Self_id( void );
*
* @return The cpu of the thread's scheduler.
*/
-RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU(
+static inline Per_CPU_Control *_Thread_Get_CPU(
const Thread_Control *thread
)
{
@@ -951,7 +1004,7 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU(
* @param[out] thread The thread.
* @param cpu The cpu to set.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Set_CPU(
+static inline void _Thread_Set_CPU(
Thread_Control *thread,
Per_CPU_Control *cpu
)
@@ -975,7 +1028,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Set_CPU(
* @retval true @a the_thread is the currently executing one.
* @retval false @a the_thread is not the currently executing one.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_executing (
+static inline bool _Thread_Is_executing (
const Thread_Control *the_thread
)
{
@@ -995,7 +1048,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_executing (
* @retval true @a the_thread is the currently executing one.
* @retval false @a the_thread is not the currently executing one.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_executing_on_a_processor(
+static inline bool _Thread_Is_executing_on_a_processor(
const Thread_Control *the_thread
)
{
@@ -1014,7 +1067,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_executing_on_a_processor(
* @retval true @a the_thread is the heir.
* @retval false @a the_thread is not the heir.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_heir (
+static inline bool _Thread_Is_heir (
const Thread_Control *the_thread
)
{
@@ -1030,7 +1083,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_heir (
*
* @param[in, out] the_thread The thread to unblock.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Unblock (
+static inline void _Thread_Unblock (
Thread_Control *the_thread
)
{
@@ -1053,7 +1106,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Unblock (
* loaded in the floating point unit.
*/
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
-RTEMS_INLINE_ROUTINE bool _Thread_Is_allocated_fp (
+static inline bool _Thread_Is_allocated_fp (
const Thread_Control *the_thread
)
{
@@ -1079,7 +1132,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_allocated_fp (
*
* @param executing The currently executing thread.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Save_fp( Thread_Control *executing )
+static inline void _Thread_Save_fp( Thread_Control *executing )
{
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
#if ( CPU_USE_DEFERRED_FP_SWITCH != TRUE )
@@ -1094,7 +1147,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Save_fp( Thread_Control *executing )
*
* @param executing The currently executing thread.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Restore_fp( Thread_Control *executing )
+static inline void _Thread_Restore_fp( Thread_Control *executing )
{
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
@@ -1119,7 +1172,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Restore_fp( Thread_Control *executing )
* point context is now longer associated with an active thread.
*/
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
-RTEMS_INLINE_ROUTINE void _Thread_Deallocate_fp( void )
+static inline void _Thread_Deallocate_fp( void )
{
_Thread_Allocated_fp = NULL;
}
@@ -1134,7 +1187,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Deallocate_fp( void )
* @retval true Dispatching is disabled.
* @retval false Dispatching is enabled.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_context_switch_necessary( void )
+static inline bool _Thread_Is_context_switch_necessary( void )
{
return ( _Thread_Dispatch_necessary );
}
@@ -1144,7 +1197,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_context_switch_necessary( void )
*
* @return The maximum number of internal threads.
*/
-RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_maximum_internal_threads(void)
+static inline uint32_t _Thread_Get_maximum_internal_threads(void)
{
/* Idle threads */
uint32_t maximum_internal_threads =
@@ -1166,7 +1219,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_maximum_internal_threads(void)
* @retval pointer Pointer to the allocated Thread_Control.
* @retval NULL The operation failed.
*/
-RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Internal_allocate( void )
+static inline Thread_Control *_Thread_Internal_allocate( void )
{
return (Thread_Control *)
_Objects_Allocate_unprotected( &_Thread_Information.Objects );
@@ -1185,7 +1238,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Internal_allocate( void )
* @see _Thread_Dispatch(), _Thread_Start_multitasking() and
* _Thread_Dispatch_update_heir().
*/
-RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing(
+static inline Thread_Control *_Thread_Get_heir_and_make_it_executing(
Per_CPU_Control *cpu_self
)
{
@@ -1205,7 +1258,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing(
* used.
* @param cpu The cpu.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Update_CPU_time_used(
+static inline void _Thread_Update_CPU_time_used(
Thread_Control *the_thread,
Per_CPU_Control *cpu
)
@@ -1227,7 +1280,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Update_CPU_time_used(
* @param heir The new heir for @a cpu_for_heir.
*/
#if defined( RTEMS_SMP )
-RTEMS_INLINE_ROUTINE void _Thread_Dispatch_update_heir(
+static inline void _Thread_Dispatch_update_heir(
Per_CPU_Control *cpu_self,
Per_CPU_Control *cpu_for_heir,
Thread_Control *heir
@@ -1284,7 +1337,7 @@ Timestamp_Control _Thread_Get_CPU_time_used_after_last_reset(
*
* @param[out] action_control The action control to initialize.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize(
+static inline void _Thread_Action_control_initialize(
Thread_Action_control *action_control
)
{
@@ -1296,7 +1349,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize(
*
* @param[out] action The Thread_Action to initialize.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Action_initialize(
+static inline void _Thread_Action_initialize(
Thread_Action *action
)
{
@@ -1315,7 +1368,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Action_initialize(
*
* @param handler is the handler for the action.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action(
+static inline void _Thread_Add_post_switch_action(
Thread_Control *the_thread,
Thread_Action *action,
Thread_Action_handler handler
@@ -1348,7 +1401,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action(
*
* @param[in, out] action is the action to add.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Append_post_switch_action(
+static inline void _Thread_Append_post_switch_action(
Thread_Control *the_thread,
Thread_Action *action
)
@@ -1370,7 +1423,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Append_post_switch_action(
* @retval true @a life_state is restarting.
* @retval false @a life_state is not restarting.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_life_restarting(
+static inline bool _Thread_Is_life_restarting(
Thread_Life_state life_state
)
{
@@ -1385,7 +1438,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_restarting(
* @retval true @a life_state is terminating.
* @retval false @a life_state is not terminating.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_life_terminating(
+static inline bool _Thread_Is_life_terminating(
Thread_Life_state life_state
)
{
@@ -1400,7 +1453,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_terminating(
* @retval true @a life_state allows life change.
* @retval false @a life_state does not allow life change.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_life_change_allowed(
+static inline bool _Thread_Is_life_change_allowed(
Thread_Life_state life_state
)
{
@@ -1416,7 +1469,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_change_allowed(
* @retval true @a life_state is life changing.
* @retval false @a life_state is not life changing.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing(
+static inline bool _Thread_Is_life_changing(
Thread_Life_state life_state
)
{
@@ -1432,7 +1485,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing(
* @retval true @a life_state is joinable.
* @retval false @a life_state is not joinable.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Is_joinable(
+static inline bool _Thread_Is_joinable(
const Thread_Control *the_thread
)
{
@@ -1445,7 +1498,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_joinable(
*
* @param[in, out] the_thread The thread to increase the resource count of.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Resource_count_increment(
+static inline void _Thread_Resource_count_increment(
Thread_Control *the_thread
)
{
@@ -1461,7 +1514,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Resource_count_increment(
*
* @param[in, out] the_thread The thread to decrement the resource count of.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Resource_count_decrement(
+static inline void _Thread_Resource_count_decrement(
Thread_Control *the_thread
)
{
@@ -1484,7 +1537,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Resource_count_decrement(
* @retval true The thread owns resources.
* @retval false The thread does not own resources.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources(
+static inline bool _Thread_Owns_resources(
const Thread_Control *the_thread
)
{
@@ -1492,32 +1545,6 @@ RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources(
}
#endif
-#if defined(RTEMS_SMP)
-/**
- * @brief Cancels the thread's need for help.
- *
- * @param the_thread The thread to cancel the help request of.
- * @param cpu The cpu to get the lock context of in order to
- * cancel the help request.
- */
-RTEMS_INLINE_ROUTINE void _Thread_Scheduler_cancel_need_for_help(
- Thread_Control *the_thread,
- Per_CPU_Control *cpu
-)
-{
- ISR_lock_Context lock_context;
-
- _Per_CPU_Acquire( cpu, &lock_context );
-
- if ( !_Chain_Is_node_off_chain( &the_thread->Scheduler.Help_node ) ) {
- _Chain_Extract_unprotected( &the_thread->Scheduler.Help_node );
- _Chain_Set_off_chain( &the_thread->Scheduler.Help_node );
- }
-
- _Per_CPU_Release( cpu, &lock_context );
-}
-#endif
-
/**
* @brief Gets the home scheduler of the thread.
*
@@ -1525,7 +1552,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_cancel_need_for_help(
*
* @return The thread's home scheduler.
*/
-RTEMS_INLINE_ROUTINE const Scheduler_Control *_Thread_Scheduler_get_home(
+static inline const Scheduler_Control *_Thread_Scheduler_get_home(
const Thread_Control *the_thread
)
{
@@ -1544,7 +1571,7 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Thread_Scheduler_get_home(
*
* @return The thread's home node.
*/
-RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_home_node(
+static inline Scheduler_Node *_Thread_Scheduler_get_home_node(
const Thread_Control *the_thread
)
{
@@ -1566,17 +1593,17 @@ RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_home_node(
*
* @return The scheduler node with the specified index.
*/
-RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_node_by_index(
+static inline Scheduler_Node *_Thread_Scheduler_get_node_by_index(
const Thread_Control *the_thread,
size_t scheduler_index
)
{
+ _Assert( scheduler_index < _Scheduler_Count );
#if defined(RTEMS_SMP)
return (Scheduler_Node *)
( (uintptr_t) the_thread->Scheduler.nodes
+ scheduler_index * _Scheduler_Node_size );
#else
- _Assert( scheduler_index == 0 );
(void) scheduler_index;
return the_thread->Scheduler.nodes;
#endif
@@ -1589,7 +1616,7 @@ RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_node_by_index(
* @param the_thread The thread to acquire the lock context.
* @param lock_context The lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Scheduler_acquire_critical(
+static inline void _Thread_Scheduler_acquire_critical(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -1603,7 +1630,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_acquire_critical(
* @param the_thread The thread to release the lock context.
* @param lock_context The lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Scheduler_release_critical(
+static inline void _Thread_Scheduler_release_critical(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -1625,7 +1652,7 @@ void _Thread_Scheduler_process_requests( Thread_Control *the_thread );
* @param[in, out] scheduler_node The scheduler node for the request.
* @param request The request to add.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_request(
+static inline void _Thread_Scheduler_add_request(
Thread_Control *the_thread,
Scheduler_Node *scheduler_node,
Scheduler_Node_request request
@@ -1668,7 +1695,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_request(
* @param[in, out] the_thread The thread to add the wait node to.
* @param scheduler_node The scheduler node which provides the wait node.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_wait_node(
+static inline void _Thread_Scheduler_add_wait_node(
Thread_Control *the_thread,
Scheduler_Node *scheduler_node
)
@@ -1691,7 +1718,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_wait_node(
* @param the_thread The thread to add the request to remove a wait node.
* @param scheduler_node The scheduler node to remove a wait node from.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Scheduler_remove_wait_node(
+static inline void _Thread_Scheduler_remove_wait_node(
Thread_Control *the_thread,
Scheduler_Node *scheduler_node
)
@@ -1716,7 +1743,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_remove_wait_node(
*
* @return The priority of the thread.
*/
-RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_priority(
+static inline Priority_Control _Thread_Get_priority(
const Thread_Control *the_thread
)
{
@@ -1733,7 +1760,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_priority(
*
* @return The unmapped priority of the thread.
*/
-RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_priority(
+static inline Priority_Control _Thread_Get_unmapped_priority(
const Thread_Control *the_thread
)
{
@@ -1747,7 +1774,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_priority(
*
* @return The unmapped real priority of the thread.
*/
-RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_real_priority(
+static inline Priority_Control _Thread_Get_unmapped_real_priority(
const Thread_Control *the_thread
)
{
@@ -1764,7 +1791,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_real_priority(
*
* @see _Thread_Wait_release_default_critical().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default_critical(
+static inline void _Thread_Wait_acquire_default_critical(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -1783,7 +1810,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default_critical(
*
* @see _Thread_Wait_release_default().
*/
-RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Wait_acquire_default_for_executing(
+static inline Thread_Control *_Thread_Wait_acquire_default_for_executing(
ISR_lock_Context *lock_context
)
{
@@ -1805,7 +1832,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Wait_acquire_default_for_executing(
*
* @see _Thread_Wait_release_default().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default(
+static inline void _Thread_Wait_acquire_default(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -1824,7 +1851,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default(
* @param lock_context The lock context used for the corresponding lock
* acquire.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default_critical(
+static inline void _Thread_Wait_release_default_critical(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -1840,7 +1867,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default_critical(
* @param[out] lock_context The lock context used for the corresponding lock
* acquire.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default(
+static inline void _Thread_Wait_release_default(
Thread_Control *the_thread,
ISR_lock_Context *lock_context
)
@@ -1859,7 +1886,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default(
* @param the_thread The thread to remove the request from.
* @param queue_lock_context The queue lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request_locked(
+static inline void _Thread_Wait_remove_request_locked(
Thread_Control *the_thread,
Thread_queue_Lock_context *queue_lock_context
)
@@ -1880,7 +1907,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request_locked(
* @param queue The queue that acquires.
* @param queue_lock_context The queue lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_queue_critical(
+static inline void _Thread_Wait_acquire_queue_critical(
Thread_queue_Queue *queue,
Thread_queue_Lock_context *queue_lock_context
)
@@ -1898,7 +1925,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_queue_critical(
* @param queue The queue that releases.
* @param queue_lock_context The queue lock context.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_release_queue_critical(
+static inline void _Thread_Wait_release_queue_critical(
Thread_queue_Queue *queue,
Thread_queue_Lock_context *queue_lock_context
)
@@ -1918,7 +1945,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_queue_critical(
* @param[in, out] queue_context The thread queue context for the corresponding
* _Thread_Wait_release_critical().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_critical(
+static inline void _Thread_Wait_acquire_critical(
Thread_Control *the_thread,
Thread_queue_Context *queue_context
)
@@ -1974,7 +2001,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_critical(
* @param[in, out] queue_context The thread queue context for the corresponding
* _Thread_Wait_release().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire(
+static inline void _Thread_Wait_acquire(
Thread_Control *the_thread,
Thread_queue_Context *queue_context
)
@@ -1993,7 +2020,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire(
* @param[in, out] queue_context The thread queue context used for corresponding
* _Thread_Wait_acquire_critical().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_release_critical(
+static inline void _Thread_Wait_release_critical(
Thread_Control *the_thread,
Thread_queue_Context *queue_context
)
@@ -2035,7 +2062,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_critical(
* @param[in, out] queue_context The thread queue context used for corresponding
* _Thread_Wait_acquire().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_release(
+static inline void _Thread_Wait_release(
Thread_Control *the_thread,
Thread_queue_Context *queue_context
)
@@ -2058,7 +2085,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release(
*
* @see _Thread_Wait_claim_finalize() and _Thread_Wait_restore_default().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_claim(
+static inline void _Thread_Wait_claim(
Thread_Control *the_thread,
Thread_queue_Queue *queue
)
@@ -2087,7 +2114,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_claim(
* @param[in, out] the_thread The thread.
* @param operations The corresponding thread queue operations.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_claim_finalize(
+static inline void _Thread_Wait_claim_finalize(
Thread_Control *the_thread,
const Thread_queue_Operations *operations
)
@@ -2106,7 +2133,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_claim_finalize(
* @param[in, out] queue_lock_context The thread queue lock context used for
* corresponding _Thread_Wait_acquire().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request(
+static inline void _Thread_Wait_remove_request(
Thread_Control *the_thread,
Thread_queue_Lock_context *queue_lock_context
)
@@ -2135,7 +2162,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request(
*
* @see _Thread_Wait_claim().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default(
+static inline void _Thread_Wait_restore_default(
Thread_Control *the_thread
)
{
@@ -2194,7 +2221,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default(
*
* @param the_thread The thread.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_tranquilize(
+static inline void _Thread_Wait_tranquilize(
Thread_Control *the_thread
)
{
@@ -2212,7 +2239,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_tranquilize(
* @param queue_context The thread queue context used for corresponding
* _Thread_Wait_acquire().
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel(
+static inline void _Thread_Wait_cancel(
Thread_Control *the_thread,
Thread_queue_Context *queue_context
)
@@ -2241,14 +2268,18 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel(
}
/**
- * @brief The initial thread wait flags value set by _Thread_Initialize().
+ * @brief Mask to get the thread wait state flags.
*/
-#define THREAD_WAIT_FLAGS_INITIAL 0x0U
+#define THREAD_WAIT_STATE_MASK 0xffU
/**
- * @brief Mask to get the thread wait state flags.
+ * @brief Indicates that the thread does not wait on something.
+ *
+ * In this wait state, the wait class is zero. This wait state is set
+ * initially by _Thread_Initialize() and after each wait operation once the
+ * thread is ready again.
*/
-#define THREAD_WAIT_STATE_MASK 0xffU
+#define THREAD_WAIT_STATE_READY 0x0U
/**
* @brief Indicates that the thread begins with the blocking operation.
@@ -2265,13 +2296,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel(
#define THREAD_WAIT_STATE_BLOCKED 0x2U
/**
- * @brief Indicates that a condition to end the thread wait occurred.
- *
- * This could be a timeout, a signal, an event or a resource availability.
- */
-#define THREAD_WAIT_STATE_READY_AGAIN 0x4U
-
-/**
* @brief Mask to get the thread wait class flags.
*/
#define THREAD_WAIT_CLASS_MASK 0xff00U
@@ -2302,7 +2326,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel(
* @param[in, out] the_thread The thread to set the wait flags of.
* @param flags The flags to set.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Wait_flags_set(
+static inline void _Thread_Wait_flags_set(
Thread_Control *the_thread,
Thread_Wait_flags flags
)
@@ -2321,7 +2345,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_flags_set(
*
* @return The thread's wait flags.
*/
-RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get(
+static inline Thread_Wait_flags _Thread_Wait_flags_get(
const Thread_Control *the_thread
)
{
@@ -2339,7 +2363,7 @@ RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get(
*
* @return The thread's wait flags.
*/
-RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get_acquire(
+static inline Thread_Wait_flags _Thread_Wait_flags_get_acquire(
const Thread_Control *the_thread
)
{
@@ -2366,7 +2390,7 @@ RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get_acquire(
* @retval true The wait flags were equal to the expected wait flags.
* @retval false The wait flags were not equal to the expected wait flags.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_release(
+static inline bool _Thread_Wait_flags_try_change_release(
Thread_Control *the_thread,
Thread_Wait_flags expected_flags,
Thread_Wait_flags desired_flags
@@ -2406,7 +2430,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_release(
* @retval true The wait flags were equal to the expected wait flags.
* @retval false The wait flags were not equal to the expected wait flags.
*/
-RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_acquire(
+static inline bool _Thread_Wait_flags_try_change_acquire(
Thread_Control *the_thread,
Thread_Wait_flags expected_flags,
Thread_Wait_flags desired_flags
@@ -2460,7 +2484,7 @@ Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread );
*
* @param the_thread The thread to get the status of the wait return code of.
*/
-RTEMS_INLINE_ROUTINE Status_Control _Thread_Wait_get_status(
+static inline Status_Control _Thread_Wait_get_status(
const Thread_Control *the_thread
)
{
@@ -2494,7 +2518,7 @@ void _Thread_Timeout( Watchdog_Control *the_watchdog );
* @param [in, out] timer The timer to initialize.
* @param cpu The cpu for the operation.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Timer_initialize(
+static inline void _Thread_Timer_initialize(
Thread_Timer_information *timer,
Per_CPU_Control *cpu
)
@@ -2511,7 +2535,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_initialize(
* @param cpu The cpu for the operation.
* @param ticks The ticks to add to the timeout ticks.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Add_timeout_ticks(
+static inline void _Thread_Add_timeout_ticks(
Thread_Control *the_thread,
Per_CPU_Control *cpu,
Watchdog_Interval ticks
@@ -2537,7 +2561,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Add_timeout_ticks(
* @param routine The watchdog routine for the thread.
* @param expire Expiration for the watchdog.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_realtime(
+static inline void _Thread_Timer_insert_realtime(
Thread_Control *the_thread,
Per_CPU_Control *cpu,
Watchdog_Service_routine_entry routine,
@@ -2562,7 +2586,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_realtime(
*
* @param[in, out] the_thread The thread to remove the watchdog from.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread )
+static inline void _Thread_Timer_remove( Thread_Control *the_thread )
{
ISR_lock_Context lock_context;
@@ -2588,7 +2612,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread )
* if necessary.
* @param queue The thread queue.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Remove_timer_and_unblock(
+static inline void _Thread_Remove_timer_and_unblock(
Thread_Control *the_thread,
Thread_queue_Queue *queue
)
@@ -2659,10 +2683,10 @@ void _Thread_Do_unpin(
*
* @param executing The currently executing thread.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Pin( Thread_Control *executing )
+static inline void _Thread_Pin( Thread_Control *executing )
{
#if defined(RTEMS_SMP)
- _Assert( executing == _Thread_Executing );
+ _Assert( executing == _Thread_Get_executing() );
executing->Scheduler.pin_level += THREAD_PIN_STEP;
#else
@@ -2676,7 +2700,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Pin( Thread_Control *executing )
* @param executing The currently executing thread.
* @param cpu_self The cpu for the operation.
*/
-RTEMS_INLINE_ROUTINE void _Thread_Unpin(
+static inline void _Thread_Unpin(
Thread_Control *executing,
Per_CPU_Control *cpu_self
)
@@ -2684,7 +2708,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Unpin(
#if defined(RTEMS_SMP)
unsigned int pin_level;
- _Assert( executing == _Thread_Executing );
+ _Assert( executing == _Per_CPU_Get_executing( cpu_self ) );
pin_level = executing->Scheduler.pin_level;
_Assert( pin_level > 0 );
@@ -2714,5 +2738,35 @@ RTEMS_INLINE_ROUTINE void _Thread_Unpin(
#include <rtems/score/threadmp.h>
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup RTEMSScoreThread
+ *
+ * @brief Removes the watchdog timer from the thread and lets the thread
+ * continue its execution.
+ *
+ * @param[in, out] the_thread is the thread.
+ *
+ * @param status is the thread wait status.
+ */
+static inline void _Thread_Timer_remove_and_continue(
+ Thread_Control *the_thread,
+ Status_Control status
+)
+{
+ _Thread_Timer_remove( the_thread );
+#if defined(RTEMS_MULTIPROCESSING)
+ _Thread_MP_Extract_proxy( the_thread );
+#endif
+ _Thread_Continue( the_thread, status );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
/* end of include file */