Repository navigation
Conversation
tx_mutex_get raised the owner of a TX_INHERIT mutex and stopped. If that owner was itself blocked on a second inheriting mutex, the second owner never inherited the priority: with H blocked on m1, owned by L1, blocked on m2, owned by L2, L2 stayed at L1's old priority and H waited behind every thread between the two. When TX_MUTEX_INHERIT_CHAIN_MAX is defined, tx_mutex_get passes the inherited priority on through a new internal function, _tx_mutex_priority_chain. While the thread it last raised is waiting on an inheriting mutex, it updates that mutex's highest waiting priority and raises the mutex owner with _tx_mutex_priority_change, which handles ready and suspended owners alike, for at most TX_MUTEX_INHERIT_CHAIN_MAX mutexes. It stops at the first owner already at the priority or higher, which also ends it on a lock cycle. The walk is iterative and only raises priorities. It is opt-in, so existing builds keep their worst-case tx_mutex_get time. Documented in tx_user_sample.h. Applied to common and common_smp. threadx_mutex_inherit_chain_test covers a chain of four suspended owners, which also checks the length limit, a chain ending at a ready owner, and a lock cycle, and checks the unchained behaviour when the option is not defined. Added to both suites, with TX_MUTEX_INHERIT_CHAIN_MAX=2 in default_build_coverage so the walk is built and covered. 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 new test passes in disable_notify_callbacks_build, where the option is not defined. The changed sources build cleanly under -Wall -Wextra -Werror with TX_NOT_INTERRUPTABLE, TX_MISRA_ENABLE and TX_DISABLE_PREEMPTION_THRESHOLD, with and without the option.
fdesbiens
self-requested a review
October 16, 2026 13:30
fdesbiens
requested changes
Oct 16, 2026
fdesbiens
left a comment
Contributor
There was a problem hiding this comment.
Hi @howjmay. Thank you for this contribution. The bounded chain walk and its cycle test are useful. I left a comment on how the inherited priority is restored. Please retarget the PR to dev and share coverage for the new production code.
| #ifdef TX_MUTEX_INHERIT_CHAIN_MAX | ||
|
|
||
| /* Pass the priority on to the owner of any mutex the owner is waiting on. */ | ||
| _tx_mutex_priority_chain(mutex_owner, thread_ptr -> tx_thread_priority); |
Contributor
There was a problem hiding this comment.
This passes a priority boost to downstream owners, but I cannot find a matching update when the triggering waiter leaves or lowers its priority. In an H → L1 → L2 chain, L2 can retain H’s priority after H stops waiting, even if #807 restores L1. Could you update the affected chain on those paths and add regression coverage?
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.
tx_mutex_get raised the owner of a TX_INHERIT mutex and stopped. If that owner was itself blocked on a second inheriting mutex, the second owner never inherited the priority: with H blocked on m1, owned by L1, blocked on m2, owned by L2, L2 stayed at L1's old priority and H waited behind every thread between the two.
When TX_MUTEX_INHERIT_CHAIN_MAX is defined, tx_mutex_get passes the inherited priority on through a new internal function, _tx_mutex_priority_chain. While the thread it last raised is waiting on an inheriting mutex, it updates that mutex's highest waiting priority and raises the mutex owner with _tx_mutex_priority_change, which handles ready and suspended owners alike, for at most TX_MUTEX_INHERIT_CHAIN_MAX mutexes. It stops at the first owner already at the priority or higher, which also ends it on a lock cycle. The walk is iterative and only raises priorities. It is opt-in, so existing builds keep their worst-case tx_mutex_get time. Documented in tx_user_sample.h. Applied to common and common_smp.
threadx_mutex_inherit_chain_test covers a chain of four suspended owners, which also checks the length limit, a chain ending at a ready owner, and a lock cycle, and checks the unchained behaviour when the option is not defined. Added to both suites, with TX_MUTEX_INHERIT_CHAIN_MAX=2 in default_build_coverage so the walk is built and covered. Without the fix it fails with ERROR #12 in both; with it, the mutex tests pass in both suites' default_build_coverage configuration and the new test passes in disable_notify_callbacks_build, where the option is not defined. The changed sources build cleanly under -Wall -Wextra -Werror with TX_NOT_INTERRUPTABLE, TX_MISRA_ENABLE and TX_DISABLE_PREEMPTION_THRESHOLD, with and without the option.
PR checklist