From 0e7469a74d901e8d4b6766eb4b213c915c3b43f1 Mon Sep 17 00:00:00 2001 From: wangfei_chen Date: Mon, 31 Mar 2025 16:27:06 +0800 Subject: [PATCH] pthread_cond: refine prvInitializeStaticCond() - On v11.1 SMP, pvPortMalloc() should not be called in critical secion. vTaskSuspenAll() would trigger assert if in criticalsection. - The pthread_cond APIs are not ISR safe. Use vTaskSuspendAll() to prevent race condition is enough. Signed-off-by: wangfei_chen --- FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c b/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c index 82ec0f5..badec75 100755 --- a/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c +++ b/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c @@ -61,7 +61,7 @@ static bool prvInitializeStaticCond( pthread_cond_internal_t * pxCond ) { /* Cond initialization must be in a critical section to prevent two threads * from initializing it at the same time. */ - taskENTER_CRITICAL(); + vTaskSuspendAll(); /* Check again that the cond is still uninitialized, i.e. it wasn't * initialized while this function was waiting to enter the critical @@ -82,7 +82,7 @@ static bool prvInitializeStaticCond( pthread_cond_internal_t * pxCond ) } /* Exit the critical section. */ - taskEXIT_CRITICAL(); + xTaskResumeAll(); } return pxCond->xIsInitialized;