liveBook · Manning

Busy-waiting loop

As explained in Software Design for Python Programmers

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

A busy-waiting loop repeatedly consumes execution time while waiting. Unlike sleeping, it does not interrupt the thread or let another thread take over. section 16.3.1

Simulating meter-setting time

A reader–writer simulation uses busy waiting to represent one second per meter-setting level and two seconds of logger work. The loop keeps the thread active while the shared meter remains protected by synchronization. section 16.3.1

How Software Design for Python Programmers covers it

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 it assumes
Contrasts busy waiting with thread sleeping and places both within concurrent access to a shared meter.
What you can do after
Build it from scratch using a timed Python loop that continues until elapsed time reaches the requested duration.
How it connects
Connects busy waiting to threads, sleeping, critical regions, mutexes, semaphores, and the reader–writer problem.

Also explained in

Compare how 3 books explain busy-waiting loop →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Design for Python Programmers. The section links point to the parts of the book it draws on.