打断:
中断是一种硬件机制,在这种机制中,设备通知 CPU 它需要它的注意。中断可以随时发生。因此,当 CPU 通过指示中断请求线获得中断信号时,CPU 停止当前进程并通过将控制权传递给服务于设备的中断处理程序来响应中断。
轮询:
轮询不是硬件机制,它是CPU稳定检查设备是否需要注意的协议。只要设备告诉处理单元它需要硬件处理,轮询处理单元就会不断询问 I/O 设备是否需要 CPU 处理。 CPU 不断检查与其相连的每一个设备,以确定是否有任何设备需要硬件关注。
每个设备都有一个命令就绪位,用于指示该设备的状态,即它是否是某个命令被硬件终止。如果命令位准备好为 1,那么它是某个命令死了,如果位为零,那么它就是没有命令。
让我们看看中断和轮询的区别:
S.NO | Interrupt | Polling |
---|---|---|
1. | In interrupt, the device notices the CPU that it requires its attention. | Whereas, in polling, CPU steadily checks whether the device needs attention. |
2. | An interrupt is not a protocol, its a hardware mechanism. | Whereas it isn’t a hardware mechanism, its a protocol. |
3. | In interrupt, the device is serviced by interrupt handler. | While in polling, the device is serviced by CPU. |
4. | Interrupt can take place at any time. | Whereas CPU steadily ballots the device at regular or proper interval. |
5. | In interrupt, interrupt request line is used as indication for indicating that device requires servicing. | While in polling, Command ready bit is used as indication for indicating that device requires servicing. |
6. | In interrupts, processor is simply disturbed once any device interrupts it. | On the opposite hand, in polling, processor waste countless processor cycles by repeatedly checking the command-ready little bit of each device. |