diff options
| author | shaojinchun <[email protected]> | 2019-09-26 18:13:07 +0800 |
|---|---|---|
| committer | shaojinchun <[email protected]> | 2019-09-27 14:38:33 +0800 |
| commit | cb07e5fb24afebdf233847da551d3ede80727345 (patch) | |
| tree | e1885e5a8925aefe3df70577416d4b4ddb698b5f /src/scheduler.c | |
| parent | 676279421feba8832f926a2e96b5e7dc7fdb0652 (diff) | |
开放spinlock相关函数
Diffstat (limited to 'src/scheduler.c')
| -rw-r--r-- | src/scheduler.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/scheduler.c b/src/scheduler.c index b487bd4b60..0faafaa2fc 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -840,11 +840,14 @@ void rt_enter_critical(void) */ /* lock scheduler for all cpus */ - if (current_thread->scheduler_lock_nest == !!current_thread->cpus_lock_nest) + if (current_thread->critical_lock_nest == 0) { rt_hw_spin_lock(&_rt_critical_lock); } + /* critical for local cpu */ + current_thread->critical_lock_nest ++; + /* lock scheduler for local cpu */ current_thread->scheduler_lock_nest ++; @@ -892,7 +895,9 @@ void rt_exit_critical(void) current_thread->scheduler_lock_nest --; - if (current_thread->scheduler_lock_nest == !!current_thread->cpus_lock_nest) + current_thread->critical_lock_nest --; + + if (current_thread->critical_lock_nest == 0) { rt_hw_spin_unlock(&_rt_critical_lock); } @@ -951,7 +956,7 @@ rt_uint16_t rt_critical_level(void) #ifdef RT_USING_SMP struct rt_thread *current_thread = rt_cpu_self()->current_thread; - return current_thread->scheduler_lock_nest; + return current_thread->critical_lock_nest; #else return rt_scheduler_lock_nest; #endif /*RT_USING_SMP*/ |
