Sleep (operating System) - Low Level Functionality

Low Level Functionality

Sleep causes the thread or process to give up the remainder of its time slice and stay in the Not Runnable state for the specified duration. While there is a generally a guarantee for the minimum time period, there is no strict guarantee that the thread will run immediately or soon, or even at all, once the specified time has passed. It is up to the scheduler's discretion, and dependent on thread priorities and implementation details such as timer resolutions when the sleeping thread will run again. On POSIX systems, the nanosleep and related syscalls are interruptible by signals, returning the remaining sleep time. The sleep library function, on the other hand, is implemented via the alarm syscall on many older systems, thus it only works by delivering a signal. The Windows Sleep function is non-interruptible due to absence of signals (other than the thread or its process being terminated), although the related SleepEx function can be used to put the thread into an alertable state, allowing APC calls being made while the thread is sleeping. Also, a thread can technically be "interrupted" in case e.g. the process terminates due to an exception in a different thread.

Read more about this topic:  Sleep (operating System)

Famous quotes containing the word level:

    As the tragic writer rids us of what is petty and ignoble in our nature, so also the humorist rids us of what is cautious, calculating, and priggish—about half of our social conscience, indeed. Both of them permit us, in blessed moments of revelation, to soar above the common level of our lives.
    Robertson Davies (b. 1913)