Futex in multithreaded applications

Lecture



Futex (English futex , short for Fast userspace mutex ) is programming how to implement POSIX semaphores and Linux mutexes. First introduced into the Linux kernel from version 2.5.7 (development); stable semantics since 2.5.40; included in stable versions of the 2.6.x series.

Developed by Hubertus Franke (from the Thomas Watson IBM Research Center), IBM Linux Technology Center employees at Matthew Kirkwood and Rusty Russell, and Ingo Molnar, a developer at Red Hat.

A futex is an aligned integer in shared memory (for multiple processors) in user space and a waiting queue in kernel space [1] . Organizing a futex requires at least one memory page mapped to the address space of each of the processes involved in the futex. System calls are intended only for user-space stream libraries and only in the form of assembler commands [2] .

The shared integer can be increased or decreased by one for one assembly instruction. Processes “tied” to this futex are waiting for this value to become positive. All operations with futexes are almost completely carried out in user space (in the absence of rivalry [3] ), the corresponding kernel functions are used only in a limited set of contentious cases. This makes it possible to increase the efficiency of using synchronization primitives, since most of the operations do not use arbitration, and therefore avoid the use of relatively expensive system calls.

CRITICAL_SECTION objects in the Win32 API are optimized in a similar way, as well as FAST_MUTEX in the Windows kernel. [four]

see also

  • Asynchronous semaphore
  • Critical section
  • Mutex
  • Race condition
  • Shared memory
  • Condition variable

Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Operating Systems and System Programming

Terms: Operating Systems and System Programming