Skip to content

Commit 1bb2a09

Browse files
Saiiijchanwangfei_chen
and
wangfei_chen
authored
pthread_cond: refine prvInitializeStaticCond() (#42)
- 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 <[email protected]> Co-authored-by: wangfei_chen <[email protected]>
1 parent f1fe687 commit 1bb2a09

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static bool prvInitializeStaticCond( pthread_cond_internal_t * pxCond )
6161
{
6262
/* Cond initialization must be in a critical section to prevent two threads
6363
* from initializing it at the same time. */
64-
taskENTER_CRITICAL();
64+
vTaskSuspendAll();
6565

6666
/* Check again that the cond is still uninitialized, i.e. it wasn't
6767
* initialized while this function was waiting to enter the critical
@@ -82,7 +82,7 @@ static bool prvInitializeStaticCond( pthread_cond_internal_t * pxCond )
8282
}
8383

8484
/* Exit the critical section. */
85-
taskEXIT_CRITICAL();
85+
xTaskResumeAll();
8686
}
8787

8888
return pxCond->xIsInitialized;

0 commit comments

Comments
 (0)