summaryrefslogtreecommitdiff
path: root/common_smp/src/tx_thread_shell_entry.c
diff options
context:
space:
mode:
Diffstat (limited to 'common_smp/src/tx_thread_shell_entry.c')
-rw-r--r--common_smp/src/tx_thread_shell_entry.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/common_smp/src/tx_thread_shell_entry.c b/common_smp/src/tx_thread_shell_entry.c
index 45fe9d6d..2a16a00b 100644
--- a/common_smp/src/tx_thread_shell_entry.c
+++ b/common_smp/src/tx_thread_shell_entry.c
@@ -9,6 +9,8 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
+
/**************************************************************************/
/**************************************************************************/
@@ -134,6 +136,17 @@ VOID (*entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT type);
#ifdef TX_NOT_INTERRUPTABLE
+ /* Set the suspending flag, so that the completion transition is marked as in
+ progress for the same interval it is marked in the interruptable
+ configuration below. Nothing in this configuration needs the flag to cancel
+ an interrupted suspension -- interrupts stay disabled through the whole
+ transition -- but the notification callback and the completion extension
+ below are application code, reached by a direct call, and interrupt lockout
+ does not stop either of them from calling a thread lifecycle service on this
+ same control block. The flag is what _tx_thread_delete and _tx_thread_reset
+ test in order to refuse one. */
+ thread_ptr -> tx_thread_suspending = TX_TRUE;
+
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
/* Determine if an application callback routine is specified. */
@@ -148,6 +161,15 @@ VOID (*entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT type);
/* Perform any additional activities for tool or user purpose. */
TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
+ /* Clear the suspending flag. It has to be cleared here rather than after the
+ call below, because _tx_thread_system_ni_suspend returns to the scheduler for
+ a thread that is the current thread, which this one is, and so does not come
+ back. Clearing it afterwards would leave a normally completed thread marked
+ as transitioning for ever and therefore permanently undeletable. Clearing it
+ here loses nothing: everything from this point to the detachment runs with
+ interrupts disabled and calls no application code. */
+ thread_ptr -> tx_thread_suspending = TX_FALSE;
+
/* Call actual non-interruptable thread suspension routine. */
_tx_thread_system_ni_suspend(thread_ptr, ((ULONG) 0));