Skip to content

Passed a mutex waiter's priority change on to the mutex owner - #809

Open
howjmay wants to merge 1 commit into
eclipse-threadx:masterfrom
howjmay:fix/mutex-inherit-waiter-priority-change
Open

howjmay wants to merge 1 commit into
eclipse-threadx:masterfrom
howjmay:fix/mutex-inherit-waiter-priority-change

Conversation

@howjmay

@howjmay howjmay commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

A mutex owner inherits a waiter's priority only at the moment the waiter blocks in tx_mutex_get. _tx_thread_priority_change on a thread that is not ready updated that thread's own priority fields and nothing else, so a thread waiting on a TX_INHERIT mutex could be raised above the owner without the owner following, and a waiter the owner had inherited from could be lowered while the owner kept the old priority.

When the thread is suspended on a mutex, _tx_thread_priority_change now calls a new internal function, _tx_mutex_inherit_priority_update, which recomputes the mutex's highest waiting priority, the owner's inherited priority across every mutex it holds, and the owner's priority. The call goes through a new function pointer, _tx_thread_mutex_priority_update, set by tx_mutex_create in the same way as _tx_thread_mutex_release, so the thread services still do not link the mutex services. Applied to common and common_smp.

threadx_mutex_inherit_waiter_priority_change_test changes the priorities of two waiters in four steps that raise the owner, lower it to the other waiter, and finally return it to its own priority. Added to both suites. Without the fix it fails with ERROR #30 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.

PR checklist

  • Updated function header with a short description and version number
  • Added test case for bug fix or new feature
  • Validated on real hardware

A mutex owner inherits a waiter's priority only at the moment the waiter blocks in
tx_mutex_get. _tx_thread_priority_change on a thread that is not ready updated that
thread's own priority fields and nothing else, so a thread waiting on a TX_INHERIT mutex
could be raised above the owner without the owner following, and a waiter the owner had
inherited from could be lowered while the owner kept the old priority.

When the thread is suspended on a mutex, _tx_thread_priority_change now calls a new
internal function, _tx_mutex_inherit_priority_update, which recomputes the mutex's
highest waiting priority, the owner's inherited priority across every mutex it holds,
and the owner's priority. The call goes through a new function pointer,
_tx_thread_mutex_priority_update, set by tx_mutex_create in the same way as
_tx_thread_mutex_release, so the thread services still do not link the mutex services.
Applied to common and common_smp.

threadx_mutex_inherit_waiter_priority_change_test changes the priorities of two waiters
in four steps that raise the owner, lower it to the other waiter, and finally return it
to its own priority. Added to both suites. Without the fix it fails with ERROR eclipse-threadx#30 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.

This branch has not been deployed

No deployments
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