Difference Between Polling and Interrupt

To keep an electronic device like computers safe and to avoid any problems that might occur to it, there are a few things and steps that must be taken. When a device completes a certain task assigned by the user, the device performs it and finds out whether the task is completed or not. There are ways that a user can use to find it out. These ways include 1.Polling and 2. Interrupt. The user either polls the device, or it can use interrupts.

Polling vs Interrupt

The main difference between polling and interrupt is the roles that they play in the functioning of a device. In polling, the device is thoroughly and repeatedly surveyed if it requires servicing. On the other hand, in interrupt, the device is notified when it needs servicing. In other words, polling is a protocol, an interrupt is a hardware mechanism.

The process in which the device is surveyed to ensure if there is any need for servicing is known as polling. It is a coeval procedure. It is also considered a polled I/O or software-driven I/O. In the polling process, an external device is used to check the condition of the computer. Until the device is ready, the process is continued, and if the device is not ready, it is shifted to a different task. The process has its independent properties, advantages, and disadvantages.

The hardware mechanism which notifies the device whenever it requires servicing is known as an interrupt. It notifies the computer whenever it requires to be attended by software. It makes sure the ongoing task is completed on time. This process is temporary only when the problem is not serious. If the problem is not serious, then the device returns to its activities.

Comparison Table Between Polling and Interrupt

Parameters of ComparisonPollingInterrupt
MeaningThe concurrent process in which the device is surveyed to ensure any need for servicing is known as polling.The hardware mechanism that notifies the device whenever it requires servicing and needs to be attended by software is an interrupt.
Type ofProtocolHardware mechanism
OccurenceAt regular intervals of time.At any instance of time.
DeviceThe device is mended by the CPU.The device is overhauled by interrupt handlers.
Form of indicationCommand ready bit is used to inform the device.The request line is used to inform the device.

What is Polling?

The process in which the device is surveyed to ensure if there is any need for servicing is known as polling. It is a coeval procedure. It is also considered a polled I/O or software-driven I/O. Low-level hardware is involved in this process. It can take a lot of time if multiple devices are to be checked and surveyed.

The process of polling takes place in two steps, namely host actions and controller actions. In host actions, the busy-bit is completely read by the host. Once the busy bit is cleared, the command-ready bit is set to 1 by the host. Before setting the command-ready bit to 1, the command is written to the command register by the host.

The second step is the controller actions. In this step, the command-ready bit is already set to 1, and this is noted by the controller. The controller then puts the busy bit to 1. It is the controller who reads and performs the I/O operations after reading the command register and ensuring the presence of a write bit in it. The operations are cleared and are shown to be successful.

Polling can be used to control the information sequence of elements involved in measuring contexts and also their execution. It can be used to administer the time of the processor along with other resources in multitasking operating systems. Although the probability that the data can be wasted is much higher in polling.

What is Interrupt?

The hardware mechanism which notifies the device whenever it requires servicing and needs to be attended by software is known as an interrupt. It notifies the computer whenever it requires to be attended by software. It makes sure the ongoing task is completed on time. It is a type of hardware mechanism.

There are two types of interrupts, namely, hardware interrupt and software interrupt. In hardware interrupt, external hardware notifies the condition of the hardware. In software interrupt, a processor requests the interrupt when a certain condition takes place. A particular interrupt handler ought to be associated with a software interrupt.

The software interrupts can be either intentional or unexpected. Special instruction is induced to intentionally cause a software interrupt. Program execution errors that take place can cause unexpected software interruptions. Based on the triggering methods, there are two types of interrupts, namely level-triggered interrupt and edge-triggered interrupt.

The occurrence of interrupts result in increased efficiency of the CPU, and the waiting time of the CPU is decreased. The wastage of the instruction cycle is also stopped because of interrupts. Some disadvantages of interrupts are that the CPU has to carry out a lot of tasks as it has to return to its previous program.

Main Differences Between Polling and Interrupt

  • In polling, the performance of the microcontroller is poor. On the contrary, in interrupt, the performance of the microcontroller is great.
  • In polling, all the processor cycles are wasted while checking the device. On the other hand, in interrupt when a certain device interrupts a processor, the processor is disturbed.
  • In polling, the CPU is put on hold. On the other hand, in interrupt, the CPU is called if required.
  • Polling takes place at regular intervals of time. On the other hand, interrupt takes place at any instance of time.
  • Polling is a type of protocol. On the other hand, interrupt is a type of hardware mechanism.
  • Conclusion

    Both processes result in making the device efficient, and it gives us a hassle-free experience when we use it. Both processes are important to keep the device safer and better.

    Both the processes have their advantages and disadvantages. The advantages are far more helpful. The disadvantages ought to be resolved in forthcoming years with more technological development.

    References

  • https://link.springer.com/chapter/10.1007/978-1-349-16651-0_9
  • https://ieeexplore.ieee.org/abstract/document/558057/
  • ncG1vNJzZmiZo6Cur8XDop2fnaKau6SxjZympmeUnrOnsdGepZydXZeytcPEnqVmqJ%2Bhuaq6xmaYp5xdnru1sdGrrKmsXw%3D%3D