Skip to content

Initialized the suspend status before the non-interruptable suspend in tx_thread_sleep, so a sleep no longer returns a stale error left over from an earlier timed-out suspension - #725

Merged
fdesbiens merged 1 commit into
eclipse-threadx:devfrom
fdesbiens:fix/issue-433
Sep 10, 2026

Conversation

@fdesbiens

Copy link
Copy Markdown
Contributor

Fixes #433.

When TX_NOT_INTERRUPTABLE is defined, _tx_thread_sleep() did not set tx_thread_suspend_status to TX_SUCCESS before calling _tx_thread_system_ni_suspend(). The interruptable path has always done so.

Nothing else writes that field on behalf of a sleeping thread: _tx_thread_timeout() resumes a TX_SLEEP thread directly, and unlike the semaphore, queue, mutex and event flags paths there is no suspend cleanup routine for sleep that would set a status. The field therefore kept whatever value the thread's previous suspension left in it, and tx_thread_sleep() returned that value. A tx_semaphore_get() that timed out with TX_NO_INSTANCE was followed by a tx_thread_sleep() that slept correctly but also returned TX_NO_INSTANCE.

This is the fix @billlamiework proposed in the issue thread. The same change is applied to common_smp/src/tx_thread_sleep.c, which is byte-identical to the non-SMP copy.

Validation: test/tx 98/98 and test/smp 114/114 pass. Neither suite has a TX_NOT_INTERRUPTABLE configuration, so both files were additionally compiled with -DTX_NOT_INTERRUPTABLE to confirm the changed path builds.

…n tx_thread_sleep, so a sleep no longer returns a stale error left over from an earlier timed-out suspension

When TX_NOT_INTERRUPTABLE is defined, _tx_thread_sleep did not set
tx_thread_suspend_status to TX_SUCCESS before calling
_tx_thread_system_ni_suspend. The interruptable path always did.

Nothing else writes that field on behalf of a sleeping thread:
_tx_thread_timeout resumes a TX_SLEEP thread directly and there is no
suspend cleanup routine for sleep. The value therefore survived from
whatever suspension the thread performed last, and tx_thread_sleep
returned it. A tx_semaphore_get that timed out with TX_NO_INSTANCE
would be followed by a tx_thread_sleep that also returned
TX_NO_INSTANCE after sleeping correctly.

The same change is applied to the SMP copy, which is identical.

Assisted-by: Copilot (Opus 5) <noreply@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant