sys_futex_waitv(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– sys_futex_waitv β€” wait on a whole LIST of futexes, bestie

okay so this one is from the Kernel API Manual (section 9, kernel-space girlies rise πŸ™Œ) and honestly? it's giving "wait on multiple things at once and see which one pops off first." iconic behaviour fr fr.


✨ NAME ✨

sys_futex_waitv β€” wait on a list of futexes. not one. a list. we multitask in this house πŸ’…


🌸 SYNOPSIS 🌸

long sys_futex_waitv (struct futex_waitv __user * waiters , unsigned int
nr_futexes , unsigned int flags , struct __kernel_timespec __user *
timeout , clockid_t clockid );

like, five whole arguments. she's high maintenance but she delivers 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • waiters β€” the list of futexes we're waiting on. the whole squad πŸ’–
  • nr_futexes β€” length of futexv. i.e. how many futexes are actually in that list, no cap.
  • flags β€” flag for the timeout (monotonic / realtime). that's literally its whole job.
  • timeout β€” optional absolute timeout. optional!! so if you don't feel like timing out, don't ✨
  • clockid β€” the clock used for the timeout: realtime or monotonic. pick your fighter ⏰

πŸ¦‹ DESCRIPTION πŸ¦‹

So you hand it an array of struct futex_waitv, right? And it waits on each uaddr. Every single one. Obsessed with the commitment.

The thread wakes up if a futex_wake is performed at any uaddr. Any of them! first one to wake her up wins the vibe check πŸ”₯

Also super important: the syscall returns immediately if any waiter has *uaddr != val. like it's not even gonna try. she said "nope, mismatch, bye" πŸ’€

*timeout is an optional timeout value for the operation β€” optional, so no pressure bestie.

Each waiter has its own individual flags. Yes, individually. And the flags argument for the syscall itself should be used solely for specifying the timeout as realtime, if needed. that's it. that's the whole assignment. Flags for private futexes, sizes, etc.? Those go on the individual flags of each waiter. don't mix them up, i'm begging πŸ™ˆ

So what does it return? It returns the array index of one of the woken futexes. One of them. That's all you get, no further information is provided β€” and this is the messy part, so sit with me:

  • any number of other futexes may also have been woken by the same event 😭
  • if more than one futex was woken, the retrned index may refer to any one of them
  • (it is not necessaryily the futex with the smallest index, nor the one most recently woken, nor…)
yes, "retrned" and "necessaryily" are literally how it's spelled in the source. she's keeping it real, we don't edit the queen πŸ‘‘πŸ’€

so like… don't build your whole personality on that index meaning something specific. it's a hint, not a promise. periodt.


🌈 SEE ALSO 🌈


πŸ’œ cute sign-off πŸ’œ

this lil masterpiece lives in ./kernel/futex, stamped October 2026 in the Kernel API Manual β€” go off, futex girlies, ily, drink some water and remember to check your uaddr != val before you wait πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from