FUTEX_WAIT_REQUEUE_PI(2const)

πŸ‘‘ FUTEX_WAIT_REQUEUE_PI β€” the 2const girlie πŸ’…

okay so bestie, welcome to FUTEX_WAIT_REQUEUE_PI(2const) β€” yes the manual name is literally part of the title, we're fancy like that πŸ’–. This is the futex operation that waits on a totally normal (non-PI) futex and then β€” plot twist β€” might get requeued onto a PI futex. It's giving "I was waiting over here but actually I belong over there now." ✨


🌸 LIBRARY

Standard C library (libc, -lc) β€” the classics, no cap.


πŸ¦‹ SYNOPSIS

#include <linux/futex.h>  /* Definition of FUTEX_* constants */
#include <sys/syscall.h>  /* Definition of SYS_* constants */
#include <unistd.h>

long syscall(SYS_futex, uint32_t *uaddr, FUTEX_WAIT_REQUEUE_PI,
             uint32_t val,
             const struct timespec *timeout,
             uint32_t *uaddr2);

✨ DESCRIPTION ✨

So here's the vibe: you wait on a non-PI futex at uaddr, and you potentially get requeued onto a PI futex at uaddr2. How does that requeue happen? Via a FUTEX_CMP_REQUEUE_PI(2const) operation running in some other task β€” so it's not you doing it, it's somebody else moving you, lowkey iconic of them. 🫢

The actual wait operation on uaddr? That part is exactly the same as FUTEX_WAIT(2const). Same energy, same rules.

Now β€” the waiter can be yanked out of the wait on uaddr without being requeued onto uaddr2, if another task hits it with a FUTEX_WAKE(2const) operation. In that specific case, the FUTEX_WAIT_REQUEUE_PI operation fails with the error EAGAIN. Not a glitch, that's just the deal. 😭

And about timeout:

  • If timeout is not NULL, the structure it points to specifies an absolute timeout for the wait operation.
  • If timeout is NULL, the operation can block indefinitely. main character patience fr fr.

πŸ’« RETURN VALUE

On error, -1 is returned, and errno is set to indicate the error. Rude but standard.

On success, FUTEX_WAIT_REQUEUE_PI returns 0 if the caller was successfully requeued to the futex for the futex word at uaddr2. Slay, you made it. πŸŽ€


πŸ’… ERRORS πŸ’…

See futex(2). But also, the whole menu:

  • EAGAIN or EWOULDBLOCK β€” The value pointed to by uaddr was not equal to the expected value val at the time of the call. It changed on you, bestie, not your fault. πŸ™ˆ
  • EFAULT β€” uaddr2 or timeout did not point to a valid user-space address.
  • EINVAL β€” The supplied timeout argument was invalid (tv_sec was less than zero, or tv_nsec was not less than 1,000,000,000).
  • EINVAL β€” uaddr2 does not point to a valid object β€” that is, the address is not four-byte-aligned. Yes, two separate EINVALs, they're twins, keep up. πŸ’€
  • ENOSYS β€” A run-time check determined that the operation is not available. The PI-futex operations are not implemented on all architectures and are not supported on some CPU variants. So if it's missing on your machine, it's not you, it's the CPU. πŸ”₯
  • ETIMEDOUT β€” The timeout expired before the operation completed. Time ran out, the clock ate, periodt. ⭐

🌈 STANDARDS

Linux. That's it, that's the standard. πŸ’œ


πŸ•°οΈ HISTORY

Linux 2.6.31 β€” an elder, but a legendary one. πŸ‘‘


πŸ“ SEE ALSO


lowkey reminder bestie: timeout is an absolute timeout and it has to be valid, and that uaddr2 alignment thing is four-byte-aligned or nothing. no cap. πŸ’…

mwah πŸ’– that's the whole page β€” written by the Linux man-pages crew, version 6.20, dated 2026-02-10. go forth and futex responsibly, queen 🧚✨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms