how to determine whether in irq context

bojan prtvar prtvar.b at gmail.com
Wed Dec 28 10:39:40 EST 2011


On Wed, Dec 28, 2011 at 10:20 AM, loody <miloody at gmail.com> wrote:
> Dear all:
> i remember there is a marco for us to determine whether we are located
> in irq context.
> I forget what it is.
> Would anyone know what it is?
>
>
> --
> Thanks for your help
Hi,
This is copy/paste from <linux/hardirq.h>:

  /*
   * Are we doing bottom half or hardware interrupt processing?
   * Are we in a softirq context? Interrupt context?
   * in_softirq - Are we currently processing softirq or have bh disabled?
   * in_serving_softirq - Are we currently processing softirq?
   */
  #define in_irq()                (hardirq_count())
  #define in_softirq()            (softirq_count())
  #define in_interrupt()          (irq_count())
 #define in_serving_softirq()    (softirq_count() & SOFTIRQ_OFFSET)

Regards,
Bojan



More information about the Kernelnewbies mailing list