jtht
jtht

Reputation: 813

Polling vs. Interrupts with slow/fast I/O devices

I'm learning about the differences between Polling and Interrupts for I/O in my OS class and one of the things my teacher mentioned was that the speed of the I/O device can make a difference in which method would be better. He didn't follow up on it but I've been wracking my brain about it and I can't figure out why. I feel like using Interrupts is almost always better and I just don't see how the speed of the I/O device has anything to do with it.

Upvotes: 1

Views: 3229

Answers (2)

user3344003
user3344003

Reputation: 21607

The only advantage of polling comes when you don't care about every change that occurs.

Assume you have a real-time system that measures the temperature of a vat of molten plastic used for molding. Let's also say that your device can measure to a resolution of 1/1000 of a degree and can take new temperature every 1/10,000 of a second.

However, you only need the temperature every second and you only need to know the temperature within 1/10 of a degree.

In that kind of environment, polling the device might be preferable. Make one polling request every second. If you used interrupts, you could get 10,000 interrupts a second as the temperature moved +/- 1/1000 of a degree.

Polling used to be common with certain I/O devices, such as joysticks and pointing devices.

That said, there is VERY little need for polling and it has pretty much gone away.

Upvotes: 2

Keiwan
Keiwan

Reputation: 8251

Generally you would want to use interrupts, because polling can waste a lot of CPU cycles. However, if the event is frequent, synchronous (and if other factors apply e.g. short polling times...) polling can be a good alternative, especially because interrupts create more overhead than polling cycles.

You might want to take a look at this thread as well for more detail: Polling or Interrupt based method

Upvotes: 1

Related Questions