Repository navigation
Conversation
When a thread blocks on a TX_INHERIT mutex, the owner is raised to the waiter's priority. If the waiter then leaves the suspension list without the mutex -- on a wait timeout, tx_thread_wait_abort or tx_thread_terminate -- _tx_mutex_cleanup unlinked it but left tx_mutex_highest_priority_waiting and the owner's priority as they were. Only tx_mutex_put recomputed them, so the owner kept the departed waiter's priority for as long as it held the mutex, and every thread between the two priorities was starved. _tx_mutex_cleanup now calls a new internal function, _tx_mutex_inherit_priority_update, after unlinking a waiter from an inheriting mutex. It recomputes the mutex's highest waiting priority from its suspension list, recomputes the owner's inherited priority across every mutex the owner holds, and changes the owner's priority if it differs from the higher of that and the owner's own. It follows the preemption-disable pattern _tx_mutex_put uses around _tx_mutex_prioritize and _tx_mutex_priority_change. Applied to common and common_smp, where both files are identical. threadx_mutex_inherit_wait_exit_test removes a single waiter by each of the three routes, then aborts four waiters spread over two mutexes in turn. Added to both suites. Without the fix it fails with ERROR eclipse-threadx#12 in both; with it, the mutex tests pass in both suites' default_build_coverage configuration, and the changed sources build cleanly under -Wall -Wextra -Werror with TX_NOT_INTERRUPTABLE, TX_MISRA_ENABLE, TX_DISABLE_PREEMPTION_THRESHOLD and event trace.
howjmay
force-pushed
the
fix/mutex-inherit-wait-exit
branch
from
October 13, 2026 18:54
66bce86 to
d2db0b3
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a thread blocks on a TX_INHERIT mutex, the owner is raised to the waiter's priority. If the waiter then leaves the suspension list without the mutex -- on a wait timeout, tx_thread_wait_abort or tx_thread_terminate -- _tx_mutex_cleanup unlinked it but left tx_mutex_highest_priority_waiting and the owner's priority as they were. Only tx_mutex_put recomputed them, so the owner kept the departed waiter's priority for as long as it held the mutex, and every thread between the two priorities was starved.
_tx_mutex_cleanup now calls a new internal function, _tx_mutex_inherit_priority_update, after unlinking a waiter from an inheriting mutex. It recomputes the mutex's highest waiting priority from its suspension list, recomputes the owner's inherited priority across every mutex the owner holds, and changes the owner's priority if it differs from the higher of that and the owner's own. It follows the preemption-disable pattern _tx_mutex_put uses around _tx_mutex_prioritize and _tx_mutex_priority_change. Applied to common and common_smp, where both files are identical.
threadx_mutex_inherit_wait_exit_test covers a single waiter leaving by each of the three routes, three waiters leaving one by one, and an owner still inheriting from a second mutex. Added to both suites. Without the fix it fails with ERROR #15 in both; with it, all 114 tests of the single-core default_build_coverage configuration pass, the mutex tests pass in the SMP default_build_coverage configuration, and the changed sources build cleanly under -Wall -Wextra -Werror with TX_NOT_INTERRUPTABLE, TX_MISRA_ENABLE, TX_DISABLE_PREEMPTION_THRESHOLD and event trace.
PR checklist