Skip to content

fix: use inherited priority for event item value in vTaskPrioritySet#1380

Open
Harsha-s210313 wants to merge 1 commit intoFreeRTOS:mainfrom
Harsha-s210313:main
Open

fix: use inherited priority for event item value in vTaskPrioritySet#1380
Harsha-s210313 wants to merge 1 commit intoFreeRTOS:mainfrom
Harsha-s210313:main

Conversation

@Harsha-s210313
Copy link

Fixes #1364

Problem

When vTaskPrioritySet() is called on a task that holds a mutex and has
an inherited priority, the event list item value is set using uxNewPriority
(the requested new priority) instead of pxTCB->uxPriority (the effective
current priority after inheritance).

This incorrect ordering in the event waiting list can cause the task to
never be unblocked when attempting to acquire additional mutexes, leading
to deadlock.

Fix

Replace uxNewPriority with pxTCB->uxPriority when setting the event
list item value, consistent with how xTaskPriorityInherit() and
vTaskPriorityDisinheritAfterTimeout() handle this.

Testing

Reproducer and test case provided by the original reporter at:
https://github.com/wirelinker/FreeRTOS_kernel_test_for_RP2040/tree/vTaskPrioritySet_event_item_value_deadlock_test

When a task holds a mutex and has an inherited priority, the event list
item value should reflect the effective priority (pxTCB->uxPriority)
rather than the requested new priority (uxNewPriority). Using uxNewPriority
can result in incorrect ordering in the event waiting list, leading to
deadlock when a task tries to acquire multiple mutexes.

Fixes FreeRTOS#1364
@sonarqubecloud
Copy link

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.

[BUG] vTaskPrioritySet doesn't set event item value according to the inherited priority

1 participant