mirror of
https://github.com/FreeRTOS/Lab-Project-FreeRTOS-POSIX.git
synced 2025-10-19 02:23:55 +08:00
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 <wangfei_chen@realsil.com.cn> Co-authored-by: wangfei_chen <wangfei_chen@realsil.com.cn>
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user