Re: How to check bottom half vs user context ?

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

 




See include/linux/hardirq.h

in_irq() returns true when in interrupt handler;
in_softirq() returns true when in bottom-half (softirq,tasklet)
in_interrupt() returns true when in interrupt handler or bottom-half

#define hardirq_count() (preempt_count() & HARDIRQ_MASK)
#define softirq_count() (preempt_count() & SOFTIRQ_MASK)
#define irq_count() (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK))
/*
* Are we doing bottom half or hardware interrupt processing?
* Are we in a softirq context? Interrupt context?
*/
#define in_irq() (hardirq_count())
#define in_softirq() (softirq_count())
#define in_interrupt() (irq_count())

Hope, it helps.

Bruce Moffat 写道:
Hi,
I am looking for a way to test whether I am running in a bottom half context or user context. There are kernel functions which may be called from both user and bottom half contex. For eg, tcp_transmit_skb, may be called from user context for first time transmission of a packet or from the timer bottom half in case of retransmission. Is there a way to check within that function whether it is currently running in user / bottom half context?
Any hints greatly appreciated !
Regards,

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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