Polling (computer science)

from Wikipedia, the free encyclopedia

In computer science, polling is the expression for a cyclical query to determine the status of hardware or software or the event of a change in value with cyclical querying.


Hardware whose status is required often consists of ports of electrical circuits, interfaces or external devices. Software states that are frequently queried are file locks on other computers or semaphores .

One possible purpose of polling is to actively wait for status changes, also known as spinning . Another form is the query once in a scan cycle, or the query for a different activity.

An example of the use of polling is polling .

Advantages and disadvantages

Polling makes sense under the following conditions:

  • The simple, explicitly serial and determinable behavior of polling programming can be desirable compared to potentially more complex parallel alternatives.
  • It is a very quick query of a hardware connection, for example, which takes on the desired state within microseconds.
  • There is a cyclical activity in which polling can take place, while alternative solutions require more effort. This is often the case with cyclical regulations.
  • There are no other connections to the partner other than the query option. This is the case with loosely coupled systems, for example when querying whether a file exists or is released on a file system (possibly on a remote computer) that is provided by another program or is locked.


  • Polling often makes the performance of programs non-deterministic (e.g. varying FPS ) and usually lower than with alternative solutions.
  • The efficiency in using system resources can be significantly less than alternative approaches. For example, a naive polling implementation, e.g. B. a program polling at maximum speed that drives the system load to 100% (with unnecessary power consumption and waste heat), whereas an event-based or hardware interrupt solution consumes practically no system resources.


There are the following alternatives to polling (mostly following the concept of inversion of control ), the possible uses of which depend on the hardware and software conditions:

The disadvantage of most of these alternatives is that these are parallel programming techniques and thus have potential risks and increased complexity compared to explicitly serial polling.


  • Gerhard Schnell, Konrad Hoyer: Microcomputer Interface Guide . Vieweg, Braunschweig / Wiesbaden 1984, ISBN 978-3-528-04248-6 .
  • Rolf Gübeli, Hans Käser, Rolf Klaus, Thomas Müller: Technical Computer Science II: Microprocessor Hardware and Programming Techniques . 2nd Edition. vdf Hochschulverlag, Zurich 2010, ISBN 978-3-7281-3256-7 .