From f9a59164e854c3151555493231f92e570bd75a2a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 17 Feb 2021 09:02:31 +0100 Subject: score: Add _Thread_Append_post_switch_action() Update #4244. --- cpukit/include/rtems/score/threadimpl.h | 38 +++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'cpukit') diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h index e76f9c3972..e9d44526da 100644 --- a/cpukit/include/rtems/score/threadimpl.h +++ b/cpukit/include/rtems/score/threadimpl.h @@ -1236,11 +1236,16 @@ RTEMS_INLINE_ROUTINE void _Thread_Action_initialize( } /** - * @brief Adds a post switch action to the thread with the given handler. + * @brief Adds the post switch action to the thread. * - * @param[in, out] the_thread The thread. - * @param[in, out] action The action to add. - * @param handler The handler for the action. + * The caller shall own the thread state lock. A thread dispatch is + * requested. + * + * @param[in, out] the_thread is the thread of the action. + * + * @param[in, out] action is the action to add. + * + * @param handler is the handler for the action. */ RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action( Thread_Control *the_thread, @@ -1264,6 +1269,31 @@ RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action( ); } +/** + * @brief Appends the post switch action to the thread. + * + * The caller shall own the thread state lock. The action shall be inactive. + * The handler of the action shall be already set. A thread dispatch is not + * requested. + * + * @param[in, out] the_thread is the thread of the action. + * + * @param[in, out] action is the action to add. + */ +RTEMS_INLINE_ROUTINE void _Thread_Append_post_switch_action( + Thread_Control *the_thread, + Thread_Action *action +) +{ + _Assert( _Thread_State_is_owner( the_thread ) ); + _Assert( action->handler != NULL ); + + _Chain_Append_unprotected( + &the_thread->Post_switch_actions.Chain, + &action->Node + ); +} + /** * @brief Checks if the thread life state is restarting. * -- cgit v1.2.3