summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2019-04-04 10:06:28 +0800
committerBernard Xiong <[email protected]>2019-04-04 10:06:28 +0800
commitd517389e521f2f2cff4f2a04631a5c952719ce73 (patch)
tree3ccf4653980aff41a2aa01f8f8f5ede751710f7c
parentb490052579e4229ae0c4c7ac0772fcc5d40195bc (diff)
[Kernel] Fix the critical issue under smp
-rw-r--r--src/scheduler.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/scheduler.c b/src/scheduler.c
index 37b262d83b..0028c98314 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -792,6 +792,12 @@ void rt_enter_critical(void)
level = rt_hw_local_irq_disable();
current_thread = rt_cpu_self()->current_thread;
+ if (!current_thread)
+ {
+ rt_hw_local_irq_enable(level);
+ return ;
+ }
+
/*
* the maximal number of nest is RT_UINT16_MAX, which is big
* enough and does not check here
@@ -842,6 +848,11 @@ void rt_exit_critical(void)
level = rt_hw_local_irq_disable();
current_thread = rt_cpu_self()->current_thread;
+ if (!current_thread)
+ {
+ rt_hw_local_irq_enable(level);
+ return ;
+ }
current_thread->scheduler_lock_nest --;