前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >kernel | interrupt| driver

kernel | interrupt| driver

作者头像
heidsoft
发布2022-04-18 19:37:10
6470
发布2022-04-18 19:37:10
举报

(1)中断:是一种异步的事件处理机制,可以提高系统的并发处理能力。

(2)如何解决中断处理程序执行过长和中断丢失的问题: Linux 将中断处理过程分成了两个阶段,也就是上半部和下半部。 上半部用来快速处理中断,它在中断禁止模式下运行,主要处理跟硬件紧密相关的或时间敏感的工作。也就是我们常说的硬中断,特点是快速执行。 下半部用来延迟处理上半部未完成的工作,通常以内核线程的方式运行。也就是我们常说的软中断,特点是延迟执行。

(3)proc 文件系统:是一种内核空间和用户空间进行通信的机制,可以用来查看内核的数据结构,或者用来动态修改内核的配置。 /proc/softirqs 提供了软中断的运行情况; /proc/interrupts 提供了硬中断的运行情况。

(4)硬中断:硬中断是由硬件产生的,比如,像磁盘,网卡,键盘,时钟等。每个设备或设备集都有它自己的IRQ(中断请求)。基于IRQ,CPU可以将相应的请求分发到对应的硬件驱动上。硬中断可以直接中断CPU,引起内核中相关的代码被触发。

(5)软中断:软中断仅与内核相关,由当前正在运行的进程所产生。通常,软中断是一些对I/O的请求,这些请求会调用内核中可以调度I/O发生的程序。软中断并不会直接中断CPU,也只有当前正在运行的代码(或进程)才会产生软中断。这种中断是一种需要内核为正在运行的进程去做一些事情(通常为I/O)的请求。除了iowait(等待I/O的CPU使用率)升高,软中断(softirq)CPU使用率升高也是最常见的一种性能问题。

  • I/O interrupts
  • An I/O device requires attention; the corresponding interrupt handler must query the device to determine the proper course of action. We cover this type of interrupt in the later section "I/O Interrupt Handling.”
  • Timer interrupts
  • Some timer, either a local APIC timer or an external timer, has issued an interrupt; this kind of interrupt tells the kernel that a fixed-time interval has elapsed. These interrupts are handled mostly as I/O interrupts; we discuss the peculiar characteristics of timer interrupts in Chapter 6.
  • Interprocessor interrupts
  • A CPU issued an interrupt to another CPU of a multiprocessor system. We cover such interrupts in the later section "Interprocessor Interrupt Handling.”
  1. https://cloud.tencent.com/developer/article/1518703
  2. https://www.oreilly.com/library/view/understanding-the-linux/0596005652/ch04s06.html
  3. https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/
  4. https://tldp.org/LDP/lkmpg/2.6/html/x323.html
  5. https://github.com/0voice/linux_kernel_wiki
  6. https://github.com/0voice/linux_kernel_wiki/blob/main/%E6%96%87%E7%AB%A0/%E7%BD%91%E7%BB%9C%E5%8D%8F%E8%AE%AE%E6%A0%88/Linux%E5%86%85%E6%A0%B8%E7%BD%91%E7%BB%9Cudp%E6%95%B0%E6%8D%AE%E5%8C%85%E5%8F%91%E9%80%81(%E4%B8%80).md
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-04-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 云数智圈 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档