中断处理程序使用哪个堆栈-Linux [英] Which stack is used by Interrupt Handler - Linux

查看:604
本文介绍了中断处理程序使用哪个堆栈-Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在多任务系统中,当任何硬件对特定CPU产生中断时,除非CPU已经在运行ISR,否则CPU可以执行以下两种情况之一:

In a multitasking system when any hardware generates a interrupt to a particular CPU, where CPU can be performing either of below cases unless it is already serving a ISR:

  1. 用户模式进程正在CPU上执行
  2. 内核模式进程正在CPU上执行

想知道在以上两种情况下中断处理程序使用哪个堆栈,为什么?

Would like to know which stack is used by interrupt handler in above two situations and why ?

推荐答案

所有中断均由内核处理.这是通过为该特定中断编写的中断处理程序完成的.对于中断处理程序,有IRQ堆栈.中断处理程序堆栈的设置是配置选项.内核堆栈的大小可能并不总是足以满足内核的工作和所需的空间 IRQ处理例程.因此,有2个堆栈出现在图片中.

All interrupts are handled by kernel. That is done by interrupt handler written for that particular interrupt. For Interrupt handler there is IRQ stack. The setup of an interrupt handler’s stacks is configuration option. The size of the kernel stack might not always be enough for the kernel work and the space required by IRQ processing routines. Hence 2 stack comes into picture.

  1. 硬件IRQ堆栈.
  2. 软件IRQ堆栈.

与每个进程分配的常规内核堆栈相反,每个CPU分配两个额外的堆栈.每当发生硬件中断(或处理softIRQ)时,内核都需要切换到 适当的堆栈. 从历史上看,中断处理程序没有接收到自己的堆栈.相反,中断处理程序将共享正在运行的进程的堆栈,并被中断.内核堆栈的大小为两页.通常,在32位体系结构上为8KB,在64位体系结构上为16KB.因为在此设置中,中断处理程序共享堆栈,所以它们在分配哪些数据方面必须格外节约.当然,内核堆栈仅限于开头,因此所有内核代码都应谨慎.

In contrast to the regular kernel stack that is allocated per process, the two additional stacks are allocated per CPU. Whenever a hardware interrupt occurs (or a softIRQ is processed), the kernel needs to switch to the appropriate stack. Historically, interrupt handlers did not receive their own stacks. Instead, interrupt handlers would share the stack of the running process, they interrupted. The kernel stack is two pages in size; typically, that is 8KB on 32-bit architectures and 16KB on 64-bit architectures. Because in this setup interrupt handlers share the stack, they must be exceptionally frugal with what data they allocate there. Of course, the kernel stack is limited to begin with, so all kernel code should be cautious.

这篇关于中断处理程序使用哪个堆栈-Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆