I am just interested how sleep(time in ms) is implemented in a C library or basically at the OS level...
I am guessing...
Sleep blocks your task/thread for the time value passed. Your task becomes un-runnable for that period or until something else interesting happens (like a signal), whichever is sooner.
It is not uncommon for sleep to call select() and pass no descriptors to wait on and a timeout value equal to your sleep period.
The system may implement this by setting a timer to expire after the time passed and then waiting on a semaphore that will be signalled when that timer expires. Thus it is blocked on that semaphore.