schedule_timeout(9)
π€ schedule_timeout(9) β the "just nap for a bit, bestie" kernel function β¨
okay so this is a page from the Kernel API Manual, and it's about schedule_timeout, which is basically the kernel's way of saying "girl, go to sleep for a minute." π
πΈ NAME πΈ
schedule_timeout β sleep until timeout π€
β¨ SYNOPSIS β¨
signed long schedule_timeout (signed long timeout );
π§ ARGUMENTS π§
timeoutβ the timeout value, measured in jiffies. (ya, jiffies. iconic unit, no notes π«Ά)
π DESCRIPTION π
So the whole vibe here: this makes the current task sleep until timeout jiffies have elapsed. That's it. That's the function. But β and this is the part that's giving β¨main character energyβ¨ β what actually happens depends on the current task state (peep the set_current_state description too, bestie, they're linked):
TASK_RUNNINGβ the scheduler gets called, but the task does not sleep at all. Zero nap. Not even a lil closing of the eyes π And why? Becausesched_submit_workdoes literally nothing for tasks inTASK_RUNNINGstate. nothing. nada. it's giving unbothered.TASK_UNINTERRUPTIBLEβ at leasttimeoutjiffies are guaranteed to pass before the routine returns, unless the current task gets explicitly woken up (like, bywake_up_process). So it's a proper deep sleep, no interruptions, no "mom's calling" energy. πTASK_INTERRUPTIBLEβ this one's the light sleeper π¦ the routine may return early if a signal is delivered to the current task, or if the current task is explicitly woken up. so like, you can be woken. it's fine. it's flexible.
And the glow-up guaranteed at the end: the current task state is guaranteed to be TASK_RUNNING when this routine returns. always. periodt. β
Also, if you specify a timeout value of MAX_SCHEDULE_TIMEOUT, it'll schedule the CPU away without a bound on the timeout β like, no clock, no limit, just vibes π₯ In that case the return value will be MAX_SCHEDULE_TIMEOUT.
π RETURN π
0when the timer has expired β slay, nap complete β- otherwise the remaining time in jiffies gets returned π
And in all cases, the return value is guaranteed to be non-negative. no negativity allowed here, we don't do that π
π SEE ALSO π
Kernel file ./kernel/time/sleep_timeout.c β go read it, it's cute
schedule_timeout_interruptible(9)schedule_timeout_killable(9)schedule_timeout_uninterruptible(9)schedule_timeout_idle(9)schedule_hrtimeout_range_clock(9)schedule_hrtimeout_range(9)schedule_hrtimeout(9)msleep(9)msleep_interruptible(9)usleep_range_state(9)
the whole sleep-timeout friend group fr fr π«Ά
βΏ and that's the whole page, bestie βΏ this one's chillin' under ./kernel/time, October 2026 edition β go take a nap, you've earned it ππ€
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms