抢占式中断处理程序会发生什么? [英] What happens to preempted interrupt handler?

查看:326
本文介绍了抢占式中断处理程序会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使在一些写得很好的内核书籍中,我也找不到以下问题的正确答案:

I could not find a proper answer for the following questions even in some well written kernel books:

  1. 他们说ISR无法入睡,因为由于ISR与任何进程都没有连接,因此它不可能重新调度ISR,那么,如果优先级较高的中断抢占了正在执行的ISR,会发生什么情况?被中断的ISR不会重新安排(执行)吗?如果是,如何&谁来做这项工作?

  1. They are saying that an ISR can't sleep because its not possible to reschedule an ISR as it is not connected with any process , so what happens when a higher priority interrupt preempt the executing one? the interrupted ISR will not rescheduled(execute) again ? if yes how & who will do that work?

很多时候我们将禁用中断(例如:1.在关键区域2.执行快速中断时,它将禁用当前处理器中的所有中断),因此对于正在发生的中断会发生什么什么时候禁止中断?他们只是被丢弃?或将存储在某个地方以供以后执行?如果是,则&怎么样?

many time we will disable interrupt (eg: 1.In critical region 2. When a fast interrupt is executing it will disable all the interrupt in the current processor) , so what will happen for the interrupts that are occurring when interrupts are disabled ? they are simply discarded? or will be stored somewhere for later execution? if yes where & how?

在执行ISR时,它将禁用当前IRQ行中的中断,以避免重入(防止执行同一行中的另一个ISR),但是为什么呢?如果ISR重入,怎么了?

when an ISR is executing it will disable interrupt in the current IRQ line to avoid reentrant(preventing another ISR on the same line from being executed), but why? whats wrong if an ISR is reentrant?

* ISR =中断服务程序

*ISR=Interrupt Service Routine

*他们=书的作者

推荐答案

  1. 是的,在OS中,只有任务以RR方式存储.调度的目的是共享CPU资源,公平地将CPU的执行力分配给每个正在运行的任务.中断本身是用来处理特定事件的,每个中断都有自己的优先级.高优先级中断可能会抢占正在运行的低优先级ISR.

  1. Yes, in OS, only tasks is scedhuled in RR fashion. The goal of scheduling is to share CPU resource, fairly share CPU's execution power to each running tasks. The interrupt itself, is to handle a specific event and each interrupt has its own priority. Higher priority interrupt may preempt the running low priority ISR.

它的工作方式基于中断控制器上的中断屏蔽寄存器,当ISR启动时,将屏蔽寄存器设置为禁用优先级较低的中断,并在ISR返回之前,将屏蔽寄存器恢复为允许较低优先级的中断.

How it works is based on a interrupt mask register on interrupt controller, when ISR starts it set the mask register to disable interrupts with lower priorities, and before ISR return, it restore the mask register to allow lower priority interrupts.

中断处理请求是由硬件设备提出的,它在数据到达时将中断引脚下拉到中断控制器.如果禁用了中断功能(设置了掩码),则来自硬件的请求将被挂起,并且中断引脚将保持低电平.一旦启用了中断(屏蔽已清除),该中断将再次发生.

The interrupt handle requests is proposed by hardware device, it pull down an interrupt pin to the interrupt controller when data arrival. If the intterupt is disabled ( mask is set ), the request from hardware is pending and the interrupt pin is kept low. The interrupt will happen again once the interrupt is enabled (mask is clear).

CPU将连续触发中断并最终导致堆栈溢出!

The CPU will continously trigger interrupts and eventaully get stackoverflow!

这篇关于抢占式中断处理程序会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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