您的位置:首页 > 运维架构 > Linux

Linux内核-中断机制个人理解

2016-04-20 20:28 459 查看
By:Ailson Jack

Date:2016.04.08

个人博客:www.only2fire.com

本文在我博客的地址是:http://www.only2fire.com/archives/876.html,排版更好,便于学习。

对于Linux的中断,个人理解首先明白三个结构体irq_desc、irq_chip、irqaction之间的关系,把这三个结构体之间的关系搞明白之后,想要弄明白中断从触发,到最后执行中断服务程序就会比较容易,至少在内核中跟踪代码会容易些。

每个中断线都有它自己的irq_desc描述符,所有这些描述符组织在一起就形成了中断描述符数组。

1、一条中断线的中断描述结构体

中断描述符数组存放着各个中断线的中断描述符结构体。

struct irq_desc {

unsigned int irq;//这个中断线的中断号

struct timer_rand_state *timer_rand_state;

unsigned int *kstat_irqs;

#ifdef CONFIG_INTR_REMAP

struct irq_2_iommu *irq_2_iommu;

#endif

irq_flow_handler_t handle_irq;

struct irq_chip *chip;//这个中断线使用的中断控制器

struct msi_desc *msi_desc;

void *handler_data;

void *chip_data;

struct irqaction *action; /* IRQ action list *///该中断线的中断服务程序

unsigned int status; /* IRQ status */

unsigned int depth; /* nested irq disables */

unsigned int wake_depth; /* nested wake enables */

unsigned int irq_count; /* For detecting broken IRQs */

unsigned long last_unhandled; /* Aging timer for unhandled count */

unsigned int irqs_unhandled;

raw_spinlock_t lock;

#ifdef CONFIG_SMP

cpumask_var_t affinity;

unsigned int node;

#ifdef CONFIG_GENERIC_PENDING_IRQ

cpumask_var_t pending_mask;

#endif

#endif

atomic_t threads_active;

wait_queue_head_t wait_for_threads;

#ifdef CONFIG_PROC_FS

struct proc_dir_entry *dir;

#endif

const char *name;

} ____cacheline_internodealigned_in_smp;

2、描述中断控制器的结构体

这是描述中断控制器的结构体,将其封装成结构体便于管理各个不同类型的中断控制器,比如8259A和APIC。

更详细的内容见我博客的地址:http://www.only2fire.com/archives/876.html

注:转载请注明出处,谢谢!^_^
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: