I have a routine that toggles the GPIO pin high/low, and have delay between the highs and lows (using udelay
), and then samples the GPIO state for some period. I need to make sure this part of the code is executed without being pre-empted by the scheduler or by any possible interrupts. I am running the code on a dual core ARM system so it should be SMP. Is Spin_Lock_IrqSave()
safe enough for such purpose? I got a feeling my code is still somehow being interrupted occasionally but no proof yet.
Thanks a lot.
If you want to disable preemption, use preempt_disable()
and preempt_enable()
.
If you want to disable interrupts, use local_irq_disable()
and local_irq_enable()
spin_lock_irqsave
will normally do both of these, though some "real-time" enhancements sometimes allow spinlocks to schedule, so it is always best to say what you mean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With