diff options
| author | Bernard Xiong <[email protected]> | 2019-05-09 08:38:18 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2019-05-09 08:48:38 +0800 |
| commit | 4127cc13bfb11ccc2371bf59700138c113d12271 (patch) | |
| tree | 2db82af6bda94a006cbf32aad2f3eb35aa5cd940 | |
| parent | 6e89f70e92bfaef1a7a3740761d6dd03226ab4b1 (diff) | |
[Kernel] Move the ++/-- operator outside of condition.
| -rw-r--r-- | src/cpu.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -42,12 +42,16 @@ rt_base_t rt_cpus_lock(void) pcpu = rt_cpu_self(); if (pcpu->current_thread != RT_NULL) { - if (pcpu->current_thread->cpus_lock_nest++ == 0) + register rt_uint16_t lock_nest = pcpu->current_thread->cpus_lock_nest; + + pcpu->current_thread->cpus_lock_nest++; + if (lock_nest == 0) { pcpu->current_thread->scheduler_lock_nest++; rt_hw_spin_lock(&_cpus_lock); } } + return level; } RTM_EXPORT(rt_cpus_lock); @@ -61,7 +65,9 @@ void rt_cpus_unlock(rt_base_t level) if (pcpu->current_thread != RT_NULL) { - if (--pcpu->current_thread->cpus_lock_nest == 0) + pcpu->current_thread->cpus_lock_nest--; + + if (pcpu->current_thread->cpus_lock_nest == 0) { pcpu->current_thread->scheduler_lock_nest--; rt_hw_spin_unlock(&_cpus_lock); |
