diff options
| author | wangxiaoyao <[email protected]> | 2023-02-20 13:39:34 +0800 |
|---|---|---|
| committer | guo <[email protected]> | 2023-02-21 08:48:49 +0800 |
| commit | ed58f6676d074ec9f66ea78e23d1e1657c9fef20 (patch) | |
| tree | 0b24af0f5a0244e17abc3cef14abe2dd746248cf | |
| parent | 29c7278edc8bd47f0263143cf85568c8c0e6e61e (diff) | |
[src] add assertion for debugging
| -rw-r--r-- | src/cpu.c | 1 | ||||
| -rw-r--r-- | src/idle.c | 6 | ||||
| -rw-r--r-- | src/scheduler.c | 3 | ||||
| -rw-r--r-- | src/signal.c | 1 |
4 files changed, 10 insertions, 1 deletions
@@ -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) { |
