I am just interested how sleep(time in ms) is implemented in a C library or basically at the OS level...
I am guessing...
The answer to your question is completely operating-system and implementation-dependent.
A simple way to think about it: When you call sleep(), the OS calculates the wakeup time, then sticks your process on a priority queue somewhere. It then just doesn't schedule your process to get any execution time until enough real time has passed for it to get popped off the queue.