From 198b85d233e0217dde9fd371f22d5730300dc211 Mon Sep 17 00:00:00 2001 From: Jiuzhu Dong Date: Thu, 3 Jun 2021 20:57:10 +0800 Subject: [PATCH] sched/idle: disable sched when idle call nx_bringup Because idle task will call mm_malloc to create some task and will take sem of mm. But if smp enable, the sem of mm may be taken by other cpu, so idle may be block because take this sem and crash. Change-Id: I22f0233ef6c59a1b81607d4389e68f8646c89395 Signed-off-by: Jiuzhu Dong --- sched/init/nx_start.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 6361695fbf..ee98a3db70 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -759,6 +759,13 @@ void nx_start(void) syslog_initialize(); + /* Disables context switching beacuse we need take the memory manager + * semaphore on this CPU so that it will not be available on the other + * CPUs until we have finished initialization. + */ + + sched_lock(); + #ifdef CONFIG_SMP /* Start all CPUs *********************************************************/ @@ -782,6 +789,10 @@ void nx_start(void) DEBUGVERIFY(nx_bringup()); + /* Let other threads have access to the memory manager */ + + sched_unlock(); + /* The IDLE Loop **********************************************************/ /* When control is return to this point, the system is idle. */