Re: How Does Interrupt Handler works in this case?

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

 



Hi Manjunath,

Please keep the kernelnewbiews in mail thread. Queries and answers on
this might help someone later.

For details of spinlock, refer to include/linux/spinlock.h in kernel
sources. There are some top level and other low level macros defined
in this file.

The thing of interrupt priority is there but that is at PIC level and
its the interrupt handler stub of linux kernel which acknowledge the
interrupts on PIC and masks that interrupt line.

You can also read to my detailed article on interrupt handling in
Linux at http://lkdp.blogspot.com/2006/01/interrupt-handling-internals-in-linux_22.html

Hope it will be of some help to you.

Gaurav


On 4/11/06, Manjunath Naik <peter.desouzain@xxxxxxxxx> wrote:
> Hi Gaurav,
>
> thanks for reply....
>
> But I want to know how exactly spin -lock works.
>
> I had read some think like Interrupt priority level. Whenever Current
> process is using the buffer it makes the interrupt priority of the
> current process high. So during this time if interrupt comes, it will
> get blocked. whether this concept is implemented using the spin-lock
> technique.

No its nothing like that. Actually A spinlock is nothing but defined
as a structure having one volatile element. Being voilatile, whenever
this spinlock variable is increased or reffered, the reffered
instruction will always get the latest value in memory
>
> thanks
> Manjunath
>
>
> On 4/11/06, Gaurav Dhiman <gauravd.chd@xxxxxxxxx> wrote:
> > On 4/11/06, Manjunath Naik <peter.desouzain@xxxxxxxxx> wrote:
> >
> > > I have typical scenario in which the both current running process and the
> > > interrupt handler shared the some buffer. when the current running process
> > > is running in kernel mode and accessing the buffer. during that time the
> > > interrupt has arrived. How the operating system(linux) is going to handle
> > > this scenario?
> >
> > Shared resource must be protected with spinlocks (either basic or
> > read-write spinlock, depending upon the situation or the access to
> > shared resource). Spinlock disables the local interrupts and provides
> > the synchronization across other CPu by its lock variable.
> >
> > On UP (uni processor) machine, interrupts will never occur whenever
> > you are holding the spinlock, so current process (which is in critical
> > section) will never be interrupted till the time it comes out of
> > critical section.
> >
> > On SMP machine, Interrupts will not occur on local CPU, but can occur
> > on other CPU. Interrupt handler will be executed on other CPU and will
> > keep on spining till the time the current process on local CPU does
> > not come out of spinlock and realese the spinlock. That is why its imp
> > to use the spinlocks only where the scritical section is too short and
> > in which we are sure we are not going to sleep or in other words not
> > going to give away the CPU.
> >
> > Hope it clears.
> > Cheers !!
> > Gaurav
> >
> >
> > >
> > > Thanks
> > >
> > > Manjunath
> > >
> >
> >
> > --
> > --
> > -Gaurav
> > Email: gauravd.chd@xxxxxxxxx
> > ---------------------------------
> > Read my blog at: http://lkdp.blogspot.com/
> > ---------------------------------
> >
>


--
--
-Gaurav
Email: gauravd.chd@xxxxxxxxx
---------------------------------
Read my blog at: http://lkdp.blogspot.com/
---------------------------------

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[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