Polling

© 2003 by Charles C. Lin. All rights reserved.

Introduction

Before interrupts were used as a mechanism for I/O, CPUs used to have to "poll" an I/O device to check its status. For example, you might be printing to the printer, and waiting until the print job is complete.

The word polling probably comes from politics where you take a poll to see the opinions of the electorate or citizenry. In a computer, polling means determining the status of an I/O device with direct action taken by the CPU. Polling is often contrasted with interrupts where the device interrupts the CPU when it's done.

To poll an I/O device, the CPU typically uses memory-mapped I/O. I/O devices are assigned memory addresses which aren't used by memory at all, but are instead, special addresses that the I/O device recognizes. (Memory mapped I/O is usually done when the CPU is started up). The CPU can then check the status of the device by reading a byte or word at some pre-determined address for that particular I/O device.

Problems with Polling

The problem with polling is that the CPU operates at a much faster speed than most I/O devices. Thus, a CPU can get into a busy wait, checking the device many times, even though the device is very slow.

Occasionally, polling is the right thing to do, especially if devices are quick enough. The main advantage of polling is that the CPU determines how often it needs to poll. An interrupt causes the CPU to "stop" and determine what device is interrupting.

Thus, if the CPU can be late handling the device, then polling prevents the CPU from being interrupted.

Summary

One way for a CPU to check on the status of an I/O device is by reading a memory address which is associated with an I/O device (using memory mapped I/O). This is called polling.

Web Accessibility