禁用中断是什么意思?

发布于 2024-09-13 02:40:50 字数 241 浏览 14 评论 0原文

当进入中断处理程序时,我们首先在该 cpu 上“禁用中断”(使用类似于 x86 上的 cli 指令)。在中断被禁用期间,假设用户按下键盘上的字母“a”,这通常会导致中断。但是,由于中断被禁用,这是否意味着:

  1. “a”的中断处理程序永远不会被调用,因为中断在关键部分被禁用,或者
  2. 中断将由操作系统处理,但会被延迟,直到再次启用中断。 具体来说,如果用户第一次按“a”是在禁用中断的情况下,是否需要再次按“a”?

When entering an inteerupt handler, we first "disable interrupts" on that cpu(using something like the cli instruction on x86). During the time that interrupts are disabled, assume say the user pressed the letter 'a' on the keyboard that would usually cause an interrupt. But since interrupts are disabled, does that mean that:

  1. the interrupt handler for 'a' would never be invoked, since interrupts are disabled in the critical section or
  2. the interrupt will be handled by the os but delayed, until interrupts are enabled again.
    Specifically, will the user need to press 'a' again, if the first time he pressed 'a' was at a time when interrupts were disabled ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

清君侧 2024-09-20 02:40:50

通常,一个中断由硬件“排队”。

[中断通常只是一个可以持续存在的逻辑门;一旦打开,它会保持一段时间。]

如果用户仅在禁用中断的时间间隔内按一次“a”,则在重新启用中断时,它将注册为中断。

如果用户以某种方式设法在禁用中断的时间间隔内按两次“a”,则在启用中断时将注册为中断。是第一个还是第二个取决于确切的逻辑门配置。

Often, one interrupt is "queued" by hardware.

[An interrupt is often just a logic gate that can stick on; once it's on, it stays on for a while.]

If the user hit 'a' once only during the interval when interrupts were disabled, it would register as an interrupt when they were re-enabled.

If the user somehow managed to hit 'a' twice during the interval when interrupts were disabled, one would register as an interrupt when they where enabled. Whether it was the first or the second depends on the exact logic gate configuration.

软的没边 2024-09-20 02:40:50

答案是,这取决于您是否已经在处理键盘中断。

大多数中断服务例程 (ISR) 在其终止处都有代码,通知硬件它已被“服务”。对于键盘控制器,命令被写入其中以确认接收到的字节。在确认时,键盘控制器硬件停止用电来发出中断条件信号。

如果您正在处理非键盘中断,例如火警中断,则当按下按键时,以电气方式断言中断的键盘硬件将触发。在 CPU 再次启用中断之前,电信号将被忽略。在火灾报警中断服务结束时,火灾报警 ISR 会确认所有数据并重新启用 CPU 上的中断。 CPU 立即进入中断,因为键盘控制器仍在用电信号发出中断条件。

如果您正在处理键盘中断,并且用户在执行键盘 ISR 期间快速键入第二次击键,则有可能会丢失第二次击键的数据,或者稍后接收到该数据如果有的话。特别是,如果 ISR 通过确认重置键盘控制器,但 ISR 实际上并未从键盘控制器接收到所有可用字节,那么这就是一个问题。

通常,ISR 将首先处理触发其激活的中断,然后在确认中断后,轮询设备以查看自第一个中断以来它是否收到了更多数据。如果是,则生成软件中断以重新进入 ISR 并为设备提供服务。

The answer is that it depends on whether you were already handling a keyboard interrupt.

Most interrupt service routines (ISR) have code at the termination of them which informs the hardware that it has been "serviced." In the case of the keyboard controller, commands are written to it acknowledging the received bytes. It is at the time of acknowledgement that the keyboard controller hardware stops using electricity to signal an interrupt condition.

If you are handling a non-keyboard interrupt, let's say the fire alarm interrupt, then the keyboard hardware which electrically asserts the interrupt will trigger as the key is pressed. The electrical signal is ignored until the CPU has interrupts enabled again. At the end of servicing the fire alarm interrupt, the fire alarm ISR acknowledges whatever data and re-enables interrupts on the CPU. Immediately, the CPU enters an interrupt because the keyboard controller is still electrically signalling an interrupt condition.

If you are handling a keyboard interrupt, and the user quickly types a second keystroke during the execution of your keyboard ISR, then there is a chance of missing the data from the second keystroke, or of receiving it later if at all. In particular, if the ISR resets the keyboard controller through an acknowledge, but the ISR has not actually received all the available bytes out of the keyboard controller, then that is a problem.

Often, an ISR will first handle the interrupt which triggered its activation, then after acknowledging the interrupt, poll the device to see if it has received more data since the first interrupt. If so, generate a software interrupt to re-enter the ISR and service the device.

撩人痒 2024-09-20 02:40:50

简单的答案是中断会自动禁用更多中断。中断应该并且仅在最短的时间内被禁用。原始 AT BIOS 键盘 ISR 中的第一条指令是 STI,用于启用中断。

令人高兴的答案是 PIC 优先考虑硬件中断即使启用了中断,也只有定时器中断 IRQ0 可以中断键盘 ISR。当然,NMI 可能以任何一种方式发生,但幸运的是,这种情况在当前的 PC 上永远不会发生。

The simple answer is that an interrupt automatically disables further interrupts. Interrupts should and are disabled for the shortest time only. The first instruction in the original AT BIOS keyboard ISR was STI to enable interrupts.

The happy answer is that the PIC prioritizes the hardware interrupts and even with interrupts enabled only the timer interrupt IRQ0 can interrupt the keyboard ISR. Of course a NMI can occur either way but happily this never occurs on a current PC.

对风讲故事 2024-09-20 02:40:50

在正常的中断处理过程中,用户实际上不可能按两次“a”。即使他一次按下两个键,这种情况也极不可能发生,但硬件应该至少保留一个键,直到 CPU 准备好获取它。

在 PC 上——这可以追溯到我的 PCXT 时代——键盘子系统可以容纳 CPU 的 13 个按键。

It would be physically impossible for a user to press "a" twice during the normal processing of an interrupt. It would be terribly unlikely even if he pressed two keys at a time, but the hardware should hold at least one key until the CPU is ready to get it.

On PCs--this is reaching WAY back to my PCXT days--the keyboard subsystem may hold in the area of 13 key presses for the CPU.

冬天旳寂寞 2024-09-20 02:40:50

禁用中断有不同的证据。
1、硬件故障
2.exceptions { 例如:除以零 }
等等。

  1. 当硬件故障发生时,操作系统必须运行混合。
  2. 当异常发生时,操作系统必须管理系统并切换另一个进程来处理中断。

或者例如:对于 I/O 设备。
如果没有中断,计算机就没有效率!

Disable interupt have diffrent proof.
1. Hardware fault
2.exceptions { for example: Divide by zero }
and ect.

  1. when hardware fault occure, the os must operate blend.
  2. when the Exception occure, os must mangae the system and switch another process to handle interupt.

Or for example : for I/O device.
if the interupt was not, the computer wasn't efficiency!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文