This might be a stupid question, but how do sleep(), wait(), pause(), functions work?
sleep()
wait()
pause()
These are system calls. Lookup the implementation in Open-source code like in Linux or Open BSD.