liveBook · Manning

Busy-waiting loop

A busy-waiting loop repeatedly checks a condition while actively consuming processor resources instead of blocking or relinquishing control.

How 3 Manning books explain it

100 Go Mistakes and How to Avoid Them

A busy loop is a repeated polling loop that continuously checks a condition instead of blocking until the condition may have changed.

How it is used
Identifies wasted CPU cycles in donation-goal listeners and a channel-merging loop.
How deep it goes
Traces two concrete loop failures and contrasts polling with condition-variable waiting and nil-channel disabling.
Examples
Uses donation-goal listeners polling a balance and a two-channel merge that keeps selecting a closed input.
What you can do after
Diagnose/debug busy loops by replacing repeated balance checks with sync.Cond waiting or disabling closed select inputs with nil.

Read how 100 Go Mistakes and How to Avoid Them explains busy-waiting loop →

Software Design for Python Programmers

Busy waiting is repeatedly consuming execution time while waiting instead of relinquishing control to other threads.

How it is used
Simulates work that occupies a thread for a measured duration while demonstrating access to a shared resource.
How deep it goes
Defines the scheduling cost and implements a timed loop, but does not develop a general waiting strategy.
Examples
Uses technician meter-setting and logger read-and-log durations as concrete busy-waiting examples.
What you can do after
Build it from scratch using a timed Python loop that continues until elapsed time reaches the requested duration.

Read how Software Design for Python Programmers explains busy-waiting loop →

Rust in Action: Systems programming concepts and techniques

A spin loop repeatedly checks a condition while actively consuming CPU time instead of blocking execution.

How it is used
Uses active waiting for short pauses when sleep timing is insufficiently precise or timing sensitivity matters.
How deep it goes
Implements elapsed-time polling, thread yielding, joining, a broken borrowing variant, and scalability limits across CPU cores.
Examples
Demonstrates a 20-millisecond Rust wait, compares it with thread::sleep, and reproduces timing data across up to 1,000 threads.
What you can do after
Build it from scratch in Rust, benchmark it against sleep, and diagnose ownership errors when joining stored thread handlers.

Read how Rust in Action: Systems programming concepts and techniques explains busy-waiting loop →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.