diff --git a/src/cpu.c b/src/cpu.c index 79a820d39e..a89a0cca6a 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -225,6 +225,7 @@ void rt_cpus_unlock(rt_base_t level) if (pcpu->current_thread != RT_NULL) { + RT_ASSERT(pcpu->current_thread->cpus_lock_nest > 0); pcpu->current_thread->cpus_lock_nest--; if (pcpu->current_thread->cpus_lock_nest == 0) diff --git a/src/idle.c b/src/idle.c index 8b0a49c7f9..dcd278c628 100644 --- a/src/idle.c +++ b/src/idle.c @@ -292,7 +292,11 @@ static void rt_thread_system_entry(void *parameter) { while (1) { - rt_sem_take(&system_sem, RT_WAITING_FOREVER); + int ret= rt_sem_take(&system_sem, RT_WAITING_FOREVER); + if (ret != RT_EOK) + { + RT_ASSERT(0); + } rt_defunct_execute(); } } diff --git a/src/scheduler.c b/src/scheduler.c index c62a6d143c..c760fa8ed9 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -666,6 +666,7 @@ void rt_scheduler_do_irq_switch(void *context) #endif /* RT_USING_OVERFLOW_CHECK */ RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n")); + RT_ASSERT(current_thread->cpus_lock_nest > 0); current_thread->cpus_lock_nest--; current_thread->scheduler_lock_nest--; @@ -941,6 +942,7 @@ void rt_enter_critical(void) { rt_uint16_t lock_nest = current_thread->cpus_lock_nest; current_thread->cpus_lock_nest++; + RT_ASSERT(current_thread->cpus_lock_nest != 0); if (lock_nest == 0) { current_thread->scheduler_lock_nest ++; @@ -999,6 +1001,7 @@ void rt_exit_critical(void) current_thread->critical_lock_nest --; + RT_ASSERT(current_thread->cpus_lock_nest > 0); current_thread->cpus_lock_nest--; if (current_thread->cpus_lock_nest == 0) { diff --git a/src/signal.c b/src/signal.c index d3972efbef..17618e2ed6 100644 --- a/src/signal.c +++ b/src/signal.c @@ -56,6 +56,7 @@ static void _signal_entry(void *parameter) { struct rt_cpu* pcpu = rt_cpu_self(); + RT_ASSERT(current_thread->cpus_lock_nest > 0); pcpu->current_thread->cpus_lock_nest--; if (pcpu->current_thread->cpus_lock_nest == 0) {