]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/futex.2
futex.2: Rewrite the intro paragraphs a little
[thirdparty/man-pages.git] / man2 / futex.2
CommitLineData
8f0aff2a 1.\" Page by b.hubert
2297bf0e 2.\"
2e46a6e7 3.\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE)
8f0aff2a 4.\" may be freely modified and distributed
8ff7380d 5.\" %%%LICENSE_END
fea681da
MK
6.\"
7.\" Niki A. Rahimi (LTC Security Development, narahimi@us.ibm.com)
8.\" added ERRORS section.
9.\"
10.\" Modified 2004-06-17 mtk
11.\" Modified 2004-10-07 aeb, added FUTEX_REQUEUE, FUTEX_CMP_REQUEUE
12.\"
c13182ef
MK
13.\" 2.6.18 adds (Ingo Molnar) priority inheritance support:
14.\" FUTEX_LOCK_PI, FUTEX_UNLOCK_PI, and FUTEX_TRYLOCK_PI. These need
34f7665a
MK
15.\" to be documented in the manual page. Probably there is sufficient
16.\" material in the kernel source file Documentation/pi-futex.txt.
4f58b197
MK
17.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
18.\" Author: Ingo Molnar <mingo@elte.hu>
19.\" Date: Tue Jun 27 02:54:58 2006 -0700
20.\"
21.\" commit e2970f2fb6950183a34e8545faa093eb49d186e1
22.\" Author: Ingo Molnar <mingo@elte.hu>
23.\" Date: Tue Jun 27 02:54:47 2006 -0700
24.\"
27b38e1c 25.\" See Documentation/pi-futex.txt
4f58b197 26.\"
bea08fec 27.\" FIXME .
40d5cf23 28.\" 2.6.25 adds FUTEX_WAKE_BITSET, FUTEX_WAIT_BITSET
4f58b197
MK
29.\" commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d
30.\" Author: Thomas Gleixner <tglx@linutronix.de>
31.\" Date: Fri Feb 1 17:45:14 2008 +0100
32.\"
bea08fec 33.\" FIXME .
4f58b197
MK
34.\" 2.6.31 adds FUTEX_WAIT_REQUEUE_PI, FUTEX_CMP_REQUEUE_PI
35.\" commit 52400ba946759af28442dee6265c5c0180ac7122
36.\" Author: Darren Hart <dvhltc@us.ibm.com>
37.\" Date: Fri Apr 3 13:40:49 2009 -0700
38.\"
39.\" commit ba9c22f2c01cf5c88beed5a6b9e07d42e10bd358
40.\" Author: Darren Hart <dvhltc@us.ibm.com>
41.\" Date: Mon Apr 20 22:22:22 2009 -0700
42.\"
43.\" See Documentation/futex-requeue-pi.txt
34f7665a 44.\"
3d155313 45.TH FUTEX 2 2014-05-21 "Linux" "Linux Programmer's Manual"
fea681da 46.SH NAME
ce154705 47futex \- fast user-space locking
fea681da 48.SH SYNOPSIS
9d9dc1e8 49.nf
fea681da
MK
50.sp
51.B "#include <linux/futex.h>"
fea681da
MK
52.B "#include <sys/time.h>"
53.sp
d33602c4
MK
54.BI "int futex(int *" uaddr ", int " futex_op ", int " val ,
55.BI " const struct timespec *" timeout ,
9d9dc1e8 56.BI " int *" uaddr2 ", int " val3 );
fea681da 57.\" int *? void *? u32 *?
9d9dc1e8 58.fi
409f08b0 59
b939d6e4
MK
60.IR Note :
61There is no glibc wrapper for this system call; see NOTES.
47297adb 62.SH DESCRIPTION
fea681da
MK
63.PP
64The
e511ffb6 65.BR futex ()
fea681da
MK
66system call provides a method for
67a program to wait for a value at a given address to change, and a
68method to wake up anyone waiting on a particular address (while the
69addresses for the same memory in separate processes may not be
70equal, the kernel maps them internally so the same memory mapped in
71different locations will correspond for
e511ffb6 72.BR futex ()
c13182ef 73calls).
fd3fa7ef 74This system call is typically used to
fea681da
MK
75implement the contended case of a lock in shared memory, as
76described in
a8bda636 77.BR futex (7).
fea681da 78.PP
f388ba70
MK
79When a futex operation did not finish uncontended in user space, a
80.BR futex ()
81call needs to be made to the kernel to arbitrate.
c13182ef 82Arbitration can either mean putting the calling
fea681da
MK
83process to sleep or, conversely, waking a waiting process.
84.PP
f388ba70
MK
85Callers of
86.BR futex ()
87are expected to adhere to the semantics described in
a8bda636 88.BR futex (7).
fea681da 89As these
d603cc27 90semantics involve writing nonportable assembly instructions, this in turn
fea681da
MK
91probably means that most users will in fact be library authors and not
92general application developers.
93.PP
94The
95.I uaddr
f388ba70
MK
96argument points to an integer which stores the counter (futex).
97On all platforms, futexes are four-byte integers that
98must be aligned on a four-byte boundary.
99The operation to perform on the futex is specified in the
100.I futex_op
101argument;
102.IR val
103is a value whose meaning and purpose depends on
104.IR futex_op .
fea681da 105.PP
6be4bad7 106The
d33602c4 107.I futex_op
6be4bad7
MK
108argument consists of two parts:
109a command that specifies the operation to be performed,
110bit-wise ORed with zero or or more options that
111modify the behaviour of the operation.
fc30eb79 112The options that may be included in
d33602c4 113.I futex_op
fc30eb79
TG
114are as follows:
115.TP
116.BR FUTEX_PRIVATE_FLAG " (since Linux 2.6.22)"
117.\" commit 34f01cc1f512fa783302982776895c73714ebbc2
118This option bit can be employed with all futex operations.
119It tells the kernel that the futex is process private and not shared
120with another process.
121This allows the kernel to choose the fast path for validating
122the user-space address and avoids expensive VMA lookups,
123taking reference counts on file backing store, and so on.
2e98bbc2
TG
124.TP
125.BR FUTEX_CLOCK_REALTIME " (since Linux 2.6.28)"
126.\" commit 1acdac104668a0834cfa267de9946fac7764d486
4a7e5b05 127This option bit can be employed only with the
2e98bbc2
TG
128.BR FUTEX_WAIT_BITSET
129and
130.BR FUTEX_WAIT_REQUEUE_PI
131operations (described below).
132
133If this option is set,
134the kernel treats the user space supplied timeout as an absolute
135time based on
136.BR CLOCK_REALTIME .
137
138If this option is not set,
1c952cf5
MK
139the kernel treats the user space supplied timeout as relative time,
140.\" FIXME I added CLOCK_MONOTONIC here. Is it correct?
141measured against the
142.BR CLOCK_MONOTONIC
143clock.
6be4bad7
MK
144.PP
145The operation specified in
d33602c4 146.I futex_op
6be4bad7 147is one of the following:
fea681da 148.TP
81c9d87e
MK
149.BR FUTEX_WAIT " (since Linux 2.6.0)"
150.\" Strictly speaking, since some time in 2.5.x
f065673c
MK
151This operation tests that the value at the
152location pointed to by the futex address
fea681da
MK
153.I uaddr
154still contains the value
155.IR val ,
f065673c 156and then sleeps awaiting
682edefb 157.B FUTEX_WAKE
f065673c
MK
158on the futex address.
159The test and sleep steps are performed atomically.
160If the futex value does not match
161.IR val ,
162then the call returns immediately with the error
163.BR EWOULDBLOCK .
164.\" FIXME I added the following sentence. Please confirm that it is correct.
165The purpose of the test step is to detect races where
166another process changes that value of the futex between
167the time it was last checked and the time of the
168.BR FUTEX_WAIT
169oepration.
170
1909e523 171
c13182ef 172If the
fea681da 173.I timeout
1c952cf5
MK
174argument is non-NULL, its contents specify a relative timeout for the wait
175.\" FIXME I added CLOCK_MONOTONIC here. Is it correct?
176measured according to the
177.BR CLOCK_MONOTONIC
178clock.
82a6092b
MK
179(This interval will be rounded up to the system clock granularity,
180and kernel scheduling delays mean that the
181blocking interval may overrun by a small amount.)
182If
183.I timeout
184is NULL, the call blocks indefinitely.
4798a7f3 185
c13182ef 186The arguments
fea681da
MK
187.I uaddr2
188and
189.I val3
190are ignored.
191
192For
a8bda636 193.BR futex (7),
fea681da
MK
194this call is executed if decrementing the count gave a negative value
195(indicating contention), and will sleep until another process releases
682edefb
MK
196the futex and executes the
197.B FUTEX_WAKE
198operation.
fea681da 199.TP
d67e21f5
MK
200.BR FUTEX_WAIT_BITSET " (since Linux 2.6.25)"
201.\" commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d
202.\" FIXME TO complete
203[As yet undocumented]
204.TP
81c9d87e
MK
205.BR FUTEX_WAKE " (since Linux 2.6.0)"
206.\" Strictly speaking, since Linux 2.5.x
f065673c
MK
207This operation wakes at most
208.I val
209processes waiting (i.e., inside
210.BR FUTEX_WAIT )
211on the futex at the address
212.IR uaddr .
213Most commonly,
214.I val
215is specified as either 1 (wake up a single waiter) or
216.BR INT_MAX
217(wake up all waiters).
4798a7f3 218
fea681da
MK
219The arguments
220.IR timeout ,
221.I uaddr2
222and
223.I val3
224are ignored.
225
226For
a8bda636 227.BR futex (7),
fea681da
MK
228this is executed if incrementing
229the count showed that there were waiters, once the futex value has been set
230to 1 (indicating that it is available).
6bac3b85
MK
231.\"
232.\" FIXME I added some FUTEX_WAKE_OP text, and I'd be happy if someone
233.\" checked it.
fea681da 234.TP
d67e21f5
MK
235.BR FUTEX_WAKE_OP " (since Linux 2.6.14)"
236.\" commit 4732efbeb997189d9f9b04708dc26bf8613ed721
6bac3b85
MK
237.\" Author: Jakub Jelinek <jakub@redhat.com>
238.\" Date: Tue Sep 6 15:16:25 2005 -0700
239This operation was added to support some user-space use cases
240where more than one futex must be handled at the same time.
241The most notable example is the implementation of
242.BR pthread_cond_signal (3),
243which requires operations on two futexes,
244the one used to implement the mutex and the one used in the implementation
245of the wait queue associated with the condition variable.
246.BR FUTEX_WAKE_OP
247allows such cases to be implemented without leading to
248high rates of contention and context switching.
249
250The
251.BR FUTEX_WAIT_OP
252operation is equivalent to atomically executing the following code:
253
254.in +4n
255.nf
256int oldval = *(int *) uaddr2;
257*(int *) uaddr2 = oldval \fIop\fP \fIoparg\fP;
258futex(uaddr, FUTEX_WAKE, val, 0, 0, 0);
259if (oldval \fIcmp\fP \fIcmparg\fP)
260 futex(uaddr2, FUTEX_WAKE, nr_wake2, 0, 0, 0);
261.fi
262.in
263
264In other words,
265.BR FUTEX_WAIT_OP
266does the following:
267.RS
268.IP * 3
269saves the original value of the futex at
270.IR uaddr2 ;
271.IP *
272performs an operation to modify the value of the futex at
273.IR uaddr2 ;
274.IP *
275wakes up a maximum of
276.I val
277waiters on the futex
278.IR uaddr ;
279and
280.IP *
281dependent on the results of a test of the original value of the futex at
282.IR uaddr2 ,
283wakes up a maximum of
284.I nr_wake2
285waiters on the futex
286.IR uaddr2 .
287.RE
288.IP
289The
290.I nr_wake2
291value is actually the
292.BR futex ()
293.I timeout
294argument (ab)used to specify how many of the waiters on the futex at
295.IR uaddr2
296are to be woken up;
297the kernel casts the
298.I timeout
299value to
300.IR u32 .
301
302The operation and comparison that are to be performed are encoded
303in the bits of the argument
304.IR val3 .
305Pictorially, the encoding is:
306
307.in +4n
308.nf
309 +-----+-----+---------------+---------------+
310 | op | cmp | oparg | cmparg |
311 +-----+-----+---------------+---------------+
312# of bits: 4 4 12 12
313
314.fi
315.in
316
317Expressed in code, the encoding is:
318
319.in +4n
320.nf
321#define FUTEX_OP(op, oparg, cmp, cmparg) \\
322 (((op & 0xf) << 28) | \\
323 ((cmp & 0xf) << 24) | \\
324 ((oparg & 0xfff) << 12) | \\
325 (cmparg & 0xfff))
326.fi
327.in
328
329In the above,
330.I op
331and
332.I cmp
333are each one of the codes listed below.
334The
335.I oparg
336and
337.I cmparg
338components are literal numeric values, except as noted below.
339
340The
341.I op
342component has one of the following values:
343
344.in +4n
345.nf
346FUTEX_OP_SET 0 /* uaddr2 = oparg; */
347FUTEX_OP_ADD 1 /* uaddr2 += oparg; */
348FUTEX_OP_OR 2 /* uaddr2 |= oparg; */
349FUTEX_OP_ANDN 3 /* uaddr2 &= ~oparg; */
350FUTEX_OP_XOR 4 /* uaddr2 ^= oparg; */
351.fi
352.in
353
354In addition, bit-wise ORing the following value into
355.I op
356causes
357.IR "(1\ <<\ oparg)"
358to be used as the operand:
359
360.in +4n
361.nf
362FUTEX_OP_ARG_SHIFT 8 /* Use (1 << oparg) as operand */
363.fi
364.in
365
366The
367.I cmp
368field is one of the following:
369
370.in +4n
371.nf
372FUTEX_OP_CMP_EQ 0 /* if (oldval == cmparg) wake */
373FUTEX_OP_CMP_NE 1 /* if (oldval != cmparg) wake */
374FUTEX_OP_CMP_LT 2 /* if (oldval < cmparg) wake */
375FUTEX_OP_CMP_LE 3 /* if (oldval <= cmparg) wake */
376FUTEX_OP_CMP_GT 4 /* if (oldval > cmparg) wake */
377FUTEX_OP_CMP_GE 5 /* if (oldval >= cmparg) wake */
378.fi
379.in
380
381The return value of
382.BR FUTEX_WAKE_OP
383is the sum of the number of waiters woken on the futex
384.IR uaddr
385plus the number of waiters woken on the futex
386.IR uaddr2 .
d67e21f5
MK
387.TP
388.BR FUTEX_WAKE_BITSET " (since Linux 2.6.25)"
389.\" commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d
390.\" FIXME TO complete
391[As yet undocumented]
392.TP
393.BR FUTEX_LOCK_PI " (since Linux 2.6.18)"
394.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
395.\" FIXME to complete
396[As yet undocumented]
397.TP
398.BR FUTEX_UNLOCK_PI " (since Linux 2.6.18)"
399.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
400.\" FIXME to complete
401[As yet undocumented]
402.TP
403.BR FUTEX_TRYLOCK_PI " (since Linux 2.6.18)"
404.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
405.\" FIXME to complete
406[As yet undocumented]
407.TP
81c9d87e
MK
408.BR FUTEX_FD " (from Linux 2.6.0 up to and including Linux 2.6.25)"
409.\" Strictly speaking, from Linux 2.5.x to 2.6.25
fea681da
MK
410To support asynchronous wakeups, this operation associates a file descriptor
411with a futex.
412.\" , suitable for .BR poll (2).
682edefb
MK
413If another process executes a
414.BR FUTEX_WAKE ,
415the process will receive the signal number that was passed in
fea681da
MK
416.IR val .
417The calling process must close the returned file descriptor after use.
4798a7f3 418
fea681da
MK
419The arguments
420.IR timeout ,
421.I uaddr2
422and
423.I val3
424are ignored.
425
c13182ef 426To prevent race conditions, the caller should test if the futex has
682edefb
MK
427been upped after
428.B FUTEX_FD
429returns.
266a5e91 430
da36351e 431Because it was inherently racy,
682edefb 432.B FUTEX_FD
5fab2e7c 433has been removed from Linux 2.6.26 onward.
fea681da 434.TP
81c9d87e
MK
435.BR FUTEX_REQUEUE " (since Linux 2.6.0)"
436.\" Strictly speaking: from Linux 2.5.70
4ac63a6c
MK
437.\"
438.\" FIXME I added this warning. Okay?
439.IR "Avoid using this operation" .
dd05d612 440It is broken (unavoidably racy) for its intended purpose.
4ac63a6c
MK
441Use
442.BR FUTEX_CMP_REQUEUE
443instead.
444
dd05d612
MK
445This operation performs the same task as
446.BR FUTEX_CMP_REQUEUE ,
447except that no check is made using the value in
448.IR val3 .
449(The argument
fea681da 450.I val3
dd05d612 451is ignored.)
fea681da
MK
452.TP
453.BR FUTEX_CMP_REQUEUE " (since Linux 2.6.7)"
3dfcc11d 454This operation was added as a replacement for the earlier
682edefb 455.BR FUTEX_REQUEUE ,
3dfcc11d
MK
456because that operation was racy for its intended use.
457
458As with
682edefb 459.BR FUTEX_REQUEUE ,
3dfcc11d
MK
460the
461.BR FUTEX_CMP_REQUEUE
462operation is used to avoid a "thundering herd" effect when
463.B FUTEX_WAKE
464is used and all processes woken up need to acquire another futex.
465It differs from
466.BR FUTEX_REQUEUE
467in that it first checks whether the location
fea681da
MK
468.I uaddr
469still contains the value
470.IR val3 .
e808bba0
MK
471If not, the operation fails with the error
472.BR EAGAIN .
3dfcc11d
MK
473.\" FIXME I added the following sentence on rational for FUTEX_CMP_REQUEUE.
474.\" Is it correct? SHould it be expanded?
475This additional feature of
476.BR FUTEX_CMP_REQUEUE
477can be used by the caller to (atomically) detect changes
478in the value of the target futex at
479.IR uaddr2 .
4798a7f3 480
3dfcc11d
MK
481The operation wakes up a maximum of
482.I val
483waiters that are waiting on the futex at
484.IR uaddr .
485If there are more than
486.I val
487waiters, then the remaining waiters are removed
488from the wait queue of the source futex at
489.I uaddr
490and added to the wait queue of the target futex at
491.IR uaddr2 .
492The
493.I timeout
494argument is (ab)used to specify a cap on the number of waiters
495that are requeued to the futex at
496.IR uaddr2 ;
497the kernel casts the
fea681da 498.I timeout
3dfcc11d
MK
499value to
500.IR u32 .
501
502.\" FIXME Please review the following new paragraph to see if it is
503.\" accurate.
504Typical values to specify for
505.I val
506are 0 or or 1.
507(Specifying
508.BR INT_MAX
509is not useful, because it would make the
510.BR FUTEX_CMP_REQUEUE
511operation equivalent to
512.BR FUTEX_WAKE .)
513The cap value specified via the (abused)
514.I timeout
515argument is typically either 1 or
516.BR INT_MAX .
517(Specifying the argument as 0 is not useful, because it would make the
518.BR FUTEX_CMP_REQUEUE
519operation equivalent to
520.BR FUTEX_WAIT .)
d67e21f5
MK
521.TP
522.BR FUTEX_CMP_REQUEUE_PI " (since Linux 2.6.31)"
523.\" commit 52400ba946759af28442dee6265c5c0180ac7122
524.\" FIXME to complete
525[As yet undocumented]
526.TP
527.BR FUTEX_WAIT_REQUEUE_PI " (since Linux 2.6.31)"
528.\" commit 52400ba946759af28442dee6265c5c0180ac7122
529.\" FIXME to complete
530[As yet undocumented]
47297adb 531.SH RETURN VALUE
fea681da 532.PP
e808bba0
MK
533In the event of an error, all operations return \-1, and set
534.I errno
535to indicate the error.
536The return value on success depends on the operation,
537as described in the following list:
fea681da
MK
538.TP
539.B FUTEX_WAIT
682edefb
MK
540Returns 0 if the process was woken by a
541.B FUTEX_WAKE
542call.
e808bba0 543See ERRORS for the various possible error returns.
fea681da
MK
544.TP
545.B FUTEX_WAKE
546Returns the number of processes woken up.
547.TP
548.B FUTEX_FD
549Returns the new file descriptor associated with the futex.
550.TP
551.B FUTEX_REQUEUE
552Returns the number of processes woken up.
553.TP
554.B FUTEX_CMP_REQUEUE
3dfcc11d
MK
555Returns the total number of processes woken up or requeued to the futex at
556.IR uaddr2 .
557If this value is greater than
558.IR val ,
559then difference is the number of waiters requeued to the futex at
560.IR uaddr2 .
519f2c3d
MK
561.\"
562.\" FIXME Add success returns for other operations
fea681da
MK
563.SH ERRORS
564.TP
565.B EACCES
566No read access to futex memory.
567.TP
568.B EAGAIN
682edefb 569.B FUTEX_CMP_REQUEUE
e808bba0 570detected that the value pointed to by
9f6c40c0
МК
571.I uaddr
572is not equal to the expected value
573.IR val3 .
fd1dc4c2 574.\" FIXME: Is the following sentence correct?
fea681da 575(This probably indicates a race;
682edefb
MK
576use the safe
577.B FUTEX_WAKE
578now.)
fea681da
MK
579.TP
580.B EFAULT
1ea901e8
MK
581A required pointer argument (i.e.,
582.IR uaddr ,
583.IR uaddr2 ,
584or
585.IR timeout )
496df304 586did not point to a valid user-space address.
fea681da 587.TP
9f6c40c0 588.B EINTR
e808bba0 589A
9f6c40c0 590.B FUTEX_WAIT
e808bba0
MK
591operation was interrupted by a signal (see
592.BR signal (7))
593or a spurious wakeup.
9f6c40c0 594.TP
fea681da 595.B EINVAL
fb2f4c27
MK
596.RB ( FUTEX_WAIT ,
597.BR FUTEX_WAIT_REQUEUE_PI )
598The supplied
599.I timeout
600argument was invalid
601.RI ( tv_sec
602was less than zero, or
603.IR tv_nsec
604was not less than 1000,000,000).
605.TP
606.B EINVAL
ea355b7f 607.RB ( FUTEX_WAIT ,
caf1ff25 608.BR FUTEX_WAKE ,
6bac3b85 609.BR FUTEX_WAKE_OP ,
a1f47699
MK
610.BR FUTEX_REQUEUE ,
611.BR FUTEX_CMP_REQUEUE )
51ee94be 612.I uaddr
caf1ff25 613or (for
a1f47699
MK
614.BR FUTEX_REQUEUE
615and
616.BR FUTEX_CMP_REQUEUE )
caf1ff25 617.I uaddr2
51ee94be
MK
618does not point to a valid object\(emthat is,
619the address is not 4-byte-aligned.
620.TP
621.B EINVAL
bae14b6c 622.RB ( FUTEX_WAKE ,
e169277f
MK
623.BR FUTEX_REQUEUE ,
624.BR FUTEX_CMP_REQUEUE )
496df304 625The kernel detected an inconsistency between the user-space state at
9534086b
TG
626.I uaddr
627and the kernel state\(emthat is, it detected a waiter which waits in
628.BR FUTEX_LOCK_PI .
629.TP
630.B EINVAL
add875c0
MK
631.RB ( FUTEX_REQUEUE )
632.\" FIXME tglx suggested adding this, but does this error really
633.\" occur for FUTEX_REQUEUE?
634.I uaddr
635equals
636.IR uaddr2
637(i.e., an attempt was made to requeue to the same futex).
638.TP
639.B EINVAL
6bac3b85
MK
640.RB ( FUTEX_WAKE_OP )
641The kernel detected an inconsistency between the user-space state at
642.I uaddr
643and the kernel state; that is, it detected a waiter which waits in
644.B FUTEX_LOCK_PI
645on
646.IR uaddr .
647.TP
648.B EINVAL
4832b48a 649Invalid argument.
fea681da
MK
650.TP
651.B ENFILE
652The system limit on the total number of open files has been reached.
4701fc28
MK
653.TP
654.B ENOSYS
655Invalid operation specified in
d33602c4 656.IR futex_op .
9f6c40c0 657.TP
4a7e5b05
MK
658.B ENOSYS
659The
660.BR FUTEX_CLOCK_REALTIME
661option was specified in
d33602c4 662.I futex_op ,
4a7e5b05
MK
663but the accompanying operation was neither
664.BR FUTEX_WAIT_BITSET
665nor
666.BR FUTEX_WAIT_REQUEUE_PI .
667.TP
9f6c40c0 668.B ETIMEDOUT
d1926d78
MK
669.RB ( FUTEX_WAIT )
670The operation timed out.
9f6c40c0
МК
671.TP
672.B EWOULDBLOCK
d33602c4 673.I futex_op
e808bba0
MK
674was
675.BR FUTEX_WAIT
676and the value pointed to by
9f6c40c0
МК
677.I uaddr
678was not equal to the expected value
679.I val
e808bba0 680at the time of the call.
47297adb 681.SH VERSIONS
a1d5f77c 682.PP
81c9d87e
MK
683Futexes were first made available in a stable kernel release
684with Linux 2.6.0.
685
a1d5f77c
MK
686Initial futex support was merged in Linux 2.5.7 but with different semantics
687from what was described above.
c4bb193f 688A 4-argument system call with the semantics
fd3fa7ef 689described in this page was introduced in Linux 2.5.40.
11b520ed 690In Linux 2.5.70, one argument
a1d5f77c 691was added.
11b520ed 692In Linux 2.6.7, a sixth argument was added\(emmessy, especially
a1d5f77c 693on the s390 architecture.
47297adb 694.SH CONFORMING TO
8382f16d 695This system call is Linux-specific.
47297adb 696.SH NOTES
fea681da 697.PP
fcdad7d6 698To reiterate, bare futexes are not intended as an easy-to-use abstraction
c13182ef 699for end-users.
fcdad7d6 700(There is no wrapper function for this system call in glibc.)
c13182ef 701Implementors are expected to be assembly literate and to have
7fac88a9 702read the sources of the futex user-space library referenced below.
d282bb24 703.\" .SH AUTHORS
fea681da
MK
704.\" .PP
705.\" Futexes were designed and worked on by
706.\" Hubertus Franke (IBM Thomas J. Watson Research Center),
707.\" Matthew Kirkwood, Ingo Molnar (Red Hat)
708.\" and Rusty Russell (IBM Linux Technology Center).
709.\" This page written by bert hubert.
47297adb 710.SH SEE ALSO
d806bc05 711.BR restart_syscall (2),
14d8dd3b 712.BR futex (7)
fea681da 713.PP
52087dd3 714\fIFuss, Futexes and Furwocks: Fast Userlevel Locking in Linux\fP
9b936e9e
MK
715(proceedings of the Ottawa Linux Symposium 2002), online at
716.br
608bf950
SK
717.UR http://kernel.org\:/doc\:/ols\:/2002\:/ols2002-pages-479-495.pdf
718.UE
f42eb21b
MK
719
720\fIFutexes Are Tricky\fP (updated in 2011), Ulrich Drepper
721.UR http://www.akkadia.org/drepper/futex.pdf
722.UE
9b936e9e
MK
723.PP
724Futex example library, futex-*.tar.bz2 at
725.br
a605264d 726.UR ftp://ftp.kernel.org\:/pub\:/linux\:/kernel\:/people\:/rusty/
608bf950 727.UE