What happens when you disable interrupts, and what do you do with interrupts you don't know how to handle?

前端 未结 2 1312
太阳男子
太阳男子 2021-02-08 13:42

When you disable interrupts (with the cli instruction in x86), what exactly happens?

  • Does the PIC wait for you to turn on interrupts, and fire the

2条回答
  •  灰色年华
    2021-02-08 14:00

    The interrupts still fire, but the CPU isn't listening. When you start listening again (sti), the signal is still there and will take effect at the first opportunity.

    A PC PIC has several levels of interrupts, and I believe it can hold one active interrupt for each priority level. It will keep each one of them until the CPU tells it that the corresponding handling is completed. Having interrupts disabled for an extended period of time will probably break this, so just don't do that!

    The device responsible for an interrupt will not get any response while waiting - which is kind of a response anyway. If it can't wait, it might enter some error state that the CPU will see when it eventually comes around.

    You will only get the interrupts you have explicitly enabled, so there should be no surprises. The device driver turning on an interrupt has better know how to handle it.

提交回复
热议问题