-
Notifications
You must be signed in to change notification settings - Fork 72
Why check pxCond->xIsInitialized flag twice and use critical section to prevent race condition #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@Saiiijchan As you have noted, the POSIX Regarding the double check of the |
Thanks for your answer.
Since suspending the scheduler (via vTaskSuspendAll()) can prevent race conditions, could we simply use vTaskSuspendAll() instead of taskENTER_CRITICAL() no matter on single-core or SMP systems? After all, vTaskSuspendAll() has lower overhead. |
I may be missing something, but from my analysis it should be sufficient for both to call |
@rlshumat, @Saiiijchan - Thank you for sharing your analysis. I agree that we can change to
Regarding the above point, this second check should prevent it, right? |
No, we do not have any test case unfortunately. You are welcome to contribute though :) |
Hi, I am try to port POSIX lab to v11.1 SMP.
I meet a problem when test pthread condition
Lab-Project-FreeRTOS-POSIX/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread_cond.c
Line 64 in f1fe687
The pvPortMalloc() will call vTaskSuspendAll() but vTaskSuspendaLL() CAN not be called in critical secion.
Besides, I don't understand why check pxCond->xIsInitialized flag twice on line 60 and 69.
The text was updated successfully, but these errors were encountered: