udelay(9)
udelay(9) π
β Kernel API Manual bestie briefing π¦
πΈ NAME πΈ
udelay β inserting a delay based on microseconds with busy waiting β¨
β¨ SYNOPSIS β¨
void udelay (unsigned long usec );
π ARGUMENTS π
usecβ the requested delay in microseconds π«Ά
π DESCRIPTION π
Okay so when you're delaying in an atomic context, ndelay, udelay, and mdelay are literally the only valid variants of delaying/sleeping to go with β periodt. π
When inserting delays in non atomic context which are shorter than the time which is required to queue e.g. an hrtimer and to enter the scheduler, it is also valuable to use udelay. But it is not simple to specify a generic threshold for this which will fit for all systems. An approximation is a threshold for all delays up to 10 microseconds β.
When having a delay which is larger than the architecture specific MAX_UDELAY_MS value, please make sure mdelay is used. Otherwise an overflow risk is given π.
β οΈ heads up bestie: please note thatndelay,udelay, andmdelaymay return early for several reasons (https://lists.openwall.net/linux-kernel/2011/01/09/56):
- computed
loops_per_jiffytoo low (due to the time taken to execute the timer interrupt.) π - cache behaviour affecting the time it takes to execute the loop function. π§
- CPU clock rate changes. π₯
π SEE ALSO π
Kernel file ./include/asm-generic/delay.h β and also go peek at ndelay(9) π«Ά
β with love from source/version ./include/asm-generic, dated October 2026, and this whole udelay(9) moment is signed off with sparkles πβ¨π
π¦ 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