This code uses select for a timeout. select usually takes a file descriptor and makes the caller wait until an input / output event occurs on fd. It also accepts a timeout argument for maximum latency. Here fd is 0, so no events will occur, and the function will always return when the timeout is reached.
select(3) , which you get from the C library, is the shell of the select(2) system call, which means that the select(3) call will ultimately take you to the kernel. Then, the kernel does not schedule the process unless an I / O event occurs or the timeout is not reached. Thus, the process does not use the processor while waiting.
Obviously, transition to the kernel and process planning lead to delays. Therefore, if you should have very low latency (nanoseconds), you should use expectation.
source share