首页 > 系统相关 >linux 内核中的上下文判断

linux 内核中的上下文判断

时间:2023-01-11 10:57:15浏览次数:57  
标签:count softirq re 内核 context linux 上下文 define

linux 内核中的上下文判断



linux/include/linux/preempt.h

...
/*
 * Are we doing bottom half or hardware interrupt processing?
 *
 * in_irq()       - We're in (hard) IRQ context
 * in_softirq()   - We have BH disabled, or are processing softirqs
 * in_interrupt() - We're in NMI,IRQ,SoftIRQ context or have BH disabled
 * in_serving_softirq() - We're in softirq context
 * in_nmi()       - We're in NMI context
 * in_task()	  - We're in task context
 *
 * Note: due to the BH disabled confusion: in_softirq(),in_interrupt() really
 *       should not be used in new code.
 */
#define in_irq()		(hardirq_count())
#define in_softirq()		(softirq_count())
#define in_interrupt()		(irq_count())
#define in_serving_softirq()	(softirq_count() & SOFTIRQ_OFFSET)
#define in_nmi()		(preempt_count() & NMI_MASK)
#define in_task()		(!(preempt_count() & \
			   (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)))
...


reference:
linux 中断子系统 - linux 内核中的上下文判断



标签:count,softirq,re,内核,context,linux,上下文,define
From: https://www.cnblogs.com/WangYangkai/p/17043110.html

相关文章