Re: locking and interrupts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a data structure is being accessed both by an interrupt handler and a process / thread / critical region then you might have to go for a spin lock with kernel preemption disabled if you want to access a datastructure (For instance you could access the datastructure in a system call service routine).

Now, what happens when you try to access the spin lock without kernel preemption? Suppose you have already acquired a spin lock on a data structure in an exception handler (or perhaps in one of the system call handler routine executing on behalf of a process) without disabling kernel preemption. When an interrupt comes then you would end up preempting the process/thread which was executing a system call service routine on behalf of user mode process and try to acquire a spin lock. A DEADLOCK!

You can't use semaphore either since implementation of semaphore supspends the process and there is no way to no the context of the process in interrupt handler. Though I believe recent kernel versions do have semaphore implementation which don't suspend the process. I hope this helps.Thanks.

-Govindraj

On Tue, 06 Oct 2009 12:44:51 +0530 wrote
>Dear All,I have a very basic confusion, please help and confirm the right answer :If a process/thread (user space/kernel space)  has taken a lock on a critical section code, and suddenly an interrupt occurs which want to use the same shared data of critical region. Will it able to preempt this code which is running in process context ?
As per my understanding, although interrupts has higher priority than process, but it can't preempt the process  otherwise a major bug can occur ( depending upon the shared data of critical section). Please confirm my understanding weather its true or not ?
Best regards,Krishna


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux