in reply to Do-nothing loops
In lieu of your CPU-time-eating delay, you might look into sleep, which is much more deterministic. In other words, it's more efficient, and it's easier to get the time right.