Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 History  





2 Operations  





3 See also  





4 References  





5 External links  














Futex






Deutsch
Français

Русский
Українська

 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


Incomputing, a futex (short for "fast userspace mutex") is a kernel system call that programmers can use to implement basic locking, or as a building block for higher-level locking abstractions such as semaphores and POSIX mutexes or condition variables.

A futex consists of a kernel-space wait queue that is attached to an atomic integerinuserspace. Multiple processesorthreads operate on the integer entirely in userspace (using atomic operations to avoid interfering with one another), and only resort to relatively expensive[citation needed] system calls to request operations on the wait queue (for example to wake up waiting processes, or to put the current process on the wait queue). A properly programmed futex-based lock will not use system calls except when the lock has contention; since most operations do not require arbitration between processes, this will not happen in most cases.

History[edit]

Hubertus Franke (IBM Thomas J. Watson Research Center), Matthew Kirkwood, Ingo Molnár (Red Hat), and Rusty Russell (IBM Linux Technology Center) originated the futex mechanism on Linux in 2002. [1] In the same year, discussions took place on a proposal to make futexes accessible via the file system by creating a special node in /devor/proc. However, Linus Torvalds strongly opposed this idea and rejected any related patches.[2]

Futexes then appeared for the first time in version 2.5.7 of the Linux kernel development series; the semantics stabilized as of version 2.5.40, and futexes have been part of the Linux kernel mainline since the December 2003 release of 2.6.x stable kernel series.

Futex functionality has been implemented in Microsoft Windows since Windows 8 or Windows Server 2012 under the name WaitOnAddress.[3]

In 2013, Microsoft patented futex-related[4] WaitOnAddress and the patent was granted in 2014.[5]

In May 2014, the CVE system announced a vulnerability discovered in the Linux kernel's futex subsystem that allowed denial-of-service attacks or local privilege escalation.[6][7]

In May 2015, the Linux kernel introduced a deadlock bug via Commit b0c29f79ecea that caused a hang in user applications. The bug affected many enterprise Linux distributions, including 3.x and 4.x kernels, and Red Hat Enterprise Linux version 5, 6 and 7, SUSE Linux 12 and Amazon Linux.[8]

Futexes have been implemented in OpenBSD since 2016.[9]

The futex mechanism is one of the core concepts of the Zircon kernel[10]inGoogle's Fuchsia operating system since at least April 2018.[11]

Apple implemented futex in iOS/iPadOS/tvOS 17.4, macOS 14.4, watchOS 10.4 and visionOS 1.1.[12]

Operations[edit]

Futexes have two basic operations, WAIT and WAKE.

If the value stored at the address addrisval, puts the current thread to sleep.
Wakes up num number of threads waiting on the address addr.

For more advanced uses, there are a number of other operations, the most used being CMP_REQUEUE and WAKE_OP, which both function as more generic WAKE operations.[13]

If the value stored at the address old_addrisval, wakes num_wake threads waiting on the address old_addr, and enqueues num_move threads waiting on the address old_addr to now wait on the address new_addr. This can be used to avoid the thundering herd problem on wake.[14][15]
Will read addr2, perform op with op_arg on it, and store the result back to addr2. Then it will wake num1 threads waiting on addr1, and, if the previously read value from addr2 matches cmp_arg using comparison cmp, will wake num2 threads waiting on addr2. This very flexible and generic wake mechanism is useful for implementing many synchronization primitives.

See also[edit]

References[edit]

  1. ^ "Fuss, Futexes and Furwocks: Fast Userlevel Locking in Linux" by Franke, Russell, Kirkwood. Published in 2002 for the Ottawa Linux Symposium.
  • ^ Torvalds, Linus. "Futex Asynchronous Interface".
  • ^ "WaitOnAddress function". Retrieved 2019-11-01.
  • ^ "Comparing WaitOnAddress with futexes". Retrieved 2024-05-09.
  • ^ "US8782674B2 Wait on address synchronization interface". Retrieved 2019-11-01.
  • ^ CVE-2014-3153
  • ^ "[SECURITY] [DSA 2949-1] linux security update". Lists.debian.org. 2014-06-05. Retrieved 2014-06-08.
  • ^ "Linux futex_wait() bug..." 2015-05-13. Retrieved 2018-03-24.
  • ^ Mazurek, Michal. "'Futexes for OpenBSD' - MARC". marc.info. Retrieved 30 April 2017.
  • ^ "Zircon Kernel Concepts". fuchsia.dev. Retrieved 20 October 2019.
  • ^ "zx_futex_wait". fuchsia.dev. Retrieved 20 October 2019.
  • ^ "os_sync_wait_on_address". Apple Developer Documentation. Retrieved 2024-03-14.
  • ^ Futexes Are Tricky Ulrich Drepper (Red Hat, v1.6, 2011)
  • ^ Linux futex(2) man page, FUTEX_CMP_REQUEUE section
  • ^ Zircon zx_futex_requeue documentation
  • External links[edit]


    Retrieved from "https://en.wikipedia.org/w/index.php?title=Futex&oldid=1227086842"

    Categories: 
    Concurrency control
    Linux kernel features
    Hidden categories: 
    Articles with short description
    Short description is different from Wikidata
    All articles with unsourced statements
    Articles with unsourced statements from October 2021
    Articles to be expanded from November 2021
     



    This page was last edited on 3 June 2024, at 16:35 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki