I'm building a multithreaded application with pthreads and need a thread to periodically check some stuff. During the time in between this thread shouldn't use any CPU. Is this possible with usleep()? Is usleep() not busy waiting? Or is there a better solution?
The function usleep has been removed from SUSv4. You should probably use nanosleep instead or timers (setitimer, etc).
As R.. notes in the comments, should the sleep be implemented as a busy wait:
Thus:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With