in reply to Do-nothing loops

It sounds as if you are Suffering from Buffering.

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.