0
votes

There is a similar question asked by someone:

How does Kernel handle the lock in process context when an interrupt comes?

But still it is not clear, when Interrupt comes on one CPU and a process is executing on same CPU with spinlock held. can interrupt preempt the process holding the spinlock. ? Should be because we have spin_lock_irq to disable the interrupts.

it means that, when kernel preemption is disabled and interrupt comes, then interrupt can preempt the process and start executing right?

Can anyone clarify this. I think I am missing point here.

Thanks Gururaj

1
When IRQs are disabled, then the CPU will save the interrupts for later handling. NMI will however be handled anyway.Paul Stelian
If you don't specify an OS, the answers might vary...tofro
@tofro I am referring Linux Operating system. case is Spinlock is held means preemption is disabled and IRQs not disabled. If this is the case, will interrupt preempt the process holding the spinlock.?Gururaja B O
An interrupt will normally preempt anything in case interrupts are not disabled - It's hardware. The CPU doesn't care about spinlocks and OS mechanisms.tofro

1 Answers

0
votes

Yes, interrupts will preempt your lock-holding code.

The CPU hardware that processes an interrupt and jumps to the interrupt's vector in the IDT does not know or care what code is running or what locks you have. It will preempt everything, even other interrupt handlers.