Polling (see also
spin-waiting) is testing for the availability of a
resource by repeatedly requesting the resource via a
non-blocking call, until the resource becomes available. Polling is wasteful of processor time that could be used by another
thread of control in a
concurrent program. Unless the resource is likely to become available almost instantaneously, a better approach is to have the resource set an
event when it becomes available, and block awaiting the event.
The is-resource-available function for many common resources has an option either to block or to return immediately. The first option is used in simple programs that are typically single threads of control. The second option facilitates polling, but it also supports blocking on a binary semaphore, then accessing the resource multiple times until the resource is exhausted.