2002-12-03 05:58:08

by Madhavi

[permalink] [raw]
Subject: in_irq()


Hi

I am using a UP system with CONFIG_SMP=y in .config with linux 2.4.19
kernel.

I have this piece of code:

spin_lock_irqsave(&some_lock, flags);
in_irq();
spin_unlock_irqrestore(&some_lock, flags);

I have read somewhere (I think its given in the Unreliable Guide to
kernel locking) that in_irq() returns true when the interrupts
are blocked. So, I was expecting in_irq() to return true here. But, it is
returning 0 here.

I have gone through the code and it seems that the __local_irq_count is
getting incremented only in irq_enter(). So, the behavior I am getting
seems to be correct.

## Could someone tell me which is the correct behavior of in_irq()?

## I have one more doubt. If I have a thread in which I do
spin_lock_irqsave(&some_lock, flags), can I expect the main kernel thread
also not to service any interrupts? I am getting replies to ping packets
when the thread is doing spin_lock_irqsave(), which means that all
hardware interrupts are not blocked. How can I block all hardware
interrupts?

Thanks in advance.

regards
Madhavi.


2002-12-04 16:01:06

by Davide Rossetti

[permalink] [raw]
Subject: Re: in_irq()

On Tue, 3 Dec 2002, Madhavi wrote:

>
> Hi
>
> I am using a UP system with CONFIG_SMP=y in .config with linux 2.4.19
> kernel.
>
> I have this piece of code:
>
> spin_lock_irqsave(&some_lock, flags);
> in_irq();
> spin_unlock_irqrestore(&some_lock, flags);
>
> I have read somewhere (I think its given in the Unreliable Guide to
> kernel locking) that in_irq() returns true when the interrupts
> are blocked. So, I was expecting in_irq() to return true here. But, it is
> returning 0 here.

I think it is intended to return true only if you are in an interrupt
context.... that is in the context of a iterrupt handler...

ciao


--
______/ Rossetti Davide INFN - Roma I - APE group \______________
pho +390649914507/412 web: http://apegate.roma1.infn.it/~rossetti
fax +390649914423 email: [email protected]