From 4d14717e771c5faceb428a68cf906c81628d67b7 Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Wed, 11 Oct 2023 14:48:05 +0800 Subject: [PATCH] fix(freertos/idf): Add work around vTaskResumeAll() compiler optimization This commit adds a workaround for a compiler optimization issue in FreeRTOS v10.5.1 in xTaskResumeAll() where pxTCB is only read once, even if in a loop. A follow up ticket has been added to properly resolve this issue. --- components/freertos/FreeRTOS-Kernel/tasks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/freertos/FreeRTOS-Kernel/tasks.c b/components/freertos/FreeRTOS-Kernel/tasks.c index c755765e1a..84861496a9 100644 --- a/components/freertos/FreeRTOS-Kernel/tasks.c +++ b/components/freertos/FreeRTOS-Kernel/tasks.c @@ -2554,7 +2554,8 @@ BaseType_t xTaskResumeAll( void ) * appropriate ready list. */ while( listLIST_IS_EMPTY( &xPendingReadyList[ xCurCoreID ] ) == pdFALSE ) { - pxTCB = listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList[ xCurCoreID ] ) ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ + /* Note: Add volatile cast (IDF-8361) */ + pxTCB = listGET_OWNER_OF_HEAD_ENTRY( ( volatile List_t * ) ( &xPendingReadyList[ xCurCoreID ] ) ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ listREMOVE_ITEM( &( pxTCB->xEventListItem ) ); portMEMORY_BARRIER(); listREMOVE_ITEM( &( pxTCB->xStateListItem ) );