wait_event_...usive_locked(9)
π€ wait_event_...usive_locked(9) β the glow-up β¨
okay so real talk, this is a page from the Kernel API Manual (yes, the actual kernel manual, we're fancy now π
) and the star of the show is wait_event_interruptible_exclusive_locked. long name? yes. iconic behavior? also yes. let's get into it bestie π«Ά
π NAME
wait_event_interruptible_exclusive_locked β sleep exclusively until a condition gets true π¦
like, it naps, but it naps with main character energy β nobody else on the list gets to wake up with it. periodt.
β¨ SYNOPSIS
wait_event_interruptible_exclusive_locked (wq , condition );
that's it. two things in, vibes out π (also yes, that spacing is exactly how it's written, don't come for me)
πΈ ARGUMENTS
wqβ the waitqueue to wait on ποΈ like, this is the bed your process is gonna crash in while it waits.conditionβ a C expression for the event to wait for β this is the "am I awake yet??" check.
π DESCRIPTION
okay so here's the whole situation, no cap:
The process is put to sleep (TASK_INTERRUPTIBLE) until the condition evaluates to true or a signal is received. and the condition gets checked every single time the waitqueue wq is woken up π₯ like, every poke = one vibe check.
β οΈ big one: it must be called with wq.lock being held. like, that's not optional, that's the whole contract bestie.
That spinlock gets unlocked while sleeping π΄ but the condition testing is done while the lock is held, and when this macro exits, the lock is held. so it comes back exactly how it left β icon behavior, honestly.
The lock is locked/unlocked using spin_lock/spin_unlock functions, and those must match the way they are locked/unlocked outside of this macro. π§ matchy matchy or it does not slay.
The process is put on the wait queue with a WQ_FLAG_EXCLUSIVE flag set β and the way that works is, when other processes are waiting, if this process is awakened, further processes are not considered. π like sorry girlies, this one's mine.
wake_up_locked has to be called after changing any variable that could change the result of the wait condition. π«‘ that's the assignment, don't skip it.
Return values (the receipts π):
-ERESTARTSYSif it was interrupted by a signal π0if the condition evaluated to true β
π SEE ALSO
the whole friend group π«Ά also from the kernel file ./include/linux/wait.h:
waitqueue_active(9), wq_has_single_sleeper(9), wq_has_sleeper(9), wake_up_pollfree(9), wait_event(9), wait_event_freezable(9), wait_event_timeout(9), wait_event_cmd(9), wait_event_interruptible(9), wait_event_interruptible_timeout(9), wait_event_hrtimeout(9), wait_event_interruptible_hrtimeout(9), wait_event_idle(9), wait_event_idle_exclusive(9), wait_event_idle_timeout(9), wait_event_idle_exclusive_timeout(9), wait_event_interruptible_locked(9), wait_event_interruptible_locked_irq(9), wait_event_interruptible_exclusive_locked_irq(9), wait_event_killable(9), wait_event_state(9), wait_event_killable_timeout(9), wait_event_lock_irq_cmd(9), wait_event_lock_irq(9), wait_event_interruptible_lock_irq_cmd(9), wait_event_interruptible_lock_irq(9), wait_event_interruptible_lock_irq_timeout(9)
mwah π that's the page!! this one lives at ./include/linux and the version is dated October 2026 β so yeah, future girlies are still out here waiting on waitqueues. go forth and sleep exclusively, bestie πβ¨
π¦ 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