2
votes

If a spinlock is held in the process context. What will happen if the same spinlock is required in an interrupt context?

Either the interrupt handler wait until the spinlock is released by the process, or the interrupt handler will schedule it on another processor? As mentioned in the following thread in stackoverflow.

But still the question will be the same, the interrupt handler will wait for the spinlock to be released? Isn't it?

1
I'd suggest adding any sample code that you can to this Q. Otherwise it might get closed for lack of effort/research.slm
I don't have any sample code, I am curious if there is any example to understand this. I have gone through "LKD" but it tells that if you are sharing data between tasklet and interrupt handler, you must use the spinlock.one.prav

1 Answers

3
votes

If a spinlock is held in the process context. What will happen if the same spinlock is required in an interrupt context?

In short, this is a bad design and will lead to deadlock. That's why there are APIs spin_lock_irq/spin_lock_irqsave that disable the interrupts before acquiring such locks and avoids such contentions.