yield(9)
π yield(9) β the "don't do it bestie" page of the Kernel API Manual
Okay so before we even start, the vibe check on this one is immaculate chaos. This page is a whole read. The manual name is yield, it lives in section 9, and the entire energy is "I am telling you this exists purely so you never touch it." Buckle up π
β¨ NAME β¨
yield β yield the current processor to other threads.
(Yes that's what it says it does. No, that's not what you think it does. Keep reading, bestie π«Ά)
πΈ SYNOPSIS πΈ
void yield (void );
That's it. That's the whole signature. Not a single argument. A perfectly innocent-looking little function that the kernel devs have personally come for π
π¦ ARGUMENTS π¦
voidβ no arguments. Zero. None. Nothing to pass, nothing to configure, nothing to blame. It takes nothing and it still manages to be the wrong call. Iconic behaviour, honestly π
π₯ DESCRIPTION π₯
Do not ever use this function, there's a 99% chance you're doing it wrong.
Not me opening the manpage and getting read in the very first paragraph π The original text is crystal clear: do not ever use this function, and there's a 99% chance you're doing it wrong. That's not a gentle suggestion, that's a prophecy.
The scheduler is at all times free to pick the calling task as the most eligible task to run. Read that again. At all times free. So if removing the yield call from your code breaks it, it's already broken β the yield was never holding it together, it was just hiding the crack like a scrunchie over a bad hair day π
Typical broken usage is:
while (!event) yield;
where one assumes that yield will let 'the other' process run that will make event true. And here's the plot twist, bestie: if the current task is a SCHED_FIFO task, that will never happen. Never. Not "eventually", not "if you're patient", not "on a full moon" β never.
Never use yield as a progress guarantee!! π¨
So what should you do? The page is generous enough to hand you the receipts:
- If you want to use
yieldto wait for something, usewait_event. - If you want to use
yieldto be 'nice' for others, usecond_resched. - If you still want to use
yieldβ do not! π«
That's the whole arc. Setup, warning, betrayal, redemption arc via wait_event, and then one last "do not!" because they knew some of y'all would still try it. They were right. π
π SEE ALSO π
Kernel file ./kernel/sched/syscalls.c, plus the whole friend group:
task_prio(9)idle_cpu(9)idle_task(9)find_process_by_pid(9)sched_setscheduler(9)sched_setscheduler_nocheck(9)sys_sched_setscheduler(9)sys_sched_setparam(9)sys_sched_setattr(9)sys_sched_getscheduler(9)sys_sched_getparam(9)sys_sched_getattr(9)sys_sched_setaffinity(9)sys_sched_getaffinity(9)sys_sched_yield(9)yield_to(9)sys_sched_get_priority_max(9)sys_sched_get_priority_min(9)sys_sched_rr_get_interval(9)
Go read those instead, bestie. They're literally right there. π§
β¨ sign-off time β¨
This masterpiece of "please don't" ships out of ./kernel/sched, dated October 2026, page yield(9). Read it. Cherish it. Then go use wait_event like the responsible main character you are ππ¦πΈ
π¦ 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