wait_on_bit_timeout(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’€ wait_on_bit_timeout(9)

okay so this is a page from the Kernel API Manual β€” the wait_on_bit_timeout(9) one, and honestly bestie, it's lowkey the chillest function in the whole wait_bit family. Let's get into it ✨


🌸 NAME 🌸

wait_on_bit_timeout β€” wait for a bit to be cleared or a timeout to elapse. whichever comes first, no cap πŸ’…


✨ SYNOPSIS ✨

int wait_on_bit_timeout (unsigned long *word , int bit , unsigned mode ,
       unsigned long timeout );

πŸŽ€ ARGUMENTS πŸŽ€

  • word β€” the address containing the bit we're waiting on. like, the actual home of the bit 🏠
  • bit β€” the specific bit at that address that's being waited on
  • mode β€” the task state to sleep in 😴
  • timeout β€” the timeout, measured in jiffies ⏳

πŸ¦‹ DESCRIPTION πŸ¦‹

So the whole vibe is: wait for the given bit in an unsigned long or a bitmap (peep DECLARE_BITMAP) to get cleared, or wait for a timeout to expire. Whichever happens first. 🫢

Heads up though β€” the clearing of the bit must be signalled with wake_up_bit, and a lot of the time that's clear_and_wake_up_bit. If nobody signals, we're just out here waiting. 😭

This one is similar to wait_on_bit, except it also takes a timeout parameter. That's the whole personality trait, honestly. ⭐

The returned value is:

  • zero if the bit was cleared β€” and in that case the call has ACQUIRE semantics πŸ‘‘
  • -EINTR if the process received a signal and the mode permitted wake up on that signal πŸ™ˆ
  • -EAGAIN if the timeout elapsed πŸ’€

🌈 SEE ALSO 🌈

Kernel file ./include/linux/wait_bit.h, plus the whole friend group fr fr:


that's the whole page bestie, ily, go clear some bits πŸ’–βœ¨πŸŽ€πŸ¦‹

shoutout to ./include/linux and the October 2026 drop β€” this one's sourced straight from there, mwah πŸ’œ

πŸ“¦ where this page comes from