[rtems commit] score: Properly continue the thread during restart
Sebastian Huber
sebh at rtems.org
Tue Nov 23 13:34:54 UTC 2021
Module: rtems
Branch: master
Commit: 546846472a5dadc7b3038b7c56da695f6dbbd1a6
Changeset: http://git.rtems.org/rtems/commit/?id=546846472a5dadc7b3038b7c56da695f6dbbd1a6
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Nov 11 08:44:29 2021 +0100
score: Properly continue the thread during restart
The _Thread_queue_Extract() does not deal with potential priority
updates and the SMP locking protocol handling. Use
_Thread_queue_Continue(). For the POSIX signals processing this is
currently probably unnecessary, however, the use case is similar to the
restart so use the same appoach.
Close #4546.
---
cpukit/include/rtems/score/status.h | 2 ++
cpukit/include/rtems/score/threadimpl.h | 7 +++++--
cpukit/posix/src/psignalunblockthread.c | 13 ++-----------
cpukit/score/src/threadrestart.c | 6 +++---
4 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/cpukit/include/rtems/score/status.h b/cpukit/include/rtems/score/status.h
index 236ae52..96c0f1f 100644
--- a/cpukit/include/rtems/score/status.h
+++ b/cpukit/include/rtems/score/status.h
@@ -106,6 +106,8 @@ typedef enum {
STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EINVAL ),
STATUS_INTERRUPTED =
STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EINTR ),
+ STATUS_INTERNAL_ERROR =
+ STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, ENOTSUP ),
STATUS_INVALID_ADDRESS =
STATUS_BUILD( STATUS_CLASSIC_INVALID_ADDRESS, EFAULT ),
STATUS_INVALID_ID =
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index a66d1a5..0a672aa 100644
--- a/cpukit/include/rtems/score/threadimpl.h
+++ b/cpukit/include/rtems/score/threadimpl.h
@@ -2698,16 +2698,19 @@ extern "C" {
* continue its execution.
*
* @param[in, out] the_thread is the thread.
+ *
+ * @param status is the thread wait status.
*/
RTEMS_INLINE_ROUTINE void _Thread_Timer_remove_and_continue(
- Thread_Control *the_thread
+ Thread_Control *the_thread,
+ Status_Control status
)
{
_Thread_Timer_remove( the_thread );
#if defined(RTEMS_MULTIPROCESSING)
_Thread_MP_Extract_proxy( the_thread );
#endif
- _Thread_queue_Extract( the_thread );
+ _Thread_Continue( the_thread, status );
}
#ifdef __cplusplus
diff --git a/cpukit/posix/src/psignalunblockthread.c b/cpukit/posix/src/psignalunblockthread.c
index 1133234..36680f9 100644
--- a/cpukit/posix/src/psignalunblockthread.c
+++ b/cpukit/posix/src/psignalunblockthread.c
@@ -175,15 +175,6 @@ static bool _POSIX_signals_Unblock_thread_done(
return status;
}
-static void _POSIX_signals_Interrupt_thread( Thread_Control *the_thread )
-{
-#if defined(RTEMS_MULTIPROCESSING)
- _Thread_MP_Extract_proxy( the_thread );
-#endif
- the_thread->Wait.return_code = STATUS_INTERRUPTED;
- _Thread_queue_Extract( the_thread );
-}
-
bool _POSIX_signals_Unblock_thread(
Thread_Control *the_thread,
int signo,
@@ -215,7 +206,7 @@ bool _POSIX_signals_Unblock_thread(
*the_info = *info;
}
- _POSIX_signals_Interrupt_thread( the_thread );
+ _Thread_Timer_remove_and_continue( the_thread, STATUS_INTERRUPTED );
return _POSIX_signals_Unblock_thread_done( the_thread, api, true );
}
@@ -245,7 +236,7 @@ bool _POSIX_signals_Unblock_thread(
*/
if ( _States_Is_interruptible_by_signal( the_thread->current_state ) ) {
- _POSIX_signals_Interrupt_thread( the_thread );
+ _Thread_Timer_remove_and_continue( the_thread, STATUS_INTERRUPTED );
}
}
return _POSIX_signals_Unblock_thread_done( the_thread, api, false );
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index d469705..90573da 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -137,7 +137,7 @@ static void _Thread_Make_zombie( Thread_Control *the_thread )
_Objects_Close( &information->Objects, &the_thread->Object );
_Thread_Set_state( the_thread, STATES_ZOMBIE );
- _Thread_Timer_remove_and_continue( the_thread );
+ _Thread_Timer_remove_and_continue( the_thread, STATUS_INTERNAL_ERROR );
/*
* Add the thread to the thread zombie chain before we wake up joining
@@ -357,7 +357,7 @@ static void _Thread_Remove_life_change_request( Thread_Control *the_thread )
* Do not remove states used for thread queues to avoid race conditions on
* SMP configurations. We could interrupt an extract operation on another
* processor disregarding the thread wait flags. Rely on
- * _Thread_queue_Extract() for removal of these states.
+ * _Thread_Continue() for removal of these states.
*/
_Thread_Clear_state_locked(
the_thread,
@@ -408,7 +408,7 @@ static void _Thread_Try_life_change_request(
_Thread_Add_life_change_request( the_thread );
_Thread_State_release( the_thread, lock_context );
- _Thread_Timer_remove_and_continue( the_thread );
+ _Thread_Timer_remove_and_continue( the_thread, STATUS_INTERNAL_ERROR );
_Thread_Remove_life_change_request( the_thread );
} else {
_Thread_Clear_state_locked( the_thread, STATES_SUSPENDED );
More information about the vc
mailing list