Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Polling or Interrupt based method

When should one use polling method and when should one use interrupt based method ? Are there scenarios in which both can be used ?

like image 939
Karthik Balaguru Avatar asked Jun 18 '10 20:06

Karthik Balaguru


People also ask

Which one is better polling or interrupt?

It is much better to go with Interrupt based design compared to polling based because polling based is flawed in the sense that it expects the data to be returned on every poll.

Why is it better to use an interrupt over polling?

So between the two methods, the interrupt is more advantageous than polling because the microcontroller can serve many devices (not all at the same time, of course) based on the priority assigned to it. The polling method cannot assign priority because it checks all devices in a round-robin fashion.

Is polling more efficient method than interrupt driven method?

The first advantage is- the performance of microcontroller is far better in Interrupt method than Polling Method. In polling method, the microcontroller is checking continuously whether the device is ready or not, but the chances of data loss are greater in Polling than Interrupt.

What is polling interrupt system?

In a computer, a polled interrupt is a specific type of I/O interrupt that notifies the part of the computer containing the I/O interface that a device is ready to be read or otherwise handled but does not indicate which device.


1 Answers

If the event of interest is:

  1. Asynchronous
  2. Urgent
  3. Infrequent

then an interrupt based handler would make sense.

If the event of interest is:

  1. Synchronous (i.e. you know when to expect it within a small window)
  2. Not Urgent (i.e. a slow polling interval has no ill effects)
  3. Frequent (i.e. majority of your polling cycles create a 'hit')

then polling might be a better fit.

Other considerations include whether you are writing a device driver for an OS or just writing bare metal code with no thread support. In bare metal situations the CPU is often just looping when it isn't busy so it might as well be polling something.

like image 69
Amardeep AC9MF Avatar answered Sep 27 '22 19:09

Amardeep AC9MF