Как процессор узнает, когда происходит прерывание?

1095
IamCarbonMan

Я пишу эмулятор и не могу найти информацию об этом. Что я знаю, так это то, что устройства запускают импульс на проводе IRQ. Но объяснения онлайн не включают, как процессор справляется с этим. Вызывает ли прерывание буквально процессор все бросить и позаботиться об этом? Или процессор проверяет состояние IRQ во время каждого цикла? А как насчет других способов обработки прерываний? Например, Nintendo Game Boy, очевидно, использует зарезервированное место в памяти в качестве флага прерывания, который сообщает центральному процессору, где вызывать подпрограмму для обработки этого прерывания (мое лучшее предположение, что этот флаг записывается DMA). Это распространено или стандартно в старых системах?

0

1 ответ на вопрос

1
sawdust

What I know is that devices trigger a pulse on the IRQ wire.

Maybe a pulse, but more common a level is asserted.
Only after the interrupt is acknowledged is the request line de-asserted.

Does an interrupt literally cause the CPU to drop everything and take care of it?

Effectively yes, in an orderly manner. That's why it's called an "interrupt".

Or does the CPU check the state of the IRQ during each cycle?

No the CPU is literally interrupted (at the completion of an instruction).
But if you look deeper, i.e. how does the CPU itself work, then there is a state machine that examines the IRQ line.

For example, the Nintendo Game Boy apparently uses a reserved location in memory as an interrupt flag, which tells the CPU where to call a subroutine for handling that interrupt

That vaguely sounds like an interrupt vector, which is used in many CPU architectures. But it's not used as an "interrupt flag".

Your questions seem to indicate that you have a weak grasp of that is external to a CPU and what is internal to a CPU. For instance the CPU executes machine instructions fetched from memory. Internal to the CPU there's an instruction decoder. If you describe this internal operation as "the CPU decodes the instruction", then you've created a problem differentiating external versus internal (low-level) operations.

Похожие вопросы