in reply to Scheduling at NT

To be portable, wait loops need to account for the possibility that sleep() might terminate prematurely. It all comes down to something like this:
while ( ($t = time()) < $targettime ) { sleep($targettime - $t); }
If you want to see a particularly elaborate idle loop, check out the source code for MisterHouse, which controls a pretty wild X10-infected house.