Previous | Next --- Slide 5 of 29
Back to Lecture Thumbnails

Busy-waiting is bad because you are wasting processor cycles checking on the true condition when you can instead sleep a thread to be woken up for instance. It's better to be notified once when the condition changes rather than repeatedly checking.


In a single-core system, busy-waiting is especially bad because you know you won't get out of the loop; someone else needs the core to change X to true!


@jpaulson That's not necessarily true on a single-core system. If a process has a signal handler that modifies a flag whose value it keeps checking or the process reading from memory mapped I/O for the condition, you can break out of the spin loop.


Busy waiting is bad because the process wastes resources that another process could use.


Note, in some situations, the spin loop may not affect performance, but will have an effect in power consumption.


busy waiting might also increase the bus load and slow down other processors since it tries to read from memory each iteration.


^ actually busy waiting won't increase bus load, because all of the processors spinning would be in the S state anyway, until there was a write.