schedule_hrtimeout_range(9)
π€ schedule_hrtimeout_range β sleep until timeout π€
okay so bestie, this is a Kernel API Manual page, section 9 β we're in kernel-internals territory and honestly it's kind of a vibe. Buckle up, this one's about making the current task nap until a specific moment in time. β¨
π SYNOPSIS π
int schedule_hrtimeout_range (ktime_t *expires , u64 delta , const enum
hrtimer_mode mode );
three args, one int back, and yes the spacing is iconic, don't touch it π
πΈ ARGUMENTS πΈ
expiresβ the timeout value, and it's aktime_t(which, note, the manpage lists asktime_teven though the synopsis saysktime_t *β¦ we report, we don't fix π«Ά). This is your "wake me up at this moment" moment.deltaβ the slack in theexpirestimeout (also listed asktime_t). Think of it as your flex window, more on that below πmodeβ the timer mode. It's aconst enum hrtimer_mode, fr fr.
π¦ DESCRIPTION π¦
Make the current task sleep until the given expiry time has elapsed. That's the whole job, and it does it.
β οΈ Big one: the routine will return immediately unless the current task state has been set (see set_current_state). So set that state first or you're just gonna blaze right through this thing π
The delta argument gives the kernel the freedom to schedule the actual wakeup to a time that's both power and performance friendly β for regular (non RT/DL) tasks. The kernel gives the normal best effort behavior for "expires+delta", but may decide to fire the timer earlier, but no earlier than expires. So it's never early-early, only early-within-your-slack. No cap. π₯
You can set the task state as follows β
TASK_UNINTERRUPTIBLEβ at least the timeout time is guaranteed to pass before the routine returns, unless the current task is explicitly woken up (e.g. bywake_up_process). It's committed. It's loyal. πTASK_INTERRUPTIBLEβ the routine may return early if a signal is delivered to the current task, or the current task is explicitly woken up. Sleeps with one eye open π
And the glow-up at the end: the current task state is guaranteed to be TASK_RUNNING when this routine returns. Periodt. You always leave running, never asleep. β¨
π RETURN π
0β when the timer has expired. clean, correct, slay π-EINTRβ if the task was woken before the timer expired, either by a signal (only possible in stateTASK_INTERRUPTIBLE) or by an explicit wakeup. Rude but valid π
π SEE ALSO π
Kernel file ./kernel/time/sleep_timeout.c β go read the source bestie, it's giving main character energy:
schedule_timeout(9)schedule_timeout_interruptible(9)schedule_timeout_killable(9)schedule_timeout_uninterruptible(9)schedule_timeout_idle(9)schedule_hrtimeout_range_clock(9)schedule_hrtimeout(9)msleep(9)msleep_interruptible(9)usleep_range_state(9)
okay that's the whole page, go take a nap (the well-timed, delta-tolerant kind) π§ββοΈπ
signed off with love from ./kernel/time, dated October 2026, in the Kernel API Manual β bye bestie, ily, don't forget set_current_state π
πΈ
π¦ 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