linux系统硬件中断、软件中断、tasklet、workqueue的简介

本文介绍了Linux系统中的硬件中断概念,包括中断控制器如何处理中断请求,并提及多核CPU中断控制器的工作方式。强调了硬件中断处理程序的注册过程以及中断处理程序应具备的快速响应特性。此外,还提到了Linux禁止硬件中断嵌套的特点,为避免阻塞,耗时操作将通过软中断、tasklet和workqueue在中断下半部执行。
摘要由CSDN通过智能技术生成

一、硬件中断

嵌入式系统一般都有一个"独立自主运行"的中断控制器,用于接收外部设备的各种中断请求信号。如下图所示,当有来自外部的未被屏蔽的中断信号时,中断控制器会产生一个公共的中断请求信号INT,送至CPU。当CPU响应中断时会发起INTA信号送往中断控制器。中断控制器会把优先级最高的中断源对应的中断号经系统总线送给CPU,作为CPU查找中断服务程序入口地址的依据。所以,硬件中断属于嵌入式系统的硬件资源,硬件设计完成后,对应的中断源数量就确定了。

在这里插入图片描述
多核CPU的中断控制器如下图所示:
在这里插入图片描述
前面讲到,当外部中断信号产生,CPU响应中断后会根据中断源(中断号)查找对应的中断处理程序进行执行。而linux设备驱动是通过request_irq函数来注册中断处理程序。在kernel3.18中实际执行的是request_threaded_irq函数。

/**
 *	request_threaded_irq - allocate an interrupt line
 *	@irq: Interrupt line to allocate
 *	@handler: Function to be called when the IRQ occurs.
 *		  Primary handler for threaded interrupts
 *		  If NULL and thread_fn != NULL the default
 *		  primary handler is installed
 *	@thread_fn: Function called from the irq handler thread
 *		    If NULL, no irq thread is created
 *	@irqflags: Interrupt type flags
 *	@devname: An ascii name for the claiming device
 *	@dev_id: A cookie passed back to the handler function
 *
 *	This call allocates interrupt resources and enables the
 *	interrupt line and IRQ handling. From the point this
 *	call is made your handler function may be invoked. Since
 *	your handler function must clear any interrupt the board
 *	raises, you must take care both to initialise your hardware
 *	and to set up the interrupt handler in the right order.
 *
 *	If you want to set up a threaded irq handler for your device
 *	then you need to supply @handler and @thread_fn. @handler is
 *	still called in hard interr
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值