-
Notifications
You must be signed in to change notification settings - Fork 1.3k
POSIX Simulator: Don't yield non-FreeRTOS threads #1237
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
POSIX Simulator: Don't yield non-FreeRTOS threads #1237
Conversation
|
Would you please help me understand how this code can create a problem because In any case, you should not call FreeRTOS APIs from non-FreeRTOS threads. So your following suggestions seems reasonable to me:
|
It is okay and a good general practice to create FreeRTOS objects (task, mutex, queue, event group etc.) before starting the scheduler. |
I am closing this PR. Feel free to reopen if you need anything else. |
@aggarg What do you think about the idea of putting an assert in |
@johnboiles I assume you are talking about something like |
Done in #1247 |
POSIX Simulator: Don't yield non-FreeRTOS threads
Description
This is a followup to #1223. I think it's correct to not call
vTaskSwitchContext
from non-FreeRTOS threads but I'm low confidence on this one. Feedback is welcome.I just noticed a hang in my test suite and it looks like my test suite thread got suspended by FreeRTOS:
xTaskCreate
callsvPortYield
which may suspend the current thread. It's useful to be able to callxTaskCreate
from outside of a FreeRTOS thread (and has to happen at least once before the scheduler is started). In my test I calledxTaskCreate
after the scheduler was started, which lead to this hang.The alternative is to never allow
xTaskCreate
to be called from outside of a FreeRTOS thread after the scheduler has been started. If this is the direction, then we should probably enforce or document that somehow.Test Steps
Call
xTaskCreate
outside of a FreeRTOS thread. Sometimes it locks up. I'm unsure why it's only sometimes.Checklist:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.