World Library  
Flag as Inappropriate
Email this Article

Futex

Article Id: WHEBN0000680285
Reproduction Date:

Title: Futex  
Author: World Heritage Encyclopedia
Language: English
Subject: Linux kernel, Native POSIX Thread Library, Compare-and-swap, Concurrency control, Kernel same-page merging
Collection: Concurrency Control, Linux Kernel Features
Publisher: World Heritage Encyclopedia
Publication
Date:
 

Futex

In computing, a futex (short for "fast userspace mutex") is a Linux 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 kernelspace wait queue that is attached to an aligned integer in userspace. Multiple processes or threads operate on the integer entirely in userspace (using atomic operations to avoid interfering with one another), and only resort to relatively expensive 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 is contended; since most operations do not require arbitration between processes, this will not happen in most cases.

Contents

  • History 1
  • Operations 2
  • See also 3
  • References 4
  • External links 5

History

On Linux, 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. Futexes 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.

In 2002 discussions took place on a proposal to make futexes accessible via the file system by creating a special node in /dev or /proc. However, Linus Torvalds strongly opposed this idea and rejected any related patches.[1]

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.[2][3]

A technique very similar to the futex mechanism, called benaphore, was available at least since 1996 in the BeOS operating system, which Be Inc. originally wrote for BeBox hardware.[4]

Operations

The basic operations of futexes are based on only two central operations—​WAIT and WAKE—​though some futex implementations (depending on the exact version of the Linux kernel) have a few more operations for more specialized cases.[5]

  • WAIT (addr, val)
Checks if the value stored at the address addr is val, and if it is puts the current thread to sleep.
  • WAKE (addr, val)
Wakes up val number of threads waiting on the address addr.

See also

References

  1. ^ Torvalds, Linus. "Futex Asynchronous Interface". 
  2. ^ CVE-2014-3153
  3. ^ "[SECURITY] [DSA 2949-1] linux security update". Lists.debian.org. 2014-06-05. Retrieved 2014-06-08. 
  4. ^ Benoit Schillings (1996-06-05). "Be Engineering Insights: Benaphores". haiku-os.org. Retrieved 2014-09-09. 
  5. ^ Futexes Are Tricky, Red Hat (v 1.6, 2011).

External links

  • - futex() system call
  • - futex semantics and usage
  • Hubertus Franke, Rusty Russell, Matthew Kirkwood, Fuss, futexes and furwocks: Fast Userlevel Locking in Linux, Ottawa Linux Symposium 2002.
  • Futex manpages
  • Ingo Molnar, "Robust Futexes", Linux Kernel Documentation
  • "Priority Inheritance Futexes", Linux Kernel Documentation


This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.