summaryrefslogtreecommitdiff
path: root/common_smp/src/tx_thread_reset.c
diff options
context:
space:
mode:
Diffstat (limited to 'common_smp/src/tx_thread_reset.c')
-rw-r--r--common_smp/src/tx_thread_reset.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/common_smp/src/tx_thread_reset.c b/common_smp/src/tx_thread_reset.c
index da56daf5..8e59f1e7 100644
--- a/common_smp/src/tx_thread_reset.c
+++ b/common_smp/src/tx_thread_reset.c
@@ -9,6 +9,8 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
+
/**************************************************************************/
/**************************************************************************/
@@ -104,6 +106,28 @@ UINT status;
status = TX_NOT_DONE;
}
}
+
+ /* The state is terminal, but a terminal state on its own is not authorization
+ to rebuild the stack and move the thread back to TX_SUSPENDED. Both paths
+ that produce one -- thread completion in _tx_thread_shell_entry and thread
+ termination in _tx_thread_terminate -- publish TX_COMPLETED or
+ TX_TERMINATED, and then run this thread's exit notification callback, before
+ the thread has been detached from the ready list. The suspending flag is
+ set for exactly that interval. Resetting inside it would also defeat the
+ protection _tx_thread_system_resume relies on, which refuses to cancel a
+ suspension only while the state is still terminal. */
+ if (status == TX_SUCCESS)
+ {
+
+ /* Is the completion or termination transition still in progress? */
+ if (thread_ptr -> tx_thread_suspending == TX_TRUE)
+ {
+
+ /* Yes, refuse the reset. The condition is transient: the caller may
+ retry once the transition has finished. */
+ status = TX_NOT_DONE;
+ }
+ }
}
/* Is the request valid? */