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
sched: nxtask_start should call entry point directly for kernel thread #1922
Conversation
I don't think that this change is going into the right direction since we will see more and more SMP capable HW |
since nxtask_startup will initialize c++ global variables which shouldn't be done inside the kernel thread Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
5ddf583
to
007cbbf
Compare
@jerpelea could you give more info? This patch fix the problem we found in SMP configuration. |
@jerpelea could you review again? |
As long as I checked the latest upstream, I think the issue does not relate to SMP. Also, I noticed that this PR only resolves the issue for kernel thread as titled. |
Yes, it isn't SMP specific. SMP just expose the problem: The good side effect with this fix is that the synchronization issue also get resolved too, because kernel always create one and only one user task(init) and cxx_initialize get called before init's main has the chance to create more tasks concurrently.
Yes, it is the expected behaviour, please see PR: #1341 and apache/nuttx-apps#316. |
@xiaoxiang781216 @jerpelea |
LGTM |
Summary
since nxtask_startup will initialize c++ global variables which shouldn't be done inside the kernel thread.
Impact
C++ global variables may initialize twice when SMP is enabled because cxx_initialize don't have any sync code. But we don't need add mutex/spinlock code to cxx_initialize, because we should avoid the kernel thread call cxx_initialize in the first place. Once we ensure that cxx_initialize get called only inside the user task entry point, the sync isn't a problem anymore because NuttX kernel always create one and only one user task(init).
Testing