xiaoxiang781216 commented on PR #15705: URL: https://github.com/apache/nuttx/pull/15705#issuecomment-2625300160
> if your code does not enable the interrupt controller and schedler at boot time, why does spin_lock require sched_lock and irq_save? > > bringup phase and ISR and scheduler is not enabled boot time is a very short phase in the whole life cycle. If you really want to squeeze the performance(I doubt), you can still call spin_lock_irqsave_preempt. > > Ok, could you give me an example, when can you use spin_lock API? the interrupt can be happened without your control, which mean spin_lock CAN'T BE CALLED in any thread context. > > There are also some places where more fine-grained control can be used, such as > > ``` > irq_save > > ... > if (....) > spin_lock > > if (spin_is_locked) > spin_unlock > > irq_restore > ``` This case already demo that you agree that holding spinlock alone without either sched_lock or irq_disable isn't safe and should be avoid as much as possible. -- 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: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org