Futex

from Wikipedia, the free encyclopedia

A Futex ( English almost userspace mutual exclusion as "fast mutual exclusion in user space") is a mutex - locker classes , of the operating system Linux is supported. The specialty of the Futex implementation is that a large part of the operations is carried out in userspace , thus avoiding expensive calls to the kernel . In contrast to the mutex, a futex is used to synchronize threads belonging to a process .

The implementation comes from Hubertus Franke ( IBM Thomas J. Watson Research Center ), Matthew Kirkwood , Ingo Molnár ( Red Hat ) and Rusty Russell ( IBM Linux Technology Center ), and became part of the Linux kernel from version 2.5.7 .

Like a mutex , a futex is a memory location that is changed atomically by various processes through locking and unlocking operations (lock / unlock) . The blocking operation ensures that all processes are blocked that want to block an already blocked Futex themselves (mutual exclusion) . In contrast to mutexes, however, the futex operations are carried out in the statistically relevant cases in user space (i.e. directly from the running program) and the kernel is only called when a process has to be blocked or activated.

Linux supports Futexe for most, but not all, processor architectures.

In general, a user program does not implement the Futex operations directly, but uses the "pthread_mutex ... ()" functions in libc, which automatically use Futexe or an interprocess Mutex implementation, depending on the processor architecture.

Since the operating system is not involved every time it is called, Futexes are generally more efficient. Since the operating system no longer has control over all locks , problems sometimes arose in the initial phase when processes with locked Futex crashed. These problems have been resolved with robust futexes , but the use of futexes still requires careful attention.

Individual evidence

  1. Hubertus Franke, Rusty Russell, Matthew Kirkwood, Fuss, futexes and furwocks: Fast Userlevel Locking in Linux ( Memento of the original from September 22, 2006 in the Internet Archive ) Info: The archive link was automatically inserted and not yet checked. Please check the original and archive link according to the instructions and then remove this notice. , Ottawa Linux Symposium, 2002. @1@ 2Template: Webachiv / IABot / www.linux.org.uk
  2. Ingo Molnar, Robust futexes , Linux Kernel Documentation.
  3. Ulrich Drepper, Futexes Are Tricky , Red Hat, 2008 (PDF, 190 kB).