0 votes
in Cache Technique by
What is Difference between Interrupt and Polling in Operating System

1 Answer

0 votes
by

An OS generally serves as a bridge between system hardware and user programs. The processor is the part of the OS that handles the tasks of the entire system. It is sometimes important to interrupt the currently running task and take rapid action. There are two types of mechanisms which interrupt and polling.

Interrupt and polling is two methods for dealing with events generated by devices that may occur at any time while the CPU is busy running another activity. The polling and interrupt methods allow the processor to pause what it is doing and respond to an essential task. Polling and interrupt are quite different in several ways. The main difference between polling and interrupt is that the CPU checks I/O devices at regular intervals in polling to see whether they require CPU service. On the other hand, in the interrupt method, the input/output device interrupts the processor and alerts it that it requires processor service.

Difference between interrupt and polling in the operating system. But before discussing the differences, you must know about the interrupt and polling in the operating system.

What is Interrupt?

An interrupt is a signal to the processor to take immediate action. An interrupt may be used to signify the end of a timer, and an interrupt may also notify a networking device about received data packets. When an interrupt happens, the processor stops the existing task and runs the connected interrupt handler, which is referred to as an Interrupt Service Routine (ISR). After managing the interrupt, it returns to the previously executed tasks. It has two types of interrupts hardware and software interrupts.

1. Hardware Interrupt

Devices use hardware interrupts to notify the OS of requiring its attention. For instance, a hardware interrupt occurs when a key is pressed on the keyboard, and it causes the CPU to read that keystroke. Interrupt requests (IRQ) are used to start hardware interrupts. There is an interrupt number for each hard interrupt, and the number identifies the hardware that produces the interrupt. As a result, the CPU may identify the device. Hardware interrupts come in two varieties: maskable interrupts and non-maskable interrupts. Non-maskable interrupts could not be delayed by the CPU, whereas maskable interrupts may be delayed.

2. Software Interrupt

An interrupt caused by an exceptional CPU condition, or a running program is referred to as software interrupt. A software interrupt can be triggered by dividing an integer by zero. In addition, incorrect variables and memory leaks produced by infinite loops may create software interrupt.

What is polling?

Polling is the process of surveying the device to determine whether it needs any servicing. It's also known as a polled Input/Output or software-driven Input/Output. A low-level hardware component is used in this procedure. If several devices need to be examined, it may take a lot of time.

Host and controller actions are the two steps that make up the polling process. The host entirely reads the busy-bit during host actions. The command-ready bit is set to 1 by the host once the busy bit has been cleared. The host writes the command to the command register before changing the command-ready bit to 1.

The second stage is to perform controller actions. The controller notices that the command-ready bit is already set to 1 during this phase, and the controller then sets the busy bit to 1. After reading the command register and confirming that it contains a write bit, the controller reads and executes the I/O operations. The operations have been approved and proven to be successful.

Polling could be used to regulate the information sequence and execution of elements engaged in measuring contexts. It could be used to manage the processor's time as well as other resources in multitasking OS. However, there is a considerably higher chance of data waste with polling.

Key differences between Interrupt and Polling in Operating System

Difference between Interrupt and Polling in Operating System

There are various key differences between Interrupt and Polling in the operating system. Some main differences between Interrupt and Polling are as follows:

  • The microcontroller's performance is much lower in pooling. In contrast, the microcontroller's performance in the interrupt is significantly higher.
  • The interrupt method is hardware as the processor has a wire called the interrupt-request line, providing signals when an interrupt has occurred. In contrast, polling is a protocol that continuously checks the control bits to determine whether a device has the stuff to execute.
  • Polling becomes wasteful when the processor continues to poll the gadget and rarely finds any gadget ready for servicing. In contrast, Interrupts become wasteful when devices constantly interrupt CPU operations.
  • The CPU is only interrupted in interruptions when another device interrupts it. In contrast, polling wastes a lot of CPU cycles by repeatedly checking each device's command-ready bit.
  • The interrupt handler handles the devices' interrupts. On the other hand, polling involves the CPU servicing the device as needed.
  • In an interrupt mechanism, the device alerts the CPU that it requires maintenance. In contrast, in polling, the CPU continuously determines whether a device requires maintenance.
  • An interrupt happens at any time. On the other hand, the CPU keeps polling the device at regular intervals.
  • The interrupt-request line serves as a signal for interrupts. In contrast, in polling, the Command-ready bit signifies that the device requires maintenance.

Head-to-head comparison between the Interrupt and Polling in Operating System

The operating system has various head-to-head comparisons between Interrupt and Polling. Some comparisons of the Interrupts and Polling are as follows:

FeaturesInterruptPolling
DefinitionAn interrupt is an occurrence that signals the CPU to do a certain action and is caused by components outside the CPU.A synchronous process in which a client program checks the status of an external device is known as polling.
BasicThe device determines the processor that it requires CPU attention.The CPU regularly checks the device status and whether it requires the processor's attention.
IndicationThe interrupt-request line serves as a signal for interrupts.The Command-ready bit signifies that the device requires to be serviced.
MechanismIt is a hardware Mechanism.It is a Protocol.
EfficiencyInterrupts become inefficient when devices constantly interrupt CPU operations.It becomes wasteful when the CPU continues to poll the gadget and rarely finds any gadget ready for servicing.
CPU cyclesThe CPU is only interrupted when a device requires servicing, which saves CPU cycles.The CPU must wait to determine whether a device requires servicing, which consumes many CPU cycles.
OccurrenceAn interrupt happens at any time.The CPU keeps polling the device at regular intervals.
ServicingThe device is serviced by the interrupt handler.The CPU services the gadget.

 

Conclusion
Polling and Interrupts are both effective in attending to I/O devices. However, they may become inadequate under specific conditions. Polling involves a cyclic reading of devices linked to a single CPU. When the external logic circuit does not require repair, the microcomputer moves on to the next external logic circuit to be examined if one of the external logic circuits requires maintenance, the CPU switches to running a program to serve it.
When the CPU is interrupted at the request of external logic, the microcomputer suspends the execution of its existing program and switches to the interrupted program. Because of the interrupted structure, the microprocessor may respond to asynchronous events such as external logic requests without having to wait in the loop to check the state of the external logic circuit.

Related questions

0 votes
asked Nov 13, 2022 in Operating System by john ganales
0 votes
asked Aug 17, 2021 in Security Assessment by Robindeniel
...