BAD smell: empty infinite loop
ome people like to use empty infinite loop to implement the “waiting“. It is a BAD design because this design will block your CPU !!! I make a practice to explain this situation.
Examples of empty infinite loop:
My test: busy.c
Compile:
Execute:
CPU usage:
Assembly:
Conclusion: DON’T use empty infinity to be your waiting timer. Ref. 讓CPU瞎忙的忙碌迴圈 Why does an empty infinite loop use my whole CPU?
Last updated