Home

Busywait

Busy-wait, also known as busy waiting or polling, is a synchronization technique in which a thread or process waits for a condition to become true by repeatedly checking it in a loop, without yielding the processor. The loop typically runs while a condition remains unmet, consuming CPU time.

In practice, busy-waiting appears in spinlocks, where a thread loops on a lock flag until it becomes

The main advantage of busy-waiting is low latency: when the condition becomes true, the waiting thread can

Mitigations and alternatives include inserting a brief pause or yielding the processor inside the loop, using

available,
and
in
hardware
polling
loops
that
wait
for
a
device
status
bit
to
change.
It
is
also
used
in
some
low-level
or
embedded
contexts
where
the
cost
of
blocking
or
context
switching
is
undesirable
and
the
wait
is
expected
to
be
very
short.
proceed
immediately
without
the
overhead
of
scheduling
or
waking
another
task.
It
has
minimal
setup
and
can
be
simpler
to
implement
in
certain
low-level
environments.
However,
it
wastes
CPU
cycles,
increases
power
consumption,
and
scales
poorly
on
multi-core
systems
where
other
threads
could
be
productive
while
one
spins.
It
is
generally
unsuitable
for
long
waits
or
workloads
with
many
competing
tasks,
where
blocking
synchronization
primitives
or
event-driven
designs
are
preferable.
back-off
strategies
to
reduce
contention,
or
replacing
the
busy-wait
with
blocking
primitives
such
as
mutexes,
semaphores,
or
condition
variables.
In
hardware
contexts,
using
interrupts
instead
of
polling
can
also
eliminate
unnecessary
spinning.
Busy-wait
is
most
appropriate
for
very
short
waits
or
tightly
controlled
environments
where
latency
is
critical.