forked from nuttx/nuttx-update
assert: in assert we use small spinlock replace enter_critical_section
reason: Since assert may synchronously wait to stop another CPU, potentially leading to a deadlock, we replace enter_critical_section with a small spinlock to avoid such a situation. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
parent
d86d902392
commit
d226170292
1 changed files with 4 additions and 2 deletions
|
@ -113,6 +113,8 @@ static noreturn_function int pause_cpu_handler(FAR void *arg);
|
|||
static bool g_cpu_paused[CONFIG_SMP_NCPUS];
|
||||
#endif
|
||||
|
||||
static spinlock_t g_assert_lock = SP_UNLOCKED;
|
||||
|
||||
static uintptr_t g_last_regs[CONFIG_SMP_NCPUS][XCPTCONTEXT_REGS]
|
||||
aligned_data(XCPTCONTEXT_ALIGN);
|
||||
|
||||
|
@ -841,7 +843,7 @@ void _assert(FAR const char *filename, int linenum,
|
|||
flags = 0; /* suppress GCC warning */
|
||||
if (os_ready)
|
||||
{
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&g_assert_lock);
|
||||
}
|
||||
|
||||
#if CONFIG_BOARD_RESET_ON_ASSERT < 2
|
||||
|
@ -914,6 +916,6 @@ void _assert(FAR const char *filename, int linenum,
|
|||
|
||||
if (os_ready)
|
||||
{
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&g_assert_lock, flags);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue