Subject: Re: how to detect if kernel is running in interrupt ctx
To: Jaromir Dolecek <jdolecek@netbsd.org>
From: Ming Lei <lei.ming@attbi.com>
List: tech-kern
Date: 06/29/2003 22:25:42
sometimes a code segment may be used by both ISR or normal kernel code. ISR
doesnt live in user context, so cannot block or sleep. In normal kernel
code, the code can block or sleep. Malloc flag is one example.

Is there any way to detect if the code is running in interrupt, even in a
archtect dependent way, such as, cpu register?

----- Original Message -----
From: "Jaromir Dolecek" <jdolecek@netbsd.org>
To: "Ming Lei" <lei.ming@attbi.com>
Cc: <tech-kern@netbsd.org>
Sent: Sunday, June 29, 2003 7:08 AM
Subject: Re: how to detect if kernel is running in interrupt ctx


> Ming Lei wrote:
> > In linux, there is a macro called in_interrupt which can tell if the
kernel
> > is running in interrupt(including hardware or software) or not because
linux
> > changes some flags when in or out of the interrupt. Is there any same
> > facility in netbsd?
>
> In NetBSD, the code needs to be structured so that the driver code
> would know whether it's running from interrupt or not. Normally
> you shouldn't even worry about this, typically most of driver code
> runs from within interrupt handler (driver's foo_intr() routine).
>
> Why would you need to distinguish the two cases?
>
> Jaromir
> --
> Jaromir Dolecek <jdolecek@NetBSD.org>            http://www.NetBSD.cz/
> -=- We should be mindful of the potential goal, but as the tantric    -=-
> -=- Buddhist masters say, ``You may notice during meditation that you -=-
> -=- sometimes levitate or glow.   Do not let this distract you.''     -=-