kernel 中断分析之四——中断申请[上]

本文深入探讨了Linux内核中断处理,包括request_threaded_irq、request_irq、setup_irq、request_percpu_irq和setup_percpu_irq等接口。这些接口用于申请中断,其中request_threaded_irq支持中断线程化,允许中断处理分为硬中断上下文和底半部的线程化处理。request_irq则不涉及中断线程。setup_irq和request_percpu_irq通常用于系统早期启动或percpu中断的申请,不涉及中断线程化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言

从分析三可知,中断处理最终调用了irqaction的handler(interrupt context),在必要的情况下唤醒中断处理线程调用thread_fn(process context)。
对应的中断服务例程是在驱动初始化阶段,普通中断通过setup_irq、request_irq或者request_threaded_irq进行申请,percpu中断通过request_percpu_irq、setup_percpu_irq,本篇主要对这上接口进行分析,__setup_irq放在kernel 中断分析之四——中断申请[下]中分析。

request_threaded_irq

关于中断线程化的目的和对系统performance的提升,可以看这篇文章Moving interrupts to threads(翻译)

  1349 /**
  1350  *  request_threaded_irq - allocate an interrupt line
  1351  *  @irq: Interrupt line to allocate
  1352  *  @handler: Function to be called when the IRQ occurs.
  1353  *        Primary handler for threaded interrupts
  1354  *        If NULL and thread_fn != NULL the default
  1355  *        primary handler is installed
  1356  *  @thread_fn: Function called from the irq handler thread
  1357  *          If NULL, no irq thread is created
  1358  *  @irqflags: Interrupt type flags
  1359  *  @devname: An ascii name for the claiming device
  1360  *  @dev_id: A cookie passed back to the handler function
  1361  *
  1362  *  This call allocates interrupt resources and enables the
  1363  *  interrupt line and IRQ handling. From the point this
  1364  *  call is made your handler function may be invoked. Since
  1365  *  your handler function must clear any interrupt the board
  1366  *  raises, you must take care both to initialise your hardware
  1367  *  and to set up the interrupt handler in the right order.
  1368  *
  1369  *  If you want to set up a threaded irq handler for your device
  1370  *  then you need to supply @handler and @thread_fn. @handler is
  1371  *  still called in hard interrupt context and has to check
  1372  *  whether the interrupt originates from the device. If yes it
  1373  *  needs to disable the interrupt on the device and 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值