Polling (computer science): Difference between revisions

Content deleted Content added
wp:unsourced especially USB4 (and grammatically incorrect) - Undid revision 1282924079 by 219.129.33.114 (talk)
BrainStack (talk | contribs)
Link suggestions feature: 2 links added.
 
Line 6:
 
==Description==
Polling is the process where the computer or controlling device waits for an [[external device]] to check for its readiness or state, often with low-level hardware. For example, when a [[printer (computing)|printer]] is connected via a [[parallel port]], the computer waits until the printer has received the next character. These processes can be as minute as only reading [[status register|one bit]]. This is sometimes used synonymously with '[[busy waiting|busy-wait]]' polling. In this situation, when an {{nowrap|I/O}} operation is required, the computer does nothing other than check the status of the {{nowrap|I/O}} device until it is ready, at which point the device is accessed. In other words, the computer waits until the device is ready. Polling also refers to the situation where a device is repeatedly checked for readiness, and if it is not, the computer returns to a different task. Although not as wasteful of [[CPU]] cycles as busy waiting, this is generally not as efficient as the alternative to polling, [[interrupt]]-driven {{nowrap|I/O}}.
 
In a simple single-purpose system, even busy-wait is perfectly appropriate if no action is possible until the {{nowrap|I/O}} access, but more often than not this was traditionally a consequence of simple hardware or non-[[Computer multitasking|multitasking]] [[operating systems]].
 
Polling is often intimately involved with very [[machine code|low-level hardware]]. For example, polling a parallel printer port to check whether it is ready for another character involves examining as little as one [[bit]] of a [[byte]]. That bit represents, at the time of reading, whether a single wire in the printer cable is at low or high voltage. The {{nowrap|I/O}} instruction that reads this byte directly transfers the voltage state of eight real world wires to the eight circuits ([[flip flop (electronics)|flip flop]]s) that make up one byte of a [[Processor register|CPU register]].
 
Polling has the disadvantage that if there are too many devices to check, the time required to poll them can exceed the time available to service the I/O device.