From a53e9337e9db9560e9b365c000d09cb40c65d5ac Mon Sep 17 00:00:00 2001 From: Harsha Date: Sun, 15 Mar 2026 21:04:41 +0530 Subject: [PATCH] fix: use inherited priority for event item value in vTaskPrioritySet 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 #1364 --- tasks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.c b/tasks.c index c596c475f8..a3515b5fdf 100644 --- a/tasks.c +++ b/tasks.c @@ -2936,7 +2936,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, * being used for anything else. */ if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0U ) ) { - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxNewPriority ) ); + listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ) ); } else {