FUTEX_WAKE(2const)

✨ FUTEX_WAKE ✨ (that's the 2const page bestie, section 2 constants, iykyk)

okay so. you know how threads be Waiting and Just Sitting There? yeah. this is the lil syscall constant that goes "WAKE UP GIRL πŸ’–" to the ones chilling inside FUTEX_WAIT. it's giving alarm clock but for kernel sleepers.


🌸 LIBRARY 🌸

Standard C library (libc, -lc) πŸ’…


πŸŽ€ 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_WAKE, uint32_t val);

like yes you do have to include all three headers, don't skip, the comments literally tell you why 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

So this operation wakes at most val of the waiters that are waiting (for example, the ones sitting inside FUTEX_WAIT(2const))) on the futex word at the address uaddr. At most, bestie. Not "all of them", not "exactly val" β€” at most. πŸ“Œ

Most commonly, val is specified as either 1 (wake up a single waiter, cute, lowkey, one-on-one energy) or INT_MAX (wake up all waiters, main character group-chat notification πŸŽ‰).

No guarantee is provided about which waiters are awoken (e.g., a waiter with a higher scheduling priority is not guaranteed to be awoken in preference to a waiter with a lower priority).

fr fr. the kernel does not care who you're besties with. priority does NOT earn you a fast pass here. it's a vibe check, not a ranking. 😭


🌈 RETURN VALUE 🌈

  • On error, -1 is returned, and errno is set to indicate the error. πŸ’€
  • On success, FUTEX_WAKE returns the number of waiters that were woken up. like, an actual count, so you can see how many people showed up to the party ✨

πŸ’œ ERRORS πŸ’œ

See futex(2).

  • EINVAL β€” the kernel detected an inconsistency between the user-space state at uaddr and the kernel state β€” that is, it detected a waiter which waits in FUTEX_LOCK_PI(2const) or FUTEX_LOCK_PI2(2const) on uaddr. 🚨 that's a mismatch, that's messy, the kernel is not having it.

πŸ‘‘ STANDARDS πŸ‘‘

Linux. that's it, that's the whole standard, it's a Linux thing bestie 🐧


πŸ•°οΈ HISTORY πŸ•°οΈ

Linux 2.6.0. she's been here since 2.6.0, a true icon, an OG ⭐


🌟 SEE ALSO 🌟


and that's the whole page 🫢 the Linux man-pages 6.20 girlies shipped this cutie on 2025-05-30, so if you're reading it, know that the FUTEX_WAKE(2const) page came straight from that release. mwah πŸ’‹ go wake somebody up (politely, at most val of them) πŸŽ€βœ¨

πŸ“¦ 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