hujun260 commented on code in PR #13349:
URL: https://github.com/apache/nuttx/pull/13349#discussion_r1765042687
##########
sched/irq/irq_csection.c:
##########
@@ -345,6 +345,26 @@ irqstate_t enter_critical_section(void)
}
else
{
+ /* CHECK IRQ
+ *
+ * After the OS starts, in the thread context,
+ * we must ensure that the interrupt is not masked
+ * when first enters the critical section.
+ * Otherwise, at this time when another CPU issues a pause
+ * interrupt to the current CPU, it can lead to a deadlock.
+ *
+ * During the vela os startup phase, interrupts are masked until
+ * the interrupt initialization function (irq_initialize) is
Review Comment:
The enter_critical_section relies on irq being enabled in its normal context
due to its specific strategy of reenable irq to respond to up_cpu_pause when
the lock cannot be acquired immediately.
However, spin_lock_irqsave disabled irq make the strategy employed by
enter_critical_section faild,
potentially leading to a deadlock situation."

cpu0<br/><br/><br/><br/><br/> cpu1
enter_critical_section
up_cpu_pause(will wait until succed)
spin_lock_irqsave(NULL);
enter_critical_section(**deadlock**)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]