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.
This comment was marked helpful 0 times.
jpaulson
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!
This comment was marked helpful 0 times.
tliao
@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.
This comment was marked helpful 0 times.
sjoyner
Busy waiting is bad because the process wastes resources that another process could use.
This comment was marked helpful 0 times.
fangyihua
Note, in some situations, the spin loop may not affect performance, but will have an effect in power consumption.
This comment was marked helpful 0 times.
chenc3
busy waiting might also increase the bus load and slow down other processors since it tries to read from memory each iteration.
This comment was marked helpful 0 times.
kfc9001
^ 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.
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.
This comment was marked helpful 0 times.
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!
This comment was marked helpful 0 times.
@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.
This comment was marked helpful 0 times.
Busy waiting is bad because the process wastes resources that another process could use.
This comment was marked helpful 0 times.
Note, in some situations, the spin loop may not affect performance, but will have an effect in power consumption.
This comment was marked helpful 0 times.
busy waiting might also increase the bus load and slow down other processors since it tries to read from memory each iteration.
This comment was marked helpful 0 times.
^ 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.
This comment was marked helpful 0 times.