To be honest with you, I can't think of a situation makes sense for
sleeping for a matter of milliseconds.
When you're dealing with hardware that requires some timeouts in the
millisecond range it's quite convenient if you don't have to sleep
each time for at least a second;-) And there are also lots of other
cases where a sub-second resolution is important.
Difftime is guaranteed to return a long in seconds.
It returns a double. But that still doesn't guarantee even second
resolution, the standard does not make any statements about the
time resolution of a time_t, it just states that it's an "arith-
metic types capable of representing times".
How does a computer distinguish sleep from a busy loop? MPJ
It's heating the CPU less;-) If you're on a multi-tasking system the
system can schedule other tasks while you're sleeping. Imagine a
situation where you want to e.g. emit a short beep from the speaker
every 5th of a second. With busy-looping that task alone would use
100% CPU time while with a real sleep function it might reduce to a
few percent - so other jobs could be done in between by the machine.
Regards, Jens