Is there such a function that idles the program for some specified number of microseconds but does not consume CPU time? I use a loop and gettimeofday() but that keeps the CPU from doing other things. Thanks!
Printable View
Is there such a function that idles the program for some specified number of microseconds but does not consume CPU time? I use a loop and gettimeofday() but that keeps the CPU from doing other things. Thanks!
On Windows, there's Sleep(). However, you cannot guarantee exactly when that will return because Windows is not a real-time OS---it only promises to relinquish control for at least the specified number of milliseconds.
In practice, you'll probably see about 10ms as the mimimum sleep time.
sleep(milliseconds)
It's not standard as far as I know, but all POSIX based systems (most UNIX and Linux) support it.
Thank you all! :)