Polling (computer science)

From Wikipedia, the free encyclopedia

Polling, in computer science, refers to actively sampling the status of an external device by a client program as a synchronous activity. Polling is most often used in terms of I/O, and is also referred to as polled I/O.

Polled I/O is a system by which an operating system (OS) waits and monitors a device until the device is ready to read. In early computer systems, when a program would want to read a key from the keyboard, it would constantly poll the keyboard status port until a key was available; due to lack of multiple processes such computers could not do other operations while waiting for the keyboard. The solution and alternative to this approach is for the device controller to generate an interrupt when the device was ready to transfer data. The CPU handles this interrupt and the OS knows to fetch the data from the relevant device registers. This solution is called interrupt-driven I/O.

Another example of polling can be found in many online chat solutions where a server must queue messages and wait to be asked by a client. This is the most common mechanism for chat utilizing the Ajax web communications technique.