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?
I’m building a multithreaded application with pthreads and need a thread to periodically check
Share
The function
usleephas been removed from SUSv4. You should probably usenanosleepinstead or timers (setitimer, etc).As R.. notes in the comments, should the sleep be implemented as a busy wait:
Thus: