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
timeoutis notNULL, the structure it points to specifies an absolute timeout for the wait operation. - If
timeoutisNULL, 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:
EAGAINorEWOULDBLOCKβ The value pointed to byuaddrwas not equal to the expected valuevalat the time of the call. It changed on you, bestie, not your fault. πEFAULTβuaddr2ortimeoutdid not point to a valid user-space address.EINVALβ The suppliedtimeoutargument was invalid (tv_secwas less than zero, ortv_nsecwas not less than1,000,000,000).EINVALβuaddr2does not point to a valid object β that is, the address is not four-byte-aligned. Yes, two separateEINVALs, 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:timeoutis an absolute timeout and it has to be valid, and thatuaddr2alignment 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