]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/futex.2
futex.2: explanation of blocking
[thirdparty/man-pages.git] / man2 / futex.2
CommitLineData
8f0aff2a 1.\" Page by b.hubert
1abce893
MK
2.\" and Copyright (C) 2015, Thomas Gleixner <tglx@linutronix.de>
3.\" and Copyright (C) 2015, Michael Kerrisk <mtk.manpages@gmail.com>
2297bf0e 4.\"
2e46a6e7 5.\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE)
8f0aff2a 6.\" may be freely modified and distributed
8ff7380d 7.\" %%%LICENSE_END
fea681da
MK
8.\"
9.\" Niki A. Rahimi (LTC Security Development, narahimi@us.ibm.com)
10.\" added ERRORS section.
11.\"
12.\" Modified 2004-06-17 mtk
13.\" Modified 2004-10-07 aeb, added FUTEX_REQUEUE, FUTEX_CMP_REQUEUE
14.\"
47f5c4ba
MK
15.\" FIXME Still to integrate are some points from Torvald Riegel's mail of
16.\" 2015-01-23:
17.\" http://thread.gmane.org/gmane.linux.kernel/1703405/focus=7977
18.\"
02182e7c
MK
19.\" FIXME Do we need add some text regarding Torvald Riegel's 2015-01-24 mail
20.\" at http://thread.gmane.org/gmane.linux.kernel/1703405/focus=1873242
21.\"
3d155313 22.TH FUTEX 2 2014-05-21 "Linux" "Linux Programmer's Manual"
fea681da 23.SH NAME
ce154705 24futex \- fast user-space locking
fea681da 25.SH SYNOPSIS
9d9dc1e8 26.nf
fea681da
MK
27.sp
28.B "#include <linux/futex.h>"
fea681da
MK
29.B "#include <sys/time.h>"
30.sp
d33602c4 31.BI "int futex(int *" uaddr ", int " futex_op ", int " val ,
768d3c23
MK
32.BI " const struct timespec *" timeout , \
33" \fR /* or: \fBu32 \fIval2\fP */
9d9dc1e8 34.BI " int *" uaddr2 ", int " val3 );
9d9dc1e8 35.fi
409f08b0 36
b939d6e4
MK
37.IR Note :
38There is no glibc wrapper for this system call; see NOTES.
47297adb 39.SH DESCRIPTION
fea681da
MK
40.PP
41The
e511ffb6 42.BR futex ()
4b35dc5d 43system call provides a method for waiting until a certain condition becomes
077981d4
MK
44true.
45It is typically used as a blocking construct in the context of
4c8cb0ff 46shared-memory synchronization: The program implements the majority of
594536fb 47the synchronization in user space, and uses one of the operations of
4c8cb0ff
MK
48the system call when it is likely that it has to block for
49a longer time until the condition becomes true.
077981d4 50The program uses another operation of the system call to wake
4b35dc5d
TR
51anyone waiting for a particular condition.
52
4c8cb0ff
MK
53The condition is represented by the futex word, which is an address
54in memory supplied to the
4b35dc5d
TR
55.BR futex ()
56system call, and the value at this memory location.
344df366
HS
57(While the virtual addresses for the same physical memory address
58in separate processes may be different,
59the same physical address may be shared by the processes using
60.BR mmap (2).)
809ca3ae 61
b80daba2
HS
62When executing a
63.BR futex ()
64operation that requests to block a thread,
4c8cb0ff
MK
65the kernel will only block if the futex word has the value that the
66calling thread supplied as expected value.
077981d4
MK
67The load from the futex word, the comparison with
68the expected value,
69and the actual blocking will happen atomically and totally
b80daba2
HS
70ordered with respect to concurrently executing
71.BR futex ()
72operations on the same futex word.
73Thus, the futex word is used to connect the synchronization in user space
4c8cb0ff 74with the implementation of blocking by the kernel; similar to an atomic
4b35dc5d 75compare-and-exchange operation that potentially changes shared memory,
077981d4
MK
76blocking via a futex is an atomic compare-and-block operation.
77See NOTES for
4b35dc5d
TR
78a detailed specification of the synchronization semantics.
79
077981d4
MK
80One example use of futexes is implementing locks.
81The state of the lock (i.e.,
4c8cb0ff
MK
82acquired or not acquired) can be represented as an atomically accessed
83flag in shared memory.
84In the uncontended case,
85a thread can access or modify the lock state with atomic instructions,
86for example atomically changing it from not acquired to acquired
87using an atomic compare-and-exchange instruction.
8e754e12
HS
88A thread maybe unable acquire a lock because
89it is already acquired by another thread.
90It then may pass the lock's flag as futex word and the value
91representing the acquired state as expected value to a
92.BR futex ()
93wait operation.
94.BR futex ()
95will block if and only if the lock is still acquired.
077981d4 96When releasing the lock, a thread has to first reset the
8e754e12
HS
97lock state to not acquired and then execute a
98.BR futex ()
99operation that wakes threads blocked on the lock flag used as futex word.
4c8cb0ff 100(this can be be further optimized to avoid unnecessary wake-ups).
077981d4 101See
4b35dc5d
TR
102.BR futex (7)
103for more detail on how to use futexes.
104
105Besides the basic wait and wake-up futex functionality, there are further
077981d4
MK
106futex operations aimed at supporting more complex use cases.
107Also note that
4c8cb0ff
MK
108no explicit initialization or destruction are necessary to use futexes;
109the kernel maintains a futex
110(i.e., the kernel-internal implementation artifact)
4b35dc5d
TR
111only while operations such as
112.BR FUTEX_WAIT ,
113described below, are being performed on a particular futex word.
a663ca5a
MK
114.\"
115.SS Arguments
fea681da
MK
116The
117.I uaddr
077981d4
MK
118argument points to the futex word.
119On all platforms, futexes are four-byte
4b35dc5d 120integers that must be aligned on a four-byte boundary.
f388ba70
MK
121The operation to perform on the futex is specified in the
122.I futex_op
123argument;
124.IR val
125is a value whose meaning and purpose depends on
126.IR futex_op .
36ab2074
MK
127
128The remaining arguments
129.RI ( timeout ,
130.IR uaddr2 ,
131and
132.IR val3 )
133are required only for certain of the futex operations described below.
134Where one of these arguments is not required, it is ignored.
768d3c23 135
36ab2074
MK
136For several blocking operations, the
137.I timeout
138argument is a pointer to a
139.IR timespec
140structure that specifies a timeout for the operation.
141However, notwithstanding the prototype shown above, for some operations,
142this argument is instead a four-byte integer whose meaning
143is determined by the operation.
768d3c23
MK
144For these operations, the kernel casts the
145.I timeout
146value to
147.IR u32 ,
148and in the remainder of this page, this argument is referred to as
149.I val2
150when interpreted in this fashion.
151
de5a3bb4 152Where it is required, the
36ab2074 153.IR uaddr2
4c8cb0ff
MK
154argument is a pointer to a second futex word that is employed
155by the operation.
36ab2074
MK
156The interpretation of the final integer argument,
157.IR val3 ,
158depends on the operation.
a663ca5a
MK
159.\"
160.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
161.\"
162.SS Futex operations
6be4bad7 163The
d33602c4 164.I futex_op
6be4bad7
MK
165argument consists of two parts:
166a command that specifies the operation to be performed,
167bit-wise ORed with zero or or more options that
168modify the behaviour of the operation.
fc30eb79 169The options that may be included in
d33602c4 170.I futex_op
fc30eb79
TG
171are as follows:
172.TP
173.BR FUTEX_PRIVATE_FLAG " (since Linux 2.6.22)"
174.\" commit 34f01cc1f512fa783302982776895c73714ebbc2
175This option bit can be employed with all futex operations.
e45f9735 176It tells the kernel that the futex is process-private and not shared
4c8cb0ff
MK
177with another process (i.e., it is only being used for synchronization
178between threads of the same process).
fc30eb79
TG
179This allows the kernel to choose the fast path for validating
180the user-space address and avoids expensive VMA lookups,
181taking reference counts on file backing store, and so on.
ae2c1774
MK
182
183As a convenience,
184.IR <linux/futex.h>
185defines a set of constants with the suffix
186.BR _PRIVATE
187that are equivalents of all of the operations listed below,
dcdfde26 188.\" except the obsolete FUTEX_FD, for which the "private" flag was
ae2c1774
MK
189.\" meaningless
190but with the
191.BR FUTEX_PRIVATE_FLAG
192ORed into the constant value.
193Thus, there are
194.BR FUTEX_WAIT_PRIVATE ,
195.BR FUTEX_WAKE_PRIVATE ,
196and so on.
2e98bbc2
TG
197.TP
198.BR FUTEX_CLOCK_REALTIME " (since Linux 2.6.28)"
199.\" commit 1acdac104668a0834cfa267de9946fac7764d486
4a7e5b05 200This option bit can be employed only with the
2e98bbc2
TG
201.BR FUTEX_WAIT_BITSET
202and
203.BR FUTEX_WAIT_REQUEUE_PI
c84cf68c 204operations.
2e98bbc2 205
f2103b26
MK
206If this option is set, the kernel treats
207.I timeout
208as an absolute time based on
2e98bbc2
TG
209.BR CLOCK_REALTIME .
210
f2103b26
MK
211If this option is not set, the kernel treats
212.I timeout
213as relative time,
f1d2171d 214.\" FIXME XXX I added CLOCK_MONOTONIC here. Okay?
1c952cf5
MK
215measured against the
216.BR CLOCK_MONOTONIC
217clock.
6be4bad7
MK
218.PP
219The operation specified in
d33602c4 220.I futex_op
6be4bad7 221is one of the following:
70b06b90
MK
222.\"
223.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
224.\"
fea681da 225.TP
81c9d87e
MK
226.BR FUTEX_WAIT " (since Linux 2.6.0)"
227.\" Strictly speaking, since some time in 2.5.x
f065673c 228This operation tests that the value at the
4b35dc5d 229futex word pointed to by the address
fea681da 230.I uaddr
4b35dc5d 231still contains the expected value
fea681da 232.IR val ,
4b35dc5d 233and if so, then sleeps awaiting
682edefb 234.B FUTEX_WAKE
077981d4
MK
235on the futex word.
236The load of the value of the futex word is an atomic memory
4b35dc5d 237access (i.e., using atomic machine instructions of the respective
077981d4
MK
238architecture).
239This load, the comparison with the expected value, and
4b35dc5d 240starting to sleep are performed atomically and totally ordered with respect
077981d4
MK
241to other futex operations on the same futex word.
242If the thread starts to
4b35dc5d 243sleep, it is considered a waiter on this futex word.
f065673c
MK
244If the futex value does not match
245.IR val ,
4710334a 246then the call fails immediately with the error
badbf70c 247.BR EAGAIN .
4b35dc5d
TR
248
249The purpose of the comparison with the expected value is to prevent lost
250wake-ups: If another thread changed the value of the futex word after the
251calling thread decided to block based on the prior value, and if the other
252thread executed a
253.BR FUTEX_WAKE
254operation (or similar wake-up) after the value change and before this
f065673c 255.BR FUTEX_WAIT
4b35dc5d
TR
256operation, then the latter will observe the value change and will not start
257to sleep.
1909e523 258
c13182ef 259If the
fea681da 260.I timeout
53ba4030 261argument is non-NULL, its contents specify a relative timeout for the wait,
f1d2171d 262.\" FIXME XXX I added CLOCK_MONOTONIC here. Okay?
1c952cf5
MK
263measured according to the
264.BR CLOCK_MONOTONIC
265clock.
82a6092b
MK
266(This interval will be rounded up to the system clock granularity,
267and kernel scheduling delays mean that the
268blocking interval may overrun by a small amount.)
269If
270.I timeout
271is NULL, the call blocks indefinitely.
4798a7f3 272
c13182ef 273The arguments
fea681da
MK
274.I uaddr2
275and
276.I val3
277are ignored.
278
74f58a64
MK
279.\" FIXME(Torvald) I think we should remove this. Or maybe adapt to a
280.\" different example.
4b35dc5d
TR
281.\" For
282.\" .BR futex (7),
283.\" this call is executed if decrementing the count gave a negative value
284.\" (indicating contention),
285.\" and will sleep until another process or thread releases
286.\" the futex and executes the
287.\" .B FUTEX_WAKE
288.\" operation.
70b06b90
MK
289.\"
290.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
291.\"
fea681da 292.TP
81c9d87e
MK
293.BR FUTEX_WAKE " (since Linux 2.6.0)"
294.\" Strictly speaking, since Linux 2.5.x
f065673c
MK
295This operation wakes at most
296.I val
74f58a64
MK
297.\" FIXME(Torvald) I believe FUTEX_WAIT_BITSET waiters, for example,
298.\" could also be woken (therefore, make it e.g. instead of i.e.)?
4b35dc5d 299of the waiters that are waiting (e.g., inside
f065673c 300.BR FUTEX_WAIT )
4b35dc5d 301on the futex word at the address
f065673c
MK
302.IR uaddr .
303Most commonly,
304.I val
305is specified as either 1 (wake up a single waiter) or
306.BR INT_MAX
307(wake up all waiters).
730bfbda
MK
308.\" FIXME Please confirm that the following is correct:
309No guarantee is provided about which waiters are awoken
310(e.g., a waiter with a higher scheduling priority is not guaranteed
311to be awoken in preference to a waiter with a lower priority).
4798a7f3 312
fea681da
MK
313The arguments
314.IR timeout ,
c8b921bd 315.IR uaddr2 ,
fea681da
MK
316and
317.I val3
318are ignored.
319
74f58a64
MK
320.\" FIXME(Torvald) I think we should remove this. Or maybe adapt to
321.\" a different example.
4c8cb0ff
MK
322.\" For
323.\" .BR futex (7),
324.\" this is executed if incrementing the count showed that
325.\" there were waiters,
326.\" once the futex value has been set to 1
327.\" (indicating that it is available).
328.\"
329.\" FIXME How does "incrementing the count show that there were waiters"?
70b06b90
MK
330.\"
331.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
332.\"
a7c2bf45
MK
333.TP
334.BR FUTEX_FD " (from Linux 2.6.0 up to and including Linux 2.6.25)"
335.\" Strictly speaking, from Linux 2.5.x to 2.6.25
4c8cb0ff
MK
336This operation creates a file descriptor that is associated with
337the futex at
a7c2bf45 338.IR uaddr .
bdc5957a
MK
339The caller must close the returned file descriptor after use.
340When another process or thread performs a
a7c2bf45 341.BR FUTEX_WAKE
4b35dc5d 342on the futex word, the file descriptor indicates as being readable with
a7c2bf45
MK
343.BR select (2),
344.BR poll (2),
345and
346.BR epoll (7)
347
f1d2171d 348The file descriptor can be used to obtain asynchronous notifications: if
a7c2bf45 349.I val
bdc5957a 350is nonzero, then when another process or thread executes a
a7c2bf45
MK
351.BR FUTEX_WAKE ,
352the caller will receive the signal number that was passed in
353.IR val .
354
355The arguments
356.IR timeout ,
357.I uaddr2
358and
359.I val3
360are ignored.
361
4c8cb0ff
MK
362.\" FIXME(Torvald) We never define "upped". Maybe just remove the
363.\" following sentence?
a7c2bf45
MK
364To prevent race conditions, the caller should test if the futex has
365been upped after
366.B FUTEX_FD
367returns.
368
369Because it was inherently racy,
370.B FUTEX_FD
371has been removed
372.\" commit 82af7aca56c67061420d618cc5a30f0fd4106b80
373from Linux 2.6.26 onward.
70b06b90
MK
374.\"
375.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
376.\"
a7c2bf45
MK
377.TP
378.BR FUTEX_REQUEUE " (since Linux 2.6.0)"
379.\" Strictly speaking: from Linux 2.5.70
74f58a64
MK
380.\" FIXME(Torvald) Is there some indication that it is broken in general,
381.\" or is this comment implicitly speaking about the condvar (?) use case?
382.\" If the latter we might want to weaken the advice a little.
a7c2bf45 383.IR "Avoid using this operation" .
4b35dc5d 384It is broken for its intended purpose.
a7c2bf45
MK
385Use
386.BR FUTEX_CMP_REQUEUE
387instead.
388
389This operation performs the same task as
390.BR FUTEX_CMP_REQUEUE ,
391except that no check is made using the value in
392.IR val3 .
393(The argument
394.I val3
395is ignored.)
70b06b90
MK
396.\"
397.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
398.\"
a7c2bf45
MK
399.TP
400.BR FUTEX_CMP_REQUEUE " (since Linux 2.6.7)"
4b35dc5d 401This operation first checks whether the location
a7c2bf45
MK
402.I uaddr
403still contains the value
404.IR val3 .
405If not, the operation fails with the error
406.BR EAGAIN .
4b35dc5d 407Otherwise, the operation wakes up a maximum of
a7c2bf45
MK
408.I val
409waiters that are waiting on the futex at
410.IR uaddr .
411If there are more than
412.I val
413waiters, then the remaining waiters are removed
414from the wait queue of the source futex at
415.I uaddr
416and added to the wait queue of the target futex at
417.IR uaddr2 .
418The
768d3c23 419.I val2
936876a9 420argument specifies an upper limit on the number of waiters
a7c2bf45 421that are requeued to the futex at
768d3c23 422.IR uaddr2 .
a7c2bf45 423
74f58a64
MK
424.\" FIXME(Torvald) Is this correct? Or is just the decision which
425.\" threads to wake or requeue part of the atomic operation?
4b35dc5d
TR
426The load from
427.I uaddr
4c8cb0ff
MK
428is an atomic memory access (i.e., using atomic machine instructions of
429the respective architecture).
077981d4 430This load, the comparison with
4b35dc5d 431.IR val3 ,
4c8cb0ff
MK
432and the requeueing of any waiters are performed atomically and totally
433ordered with respect to other operations on the same futex word.
4b35dc5d
TR
434
435This operation was added as a replacement for the earlier
436.BR FUTEX_REQUEUE .
437The difference is that the check of the value at
438.I uaddr
4c8cb0ff
MK
439can be used to ensure that requeueing only happens under certain
440conditions.
4b35dc5d
TR
441Both operations can be used to avoid a "thundering herd" effect when
442.B FUTEX_WAKE
4c8cb0ff
MK
443is used and all of the waiters that are woken need to acquire
444another futex.
4b35dc5d 445
a7c2bf45
MK
446.\" FIXME Please review the following new paragraph to see if it is
447.\" accurate.
448Typical values to specify for
449.I val
450are 0 or or 1.
451(Specifying
452.BR INT_MAX
453is not useful, because it would make the
454.BR FUTEX_CMP_REQUEUE
455operation equivalent to
456.BR FUTEX_WAKE .)
936876a9 457The limit value specified via
768d3c23
MK
458.I val2
459is typically either 1 or
a7c2bf45
MK
460.BR INT_MAX .
461(Specifying the argument as 0 is not useful, because it would make the
462.BR FUTEX_CMP_REQUEUE
463operation equivalent to
464.BR FUTEX_WAIT .)
6bac3b85 465.\"
43d16602
MK
466.\" FIXME Here, it would be helpful to have an example of how
467.\" FUTEX_CMP_REQUEUE might be used, at the same time illustrating
468.\" why FUTEX_WAKE is unsuitable for the same use case.
469.\"
70b06b90
MK
470.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
471.\"
a5956430
MK
472.\" FIXME I added a lengthy piece of text on FUTEX_WAKE_OP text,
473.\" and I'd be happy if someone checked it.
fea681da 474.TP
d67e21f5
MK
475.BR FUTEX_WAKE_OP " (since Linux 2.6.14)"
476.\" commit 4732efbeb997189d9f9b04708dc26bf8613ed721
6bac3b85
MK
477.\" Author: Jakub Jelinek <jakub@redhat.com>
478.\" Date: Tue Sep 6 15:16:25 2005 -0700
4c8cb0ff
MK
479.\" FIXME(Torvald) The glibc condvar implementation is currently being
480.\" revised (e.g., to not use an internal lock anymore).
481.\" It is probably more future-proof to remove this paragraph.
6bac3b85
MK
482This operation was added to support some user-space use cases
483where more than one futex must be handled at the same time.
484The most notable example is the implementation of
485.BR pthread_cond_signal (3),
486which requires operations on two futexes,
487the one used to implement the mutex and the one used in the implementation
488of the wait queue associated with the condition variable.
489.BR FUTEX_WAKE_OP
490allows such cases to be implemented without leading to
491high rates of contention and context switching.
492
493The
494.BR FUTEX_WAIT_OP
4c8cb0ff
MK
495operation is equivalent to execute the following code atomically
496and totally ordered with respect to other futex operations on
497any of the two supplied futex words:
6bac3b85
MK
498
499.in +4n
500.nf
501int oldval = *(int *) uaddr2;
502*(int *) uaddr2 = oldval \fIop\fP \fIoparg\fP;
503futex(uaddr, FUTEX_WAKE, val, 0, 0, 0);
504if (oldval \fIcmp\fP \fIcmparg\fP)
768d3c23 505 futex(uaddr2, FUTEX_WAKE, val2, 0, 0, 0);
6bac3b85
MK
506.fi
507.in
508
509In other words,
510.BR FUTEX_WAIT_OP
511does the following:
512.RS
513.IP * 3
4b35dc5d
TR
514saves the original value of the futex word at
515.IR uaddr2
516and performs an operation to modify the value of the futex at
6bac3b85 517.IR uaddr2 ;
4c8cb0ff
MK
518this is an atomic read-modify-write memory access (i.e., using atomic
519machine instructions of the respective architecture)
6bac3b85
MK
520.IP *
521wakes up a maximum of
522.I val
4b35dc5d 523waiters on the futex for the futex word at
6bac3b85
MK
524.IR uaddr ;
525and
526.IP *
4c8cb0ff
MK
527dependent on the results of a test of the original value of the
528futex word at
6bac3b85
MK
529.IR uaddr2 ,
530wakes up a maximum of
768d3c23 531.I val2
4b35dc5d 532waiters on the futex for the futex word at
6bac3b85
MK
533.IR uaddr2 .
534.RE
535.IP
6bac3b85
MK
536The operation and comparison that are to be performed are encoded
537in the bits of the argument
538.IR val3 .
539Pictorially, the encoding is:
540
f6af90e7 541.in +8n
6bac3b85 542.nf
f6af90e7
MK
543+---+---+-----------+-----------+
544|op |cmp| oparg | cmparg |
545+---+---+-----------+-----------+
546 4 4 12 12 <== # of bits
6bac3b85
MK
547.fi
548.in
549
550Expressed in code, the encoding is:
551
552.in +4n
553.nf
554#define FUTEX_OP(op, oparg, cmp, cmparg) \\
555 (((op & 0xf) << 28) | \\
556 ((cmp & 0xf) << 24) | \\
557 ((oparg & 0xfff) << 12) | \\
558 (cmparg & 0xfff))
559.fi
560.in
561
562In the above,
563.I op
564and
565.I cmp
566are each one of the codes listed below.
567The
568.I oparg
569and
570.I cmparg
571components are literal numeric values, except as noted below.
572
573The
574.I op
575component has one of the following values:
576
577.in +4n
578.nf
579FUTEX_OP_SET 0 /* uaddr2 = oparg; */
580FUTEX_OP_ADD 1 /* uaddr2 += oparg; */
581FUTEX_OP_OR 2 /* uaddr2 |= oparg; */
582FUTEX_OP_ANDN 3 /* uaddr2 &= ~oparg; */
583FUTEX_OP_XOR 4 /* uaddr2 ^= oparg; */
584.fi
585.in
586
587In addition, bit-wise ORing the following value into
588.I op
589causes
590.IR "(1\ <<\ oparg)"
591to be used as the operand:
592
593.in +4n
594.nf
595FUTEX_OP_ARG_SHIFT 8 /* Use (1 << oparg) as operand */
596.fi
597.in
598
599The
600.I cmp
601field is one of the following:
602
603.in +4n
604.nf
605FUTEX_OP_CMP_EQ 0 /* if (oldval == cmparg) wake */
606FUTEX_OP_CMP_NE 1 /* if (oldval != cmparg) wake */
607FUTEX_OP_CMP_LT 2 /* if (oldval < cmparg) wake */
608FUTEX_OP_CMP_LE 3 /* if (oldval <= cmparg) wake */
609FUTEX_OP_CMP_GT 4 /* if (oldval > cmparg) wake */
610FUTEX_OP_CMP_GE 5 /* if (oldval >= cmparg) wake */
611.fi
612.in
613
614The return value of
615.BR FUTEX_WAKE_OP
616is the sum of the number of waiters woken on the futex
617.IR uaddr
618plus the number of waiters woken on the futex
619.IR uaddr2 .
70b06b90
MK
620.\"
621.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
622.\"
d67e21f5 623.TP
79c9b436
TG
624.BR FUTEX_WAIT_BITSET " (since Linux 2.6.25)"
625.\" commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d
fd9e59d4 626This operation is like
79c9b436
TG
627.BR FUTEX_WAIT
628except that
629.I val3
630is used to provide a 32-bit bitset to the kernel.
631This bitset is stored in the kernel-internal state of the waiter.
632See the description of
633.BR FUTEX_WAKE_BITSET
634for further details.
635
fd9e59d4
MK
636The
637.BR FUTEX_WAIT_BITSET
9732dd8b 638operation also interprets the
fd9e59d4
MK
639.I timeout
640argument differently from
641.BR FUTEX_WAIT .
642See the discussion of
643.BR FUTEX_CLOCK_REALTIME ,
644above.
645
79c9b436
TG
646The
647.I uaddr2
648argument is ignored.
70b06b90
MK
649.\"
650.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
651.\"
79c9b436 652.TP
d67e21f5
MK
653.BR FUTEX_WAKE_BITSET " (since Linux 2.6.25)"
654.\" commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d
55cc422d
TG
655This operation is the same as
656.BR FUTEX_WAKE
657except that the
658.I val3
659argument is used to provide a 32-bit bitset to the kernel.
98d769c0
MK
660This bitset is used to select which waiters should be woken up.
661The selection is done by a bit-wise AND of the "wake" bitset
662(i.e., the value in
663.IR val3 )
664and the bitset which is stored in the kernel-internal
09cb4ce7 665state of the waiter (the "wait" bitset that is set using
98d769c0
MK
666.BR FUTEX_WAIT_BITSET ).
667All of the waiters for which the result of the AND is nonzero are woken up;
668the remaining waiters are left sleeping.
669
f1d2171d 670.\" FIXME XXX Is this paragraph that I added okay?
e9d4496b
MK
671The effect of
672.BR FUTEX_WAIT_BITSET
673and
674.BR FUTEX_WAKE_BITSET
9732dd8b
MK
675is to allow selective wake-ups among multiple waiters that are blocked
676on the same futex.
09cb4ce7 677Note, however, that using this bitset multiplexing feature on a
e9d4496b
MK
678futex is less efficient than simply using multiple futexes,
679because employing bitset multiplexing requires the kernel
680to check all waiters on a futex,
681including those that are not interested in being woken up
682(i.e., they do not have the relevant bit set in their "wait" bitset).
683.\" According to http://locklessinc.com/articles/futex_cheat_sheet/:
684.\"
685.\" "The original reason for the addition of these extensions
686.\" was to improve the performance of pthread read-write locks
687.\" in glibc. However, the pthreads library no longer uses the
688.\" same locking algorithm, and these extensions are not used
689.\" without the bitset parameter being all ones.
690.\"
691.\" The page goes on to note that the FUTEX_WAIT_BITSET operation
692.\" is nevertheless used (with a bitset of all ones) in order to
693.\" obtain the absolute timeout functionality that is useful
694.\" for efficiently implementing Pthreads APIs (which use absolute
695.\" timeouts); FUTEX_WAIT provides only relative timeouts.
696
98d769c0
MK
697The
698.I uaddr2
699and
700.I timeout
701arguments are ignored.
9732dd8b
MK
702
703The
704.BR FUTEX_WAIT
705and
706.BR FUTEX_WAKE
707operations correspond to
708.BR FUTEX_WAIT_BITSET
709and
710.BR FUTEX_WAKE_BITSET
711operations where the bitsets are all ones.
bd90a5f9 712.\"
70b06b90 713.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
bd90a5f9
MK
714.\"
715.SS Priority-inheritance futexes
b52e1cd4
MK
716Linux supports priority-inheritance (PI) futexes in order to handle
717priority-inversion problems that can be encountered with
718normal futex locks.
b565548b 719Priority inversion is the problem that occurs when a high-priority
bdc5957a
MK
720task is blocked waiting to acquire a lock held by a low-priority task,
721while tasks at an intermediate priority continuously preempt
722the low-priority task from the CPU.
723Consequently, the low-priority task makes no progress toward
724releasing the lock, and the high-priority task remains blocked.
7f315ae3 725
7d20efd7
MK
726Priority inheritance is a mechanism for dealing with
727the priority-inversion problem.
bdc5957a
MK
728With this mechanism, when a high-priority task becomes blocked
729by a lock held by a low-priority task,
7d20efd7 730the latter's priority is temporarily raised to that of the former,
bdc5957a 731so that it is not preempted by any intermediate level tasks,
7d20efd7
MK
732and can thus make progress toward releasing the lock.
733To be effective, priority inheritance must be transitive,
bdc5957a
MK
734meaning that if a high-priority task blocks on a lock
735held by a lower-priority task that is itself blocked by lock
736held by another intermediate-priority task
7d20efd7 737(and so on, for chains of arbitrary length),
bdc5957a
MK
738then both of those task
739(or more generally, all of the tasks in a lock chain)
740have their priorities raised to be the same as the high-priority task.
7d20efd7 741
9e2b90ee
MK
742.\" FIXME XXX The following is my attempt at a definition of PI futexes,
743.\" based on mail discussions with Darren Hart. Does it seem okay?
744From a user-space perspective,
745what makes a futex PI-aware is a policy agreement between user space
4b35dc5d 746and the kernel about the value of the futex word (described in a moment),
9e2b90ee
MK
747coupled with the use of the PI futex operations described below
748(in particular,
749.BR FUTEX_LOCK_PI ,
750.BR FUTEX_TRYLOCK_PI ,
751and
752.BR FUTEX_CMP_REQUEUE_PI ).
753.\" Quoting Darren Hart:
754.\" These opcodes paired with the PI futex value policy (described below)
755.\" defines a "futex" as PI aware. These were created very specifically
756.\" in support of PI pthread_mutexes, so it makes a lot more sense to
757.\" talk about a PI aware pthread_mutex, than a PI aware futex, since
758.\" there is a lot of policy and scaffolding that has to be built up
759.\" around it to use it properly (this is what a PI pthread_mutex is).
760
f1d2171d 761.\" FIXME XXX ===== Start of adapted Hart/Guniguntala text =====
1af427a4
MK
762.\" The following text is drawn from the Hart/Guniguntala paper
763.\" (listed in SEE ALSO), but I have reworded some pieces
764.\" significantly. Please check it.
79d918c7
MK
765.\"
766The PI futex operations described below differ from the other
4b35dc5d
TR
767futex operations in that they impose policy on the use of the value of the
768futex word:
79d918c7 769.IP * 3
4b35dc5d 770If the lock is not acquired, the futex word's value shall be 0.
79d918c7 771.IP *
4c8cb0ff
MK
772If the lock is acquired, the futex word's value shall
773be the thread ID (TID;
4b35dc5d 774see
79d918c7
MK
775.BR gettid (2))
776of the owning thread.
777.IP *
f1d2171d 778.\" FIXME XXX In the following line, I added "the lock is owned and". Okay?
79d918c7
MK
779If the lock is owned and there are threads contending for the lock,
780then the
781.B FUTEX_WAITERS
4b35dc5d 782bit shall be set in the futex word's value; in other words, this value is:
79d918c7
MK
783
784 FUTEX_WAITERS | TID
9e2b90ee 785
79d918c7 786.PP
4b35dc5d 787Note that a PI futex word never just has the value
9e2b90ee
MK
788.BR FUTEX_WAITERS ,
789which is a permissible state for non-PI futexes.
790
79d918c7 791With this policy in place,
4b35dc5d
TR
792a user-space application can acquire a not-acquired
793lock or release a lock that no other threads try to acquire using atomic
4c8cb0ff
MK
794instructions executed in user space (e.g., a compare-and-swap operation
795such as
b52e1cd4
MK
796.I cmpxchg
797on the x86 architecture).
4c8cb0ff
MK
798Acquiring a lock simply consists of using compare-and-swap to atomically
799set the futex word's value to the caller's TID if its previous value was 0.
4b35dc5d
TR
800Releasing a lock requires using compare-and-swap to set the futex word's
801value to 0 if the previous value was the expected TID.
b52e1cd4 802
4b35dc5d 803If a futex is already acquired (i.e., has a nonzero value),
b52e1cd4 804waiters must employ the
79d918c7
MK
805.B FUTEX_LOCK_PI
806operation to acquire the lock.
4b35dc5d 807If other threads are waiting for the lock, then the
79d918c7 808.B FUTEX_WAITERS
4c8cb0ff
MK
809bit is set in the futex value;
810in this case, the lock owner must employ the
79d918c7 811.B FUTEX_UNLOCK_PI
b52e1cd4
MK
812operation to release the lock.
813
79d918c7
MK
814In the cases where callers are forced into the kernel
815(i.e., required to perform a
816.BR futex ()
817operation),
818they then deal directly with a so-called RT-mutex,
819a kernel locking mechanism which implements the required
820priority-inheritance semantics.
821After the RT-mutex is acquired, the futex value is updated accordingly,
822before the calling thread returns to user space.
823.\" FIXME ===== End of adapted Hart/Guniguntala text =====
824
a59fca75
MK
825It is important to note
826.\" FIXME We need some explanation here of *why* it is important to
1af427a4 827.\" note this. Can someone explain?
4b35dc5d 828that the kernel will update the futex word's value prior
79d918c7
MK
829to returning to user space.
830Unlike the other futex operations described above,
831the PI futex operations are designed
d9d5be6b 832for the implementation of very specific IPC mechanisms.
fc57e6bb 833.\"
7bd3ffbc 834.\" FIXME XXX In discussing errors for FUTEX_CMP_REQUEUE_PI, Darren Hart
99c0ac69
MK
835.\" made the observation that "EINVAL is returned if the non-pi
836.\" to pi or op pairing semantics are violated."
837.\" Probably there needs to be a general statement about this
838.\" requirement, probably located at about this point in the page.
7bd3ffbc 839.\" Darren, care to take a shot at this?
dd003bef
MK
840.\"
841.\" FIXME Somewhere on this page (I guess under the discussion of PI
842.\" futexes) we need a discussion of the FUTEX_OWNER_DIED bit.
843.\" Can someone propose a text?
bd90a5f9
MK
844
845PI futexes are operated on by specifying one of the following values in
846.IR futex_op :
70b06b90
MK
847.\"
848.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
849.\"
d67e21f5
MK
850.TP
851.BR FUTEX_LOCK_PI " (since Linux 2.6.18)"
852.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
67833bec
MK
853.\"
854.\" FIXME I did some significant rewording of tglx's text.
855.\" Please check, in case I injected errors.
856.\"
857This operation is used after after an attempt to acquire
4b35dc5d
TR
858the lock via an atomic user-space instruction failed
859because the futex word has a nonzero value\(emspecifically,
67833bec 860because it contained the namespace-specific TID of the lock owner.
67259526 861.\" FIXME In the preceding line, what does "namespace-specific" mean?
67833bec 862.\" (I kept those words from tglx.)
67259526 863.\" That is, what kind of namespace are we talking about?
67833bec
MK
864.\" (I suppose we are talking PID namespaces here, but I want to
865.\" be sure.)
866
4b35dc5d 867The operation checks the value of the futex word at the address
67833bec 868.IR uaddr .
70b06b90
MK
869If the value is 0, then the kernel tries to atomically set
870the futex value to the caller's TID.
67833bec
MK
871If that fails,
872.\" FIXME What would be the cause of failure?
4b35dc5d 873or the futex word's value is nonzero,
67833bec 874the kernel atomically sets the
e0547e70 875.B FUTEX_WAITERS
67833bec
MK
876bit, which signals the futex owner that it cannot unlock the futex in
877user space atomically by setting the futex value to 0.
878After that, the kernel tries to find the thread which is
879associated with the owner TID,
880.\" FIXME Could I get a bit more detail on the next two lines?
881.\" What is "creates or reuses kernel state" about?
882creates or reuses kernel state on behalf of the owner
883and attaches the waiter to it.
67259526
MK
884.\" FIXME In the next line, what type of "priority" are we talking about?
885.\" Realtime priorities for SCHED_FIFO and SCHED_RR?
886.\" Or something else?
1f043693 887The enqueueing of the waiter is in descending priority order if more
e0547e70 888than one waiter exists.
67259526 889.\" FIXME What does "bandwidth" refer to in the next line?
e0547e70 890The owner inherits either the priority or the bandwidth of the waiter.
67259526
MK
891.\" FIXME In the preceding line, what determines whether the
892.\" owner inherits the priority versus the bandwidth?
67833bec
MK
893.\"
894.\" FIXME Could I get some help translating the next sentence into
895.\" something that user-space developers (and I) can understand?
70b06b90 896.\" In particular, what are "nested locks" in this context?
e0547e70
TG
897This inheritance follows the lock chain in the case of
898nested locking and performs deadlock detection.
899
9ce19cf1
MK
900.\" FIXME tglx says "The timeout argument is handled as described in
901.\" FUTEX_WAIT." However, it appears to me that this is not right.
70b06b90 902.\" Is the following formulation correct?
e0547e70
TG
903The
904.I timeout
9ce19cf1
MK
905argument provides a timeout for the lock attempt.
906It is interpreted as an absolute time, measured against the
907.BR CLOCK_REALTIME
908clock.
909If
910.I timeout
911is NULL, the operation will block indefinitely.
e0547e70 912
a449c634 913The
e0547e70
TG
914.IR uaddr2 ,
915.IR val ,
916and
917.IR val3
a449c634 918arguments are ignored.
67833bec 919.\"
70b06b90
MK
920.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
921.\"
d67e21f5 922.TP
12fdbe23 923.BR FUTEX_TRYLOCK_PI " (since Linux 2.6.18)"
d67e21f5 924.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
12fdbe23
MK
925This operation tries to acquire the futex at
926.IR uaddr .
0b761826 927.\" FIXME I think it would be helpful here to say a few more words about
70b06b90
MK
928.\" the difference(s) between FUTEX_LOCK_PI and FUTEX_TRYLOCK_PI.
929.\" Can someone propose something?
930.\"
74f58a64
MK
931.\" FIXME(Torvald) Additionally, we claim above that just FUTEX_WAITERS
932.\" is never an allowed state.
fa0388c3 933It deals with the situation where the TID value at
12fdbe23
MK
934.I uaddr
935is 0, but the
b52e1cd4 936.B FUTEX_WAITERS
12fdbe23 937bit is set.
fa0388c3
MK
938.\" FIXME How does the situation in the previous sentence come about?
939.\" Probably it would be helpful to say something about that in
940.\" the man page.
badbf70c 941.\" FIXME And *how* does FUTEX_TRYLOCK_PI deal with this situation?
a282e5b0 942User space cannot handle this condition in a race-free manner
084744ef
MK
943
944The
945.IR uaddr2 ,
946.IR val ,
947.IR timeout ,
948and
949.IR val3
950arguments are ignored.
70b06b90
MK
951.\"
952.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
953.\"
d67e21f5 954.TP
12fdbe23 955.BR FUTEX_UNLOCK_PI " (since Linux 2.6.18)"
d67e21f5 956.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
d4ba4328 957This operation wakes the top priority waiter that is waiting in
ecae2099
TG
958.B FUTEX_LOCK_PI
959on the futex address provided by the
960.I uaddr
961argument.
962
963This is called when the user space value at
964.I uaddr
965cannot be changed atomically from a TID (of the owner) to 0.
966
967The
968.IR uaddr2 ,
969.IR val ,
970.IR timeout ,
971and
972.IR val3
11a194bf 973arguments are ignored.
70b06b90
MK
974.\"
975.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
976.\"
d67e21f5 977.TP
d67e21f5
MK
978.BR FUTEX_CMP_REQUEUE_PI " (since Linux 2.6.31)"
979.\" commit 52400ba946759af28442dee6265c5c0180ac7122
f812a08b
DH
980This operation is a PI-aware variant of
981.BR FUTEX_CMP_REQUEUE .
982It requeues waiters that are blocked via
983.B FUTEX_WAIT_REQUEUE_PI
984on
985.I uaddr
986from a non-PI source futex
987.RI ( uaddr )
988to a PI target futex
989.RI ( uaddr2 ).
990
9e54d26d
MK
991As with
992.BR FUTEX_CMP_REQUEUE ,
993this operation wakes up a maximum of
994.I val
995waiters that are waiting on the futex at
996.IR uaddr .
997However, for
998.BR FUTEX_CMP_REQUEUE_PI ,
999.I val
6fbeb8f4 1000is required to be 1
939ca89f 1001(since the main point is to avoid a thundering herd).
9e54d26d
MK
1002The remaining waiters are removed from the wait queue of the source futex at
1003.I uaddr
1004and added to the wait queue of the target futex at
1005.IR uaddr2 .
f812a08b 1006
9e54d26d 1007The
768d3c23 1008.I val2
c6d8cf21
MK
1009.\" val2 is the cap on the number of requeued waiters.
1010.\" In the glibc pthread_cond_broadcast() implementation, this argument
1011.\" is specified as INT_MAX, and for pthread_cond_signal() it is 0.
9e54d26d 1012and
768d3c23 1013.I val3
9e54d26d
MK
1014arguments serve the same purposes as for
1015.BR FUTEX_CMP_REQUEUE .
70b06b90 1016.\"
be376673
MK
1017.\" FIXME The page at http://locklessinc.com/articles/futex_cheat_sheet/
1018.\" notes that "priority-inheritance Futex to priority-inheritance
1019.\" Futex requeues are currently unsupported". Do we need to say
1020.\" something in the man page about that?
70b06b90
MK
1021.\"
1022.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1023.\"
d67e21f5
MK
1024.TP
1025.BR FUTEX_WAIT_REQUEUE_PI " (since Linux 2.6.31)"
1026.\" commit 52400ba946759af28442dee6265c5c0180ac7122
70b06b90
MK
1027.\"
1028.\" FIXME I find the next sentence (from tglx) pretty hard to grok.
1af427a4 1029.\" Could someone explain it a bit more?
6ff1b4c0
TG
1030Wait operation to wait on a non-PI futex at
1031.I uaddr
1032and potentially be requeued onto a PI futex at
1033.IR uaddr2 .
1034The wait operation on
1035.I uaddr
1036is the same as
1037.BR FUTEX_WAIT .
70b06b90 1038.\"
f1d2171d
MK
1039.\" FIXME I'm not quite clear on the meaning of the following sentence.
1040.\" Is this trying to say that while blocked in a
1041.\" FUTEX_WAIT_REQUEUE_PI, it could happen that another
1042.\" task does a FUTEX_WAKE on uaddr that simply causes
1043.\" a normal wake, with the result that the FUTEX_WAIT_REQUEUE_PI
1044.\" does not complete? What happens then to the FUTEX_WAIT_REQUEUE_PI
1045.\" opertion? Does it remain blocked, or does it unblock
1046.\" In which case, what does user space see?
6ff1b4c0
TG
1047The waiter can be removed from the wait on
1048.I uaddr
1049via
1050.BR FUTEX_WAKE
1051without requeueing on
1052.IR uaddr2 .
a4e69912 1053
63bea7dc
MK
1054.\" FIXME Please check the following. tglx said "The timeout argument
1055.\" is handled as described in FUTEX_WAIT.", but the truth is
1056.\" as below, AFAICS
1057If
1058.I timeout
1059is not NULL, it specifies a timeout for the wait operation;
1060this timeout is interpreted as outlined above in the description of the
1061.BR FUTEX_CLOCK_REALTIME
1062option.
1063If
1064.I timeout
1065is NULL, the operation can block indefinitely.
1066
a4e69912
MK
1067The
1068.I val3
1069argument is ignored.
70b06b90 1070.\" FIXME Re the preceding sentence... Actually 'val3' is internally set to
a4e69912
MK
1071.\" FUTEX_BITSET_MATCH_ANY before calling futex_wait_requeue_pi().
1072.\" I'm not sure we need to say anything about this though.
1073.\" Comments?
abb571e8
MK
1074
1075The
1076.BR FUTEX_WAIT_REQUEUE_PI
1077and
1078.BR FUTEX_CMP_REQUEUE_PI
1079were added to support a fairly specific use case:
1080support for priority-inheritance-aware POSIX threads condition variables.
1081The idea is that these operations should always be paired,
1082in order to ensure that user space and the kernel remain in sync.
1083Thus, in the
1084.BR FUTEX_WAIT_REQUEUE_PI
1085operation, the user-space application pre-specifies the target
1086of the requeue that takes place in the
1087.BR FUTEX_CMP_REQUEUE_PI
1088operation.
1089.\"
1090.\" Darren Hart notes that a patch to allow glibc to fully support
1af427a4 1091.\" PI-aware pthreads condition variables has not yet been accepted into
abb571e8
MK
1092.\" glibc. The story is complex, and can be found at
1093.\" https://sourceware.org/bugzilla/show_bug.cgi?id=11588
1094.\" Darren notes that in the meantime, the patch is shipped with various
1af427a4 1095.\" PREEMPT_RT-enabled Linux systems.
abb571e8
MK
1096.\"
1097.\" Related to the preceding, Darren proposed that somewhere, man-pages
1098.\" should document the following point:
1af427a4 1099.\"
4c8cb0ff
MK
1100.\" While the Linux kernel, since 2.6.31, supports requeueing of
1101.\" priority-inheritance (PI) aware mutexes via the
1102.\" FUTEX_WAIT_REQUEUE_PI and FUTEX_CMP_REQUEUE_PI futex operations,
1103.\" the glibc implementation does not yet take full advantage of this.
1104.\" Specifically, the condvar internal data lock remains a non-PI aware
1105.\" mutex, regardless of the type of the pthread_mutex associated with
1106.\" the condvar. This can lead to an unbounded priority inversion on
1107.\" the internal data lock even when associating a PI aware
1108.\" pthread_mutex with a condvar during a pthread_cond*_wait
1109.\" operation. For this reason, it is not recommended to rely on
1110.\" priority inheritance when using pthread condition variables.
1af427a4
MK
1111.\"
1112.\" The problem is that the obvious location for this text is
1113.\" the pthread_cond*wait(3) man page. However, such a man page
abb571e8 1114.\" does not currently exist.
70b06b90 1115.\"
6700de24 1116.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
70b06b90 1117.\"
47297adb 1118.SH RETURN VALUE
fea681da 1119.PP
6f147f79 1120In the event of an error, all operations return \-1 and set
e808bba0 1121.I errno
6f147f79 1122to indicate the cause of the error.
e808bba0
MK
1123The return value on success depends on the operation,
1124as described in the following list:
fea681da
MK
1125.TP
1126.B FUTEX_WAIT
077981d4 1127Returns 0 if the caller was woken up.
4c8cb0ff
MK
1128Note that a wake-up can also be caused by common futex usage patterns
1129in unrelated code that happened to have previously used the futex word's
1130memory location (e.g., typical futex-based implementations of
1131Pthreads mutexes can cause this under some conditions).
1132Therefore, callers should always conservatively assume that a return
1133value of 0 can mean a spurious wake-up, and use the futex word's value
1134(i.e., the user space synchronization scheme)
1135 to decide whether to continue to block or not.
fea681da
MK
1136.TP
1137.B FUTEX_WAKE
bdc5957a 1138Returns the number of waiters that were woken up.
fea681da
MK
1139.TP
1140.B FUTEX_FD
1141Returns the new file descriptor associated with the futex.
1142.TP
1143.B FUTEX_REQUEUE
bdc5957a 1144Returns the number of waiters that were woken up.
fea681da
MK
1145.TP
1146.B FUTEX_CMP_REQUEUE
bdc5957a 1147Returns the total number of waiters that were woken up or
4b35dc5d 1148requeued to the futex for the futex word at
3dfcc11d
MK
1149.IR uaddr2 .
1150If this value is greater than
1151.IR val ,
4c8cb0ff
MK
1152then difference is the number of waiters requeued to the futex for the
1153futex word at
3dfcc11d 1154.IR uaddr2 .
dcad19c0
MK
1155.TP
1156.B FUTEX_WAKE_OP
a8b5b324 1157Returns the total number of waiters that were woken up.
4c8cb0ff
MK
1158This is the sum of the woken waiters on the two futexes for
1159the futex words at
a8b5b324
MK
1160.I uaddr
1161and
1162.IR uaddr2 .
dcad19c0
MK
1163.TP
1164.B FUTEX_WAIT_BITSET
077981d4
MK
1165Returns 0 if the caller was woken up.
1166See
4b35dc5d
TR
1167.B FUTEX_WAIT
1168for how to interpret this correctly in practice.
dcad19c0
MK
1169.TP
1170.B FUTEX_WAKE_BITSET
bdc5957a 1171Returns the number of waiters that were woken up.
dcad19c0
MK
1172.TP
1173.B FUTEX_LOCK_PI
bf02a260 1174Returns 0 if the futex was successfully locked.
dcad19c0
MK
1175.TP
1176.B FUTEX_TRYLOCK_PI
5c716eef 1177Returns 0 if the futex was successfully locked.
dcad19c0
MK
1178.TP
1179.B FUTEX_UNLOCK_PI
52bb928f 1180Returns 0 if the futex was successfully unlocked.
dcad19c0
MK
1181.TP
1182.B FUTEX_CMP_REQUEUE_PI
bdc5957a 1183Returns the total number of waiters that were woken up or
4b35dc5d 1184requeued to the futex for the futex word at
dddd395a
MK
1185.IR uaddr2 .
1186If this value is greater than
1187.IR val ,
4c8cb0ff
MK
1188then difference is the number of waiters requeued to the futex for
1189the futex word at
dddd395a 1190.IR uaddr2 .
dcad19c0
MK
1191.TP
1192.B FUTEX_WAIT_REQUEUE_PI
4c8cb0ff
MK
1193Returns 0 if the caller was successfully requeued to the futex for
1194the futex word at
22c15de9 1195.IR uaddr2 .
70b06b90
MK
1196.\"
1197.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1198.\"
fea681da
MK
1199.SH ERRORS
1200.TP
1201.B EACCES
4b35dc5d 1202No read access to the memory of a futex word.
fea681da
MK
1203.TP
1204.B EAGAIN
f48516d1 1205.RB ( FUTEX_WAIT ,
4b35dc5d 1206.BR FUTEX_WAIT_BITSET ,
f48516d1 1207.BR FUTEX_WAIT_REQUEUE_PI )
badbf70c
MK
1208The value pointed to by
1209.I uaddr
1210was not equal to the expected value
1211.I val
1212at the time of the call.
9732dd8b
MK
1213
1214.BR Note :
1215on Linux, the symbolic names
1216.B EAGAIN
1217and
1218.B EWOULDBLOCK
77da5feb 1219(both of which appear in different parts of the kernel futex code)
9732dd8b 1220have the same value.
badbf70c
MK
1221.TP
1222.B EAGAIN
8f2068bb
MK
1223.RB ( FUTEX_CMP_REQUEUE ,
1224.BR FUTEX_CMP_REQUEUE_PI )
ce5602fd 1225The value pointed to by
9f6c40c0
МК
1226.I uaddr
1227is not equal to the expected value
1228.IR val3 .
fd1dc4c2 1229.\" FIXME: Is the following sentence correct?
4b35dc5d 1230.\" I would prefer to remove this sentence. --triegel@redhat.com
fea681da 1231(This probably indicates a race;
682edefb
MK
1232use the safe
1233.B FUTEX_WAKE
1234now.)
c0091dd3 1235.\"
f1d2171d 1236.\" FIXME XXX Should there be an EAGAIN case for FUTEX_TRYLOCK_PI?
c0091dd3
MK
1237.\" It seems so, looking at the handling of the rt_mutex_trylock()
1238.\" call in futex_lock_pi()
9732dd8b 1239.\" (Davidlohr also thinks so.)
c0091dd3 1240.\"
fea681da 1241.TP
5662f56a
MK
1242.BR EAGAIN
1243.RB ( FUTEX_LOCK_PI ,
aaec9032
MK
1244.BR FUTEX_TRYLOCK_PI ,
1245.BR FUTEX_CMP_REQUEUE_PI )
1246The futex owner thread ID of
1247.I uaddr
1248(for
1249.BR FUTEX_CMP_REQUEUE_PI :
1250.IR uaddr2 )
1251is about to exit,
5662f56a
MK
1252but has not yet handled the internal state cleanup.
1253Try again.
1254.TP
7a39e745
MK
1255.BR EDEADLK
1256.RB ( FUTEX_LOCK_PI ,
9732dd8b
MK
1257.BR FUTEX_TRYLOCK_PI ,
1258.BR FUTEX_CMP_REQUEUE_PI )
4b35dc5d 1259The futex word at
7a39e745
MK
1260.I uaddr
1261is already locked by the caller.
1262.TP
662c0da8
MK
1263.BR EDEADLK
1264.\" FIXME I reworded tglx's text somewhat; is the following okay?
4c8cb0ff
MK
1265.\" FIXME XXX I see that kernel/locking/rtmutex.c uses EDEADLK in some
1266.\" iplaces, and EDEADLOCK in others. On almost all architectures
1267.\" these constants are synonymous. Is there a reason that both
1268.\" names are used?
662c0da8 1269.RB ( FUTEX_CMP_REQUEUE_PI )
4b35dc5d 1270While requeueing a waiter to the PI futex for the futex word at
662c0da8
MK
1271.IR uaddr2 ,
1272the kernel detected a deadlock.
1273.TP
fea681da 1274.B EFAULT
1ea901e8
MK
1275A required pointer argument (i.e.,
1276.IR uaddr ,
1277.IR uaddr2 ,
1278or
1279.IR timeout )
496df304 1280did not point to a valid user-space address.
fea681da 1281.TP
9f6c40c0 1282.B EINTR
e808bba0 1283A
9f6c40c0 1284.B FUTEX_WAIT
2674f781
MK
1285or
1286.B FUTEX_WAIT_BITSET
e808bba0 1287operation was interrupted by a signal (see
f529fd20
MK
1288.BR signal (7)).
1289In kernels before Linux 2.6.22, this error could also be returned for
1290on a spurious wakeup; since Linux 2.6.22, this no longer happens.
9f6c40c0 1291.TP
fea681da 1292.B EINVAL
180f97b7
MK
1293The operation in
1294.IR futex_op
1295is one of those that employs a timeout, but the supplied
fb2f4c27
MK
1296.I timeout
1297argument was invalid
1298.RI ( tv_sec
1299was less than zero, or
1300.IR tv_nsec
1301was not less than 1000,000,000).
1302.TP
1303.B EINVAL
0c74df0b 1304The operation specified in
025e1374 1305.IR futex_op
0c74df0b 1306employs one or both of the pointers
51ee94be 1307.I uaddr
a1f47699 1308and
0c74df0b
MK
1309.IR uaddr2 ,
1310but one of these does not point to a valid object\(emthat is,
1311the address is not four-byte-aligned.
51ee94be
MK
1312.TP
1313.B EINVAL
55cc422d
TG
1314.RB ( FUTEX_WAIT_BITSET ,
1315.BR FUTEX_WAKE_BITSET )
79c9b436
TG
1316The bitset supplied in
1317.IR val3
1318is zero.
1319.TP
1320.B EINVAL
2abcba67 1321.RB ( FUTEX_CMP_REQUEUE_PI )
add875c0
MK
1322.I uaddr
1323equals
1324.IR uaddr2
1325(i.e., an attempt was made to requeue to the same futex).
1326.TP
ff597681
MK
1327.BR EINVAL
1328.RB ( FUTEX_FD )
1329The signal number supplied in
1330.I val
1331is invalid.
1332.TP
6bac3b85 1333.B EINVAL
476debd7
MK
1334.RB ( FUTEX_WAKE ,
1335.BR FUTEX_WAKE_OP ,
1336.BR FUTEX_WAKE_BITSET ,
1337.BR FUTEX_REQUEUE ,
1338.BR FUTEX_CMP_REQUEUE )
1339The kernel detected an inconsistency between the user-space state at
1340.I uaddr
1341and the kernel state\(emthat is, it detected a waiter which waits in
1342.BR FUTEX_LOCK_PI
1343on
1344.IR uaddr .
1345.TP
1346.B EINVAL
a218ef20 1347.RB ( FUTEX_LOCK_PI ,
ce022f18
MK
1348.BR FUTEX_TRYLOCK_PI ,
1349.BR FUTEX_UNLOCK_PI )
a218ef20
MK
1350The kernel detected an inconsistency between the user-space state at
1351.I uaddr
1352and the kernel state.
ce022f18
MK
1353This indicates either state corruption
1354.\" FIXME tglx did not mention the "state corruption" for FUTEX_UNLOCK_PI.
1355.\" Does that case also apply for FUTEX_UNLOCK_PI?
1356or that the kernel found a waiter on
a218ef20
MK
1357.I uaddr
1358which is waiting via
1359.BR FUTEX_WAIT
1360or
1361.BR FUTEX_WAIT_BITSET .
1362.TP
1363.B EINVAL
f9250b1a
MK
1364.RB ( FUTEX_CMP_REQUEUE_PI )
1365The kernel detected an inconsistency between the user-space state at
99c0041d
MK
1366.I uaddr2
1367and the kernel state;
1368that is, the kernel detected a waiter which waits via
1369.BR FUTEX_WAIT
1370.\" FIXME tglx did not mention FUTEX_WAIT_BITSET here,
1371.\" but should that not also be included here?
1372on
1373.IR uaddr2 .
1374.TP
1375.B EINVAL
1376.RB ( FUTEX_CMP_REQUEUE_PI )
1377The kernel detected an inconsistency between the user-space state at
f9250b1a
MK
1378.I uaddr
1379and the kernel state;
1380that is, the kernel detected a waiter which waits via
75299c8d 1381.BR FUTEX_WAIT
99c0041d 1382or
75299c8d 1383.BR FUTEX_WAIT_BITESET
f9250b1a
MK
1384on
1385.IR uaddr .
1386.TP
1387.B EINVAL
99c0041d 1388.RB ( FUTEX_CMP_REQUEUE_PI )
75299c8d
MK
1389The kernel detected an inconsistency between the user-space state at
1390.I uaddr
1391and the kernel state;
1392that is, the kernel detected a waiter which waits on
1393.I uaddr
1394via
1395.BR FUTEX_LOCK_PI
1396(instead of
1397.BR FUTEX_WAIT_REQUEUE_PI ).
99c0041d
MK
1398.TP
1399.B EINVAL
9786b3ca 1400.RB ( FUTEX_CMP_REQUEUE_PI )
f1d2171d 1401.\" FIXME XXX The following is a reworded version of Darren Hart's text.
9786b3ca
MK
1402.\" Please check that I did not introduce any errors.
1403An attempt was made to requeue a waiter to a futex other than that
1404specified by the matching
1405.B FUTEX_WAIT_REQUEUE_PI
1406call for that waiter.
1407.TP
1408.B EINVAL
f0c0d61c
MK
1409.RB ( FUTEX_CMP_REQUEUE_PI )
1410The
1411.I val
1412argument is not 1.
1413.TP
1414.B EINVAL
4832b48a 1415Invalid argument.
fea681da 1416.TP
a449c634
MK
1417.BR ENOMEM
1418.RB ( FUTEX_LOCK_PI ,
e34a8fb6
MK
1419.BR FUTEX_TRYLOCK_PI ,
1420.BR FUTEX_CMP_REQUEUE_PI )
a449c634
MK
1421The kernel could not allocate memory to hold state information.
1422.TP
fea681da 1423.B ENFILE
ff597681 1424.RB ( FUTEX_FD )
fea681da 1425The system limit on the total number of open files has been reached.
4701fc28
MK
1426.TP
1427.B ENOSYS
1428Invalid operation specified in
d33602c4 1429.IR futex_op .
9f6c40c0 1430.TP
4a7e5b05
MK
1431.B ENOSYS
1432The
1433.BR FUTEX_CLOCK_REALTIME
1434option was specified in
1afcee7c 1435.IR futex_op ,
4a7e5b05
MK
1436but the accompanying operation was neither
1437.BR FUTEX_WAIT_BITSET
1438nor
1439.BR FUTEX_WAIT_REQUEUE_PI .
1440.TP
a9dcb4d1
MK
1441.BR ENOSYS
1442.RB ( FUTEX_LOCK_PI ,
f2424fae 1443.BR FUTEX_TRYLOCK_PI ,
4945ff19 1444.BR FUTEX_UNLOCK_PI ,
4cf92894 1445.BR FUTEX_CMP_REQUEUE_PI ,
794bb106 1446.BR FUTEX_WAIT_REQUEUE_PI )
4b35dc5d 1447A run-time check determined that the operation is not available.
a2ebebcd 1448The PI futex operations are not implemented on all architectures and
077981d4 1449are not supported on some CPU variants.
a9dcb4d1 1450.TP
c7589177
MK
1451.BR EPERM
1452.RB ( FUTEX_LOCK_PI ,
dc2742a8
MK
1453.BR FUTEX_TRYLOCK_PI ,
1454.BR FUTEX_CMP_REQUEUE_PI )
04331c3f 1455The caller is not allowed to attach itself to the futex at
dc2742a8
MK
1456.I uaddr
1457(for
1458.BR FUTEX_CMP_REQUEUE_PI :
1459the futex at
1460.IR uaddr2 ).
c7589177
MK
1461(This may be caused by a state corruption in user space.)
1462.TP
76f347ba 1463.BR EPERM
87276709 1464.RB ( FUTEX_UNLOCK_PI )
4b35dc5d 1465The caller does not own the lock represented by the futex word.
76f347ba 1466.TP
0b0e4934
MK
1467.BR ESRCH
1468.RB ( FUTEX_LOCK_PI ,
9732dd8b
MK
1469.BR FUTEX_TRYLOCK_PI ,
1470.BR FUTEX_CMP_REQUEUE_PI )
0b0e4934
MK
1471.\" FIXME I reworded the following sentence a bit differently from
1472.\" tglx's formulation. Is it okay?
4b35dc5d 1473The thread ID in the futex word at
0b0e4934
MK
1474.I uaddr
1475does not exist.
1476.TP
360f773c
MK
1477.BR ESRCH
1478.RB ( FUTEX_CMP_REQUEUE_PI )
1479.\" FIXME I reworded the following sentence a bit differently from
1480.\" tglx's formulation. Is it okay?
4b35dc5d 1481The thread ID in the futex word at
360f773c
MK
1482.I uaddr2
1483does not exist.
1484.TP
9f6c40c0 1485.B ETIMEDOUT
4d85047f
MK
1486The operation in
1487.IR futex_op
1488employed the timeout specified in
1489.IR timeout ,
1490and the timeout expired before the operation completed.
70b06b90
MK
1491.\"
1492.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1493.\"
47297adb 1494.SH VERSIONS
a1d5f77c 1495.PP
81c9d87e
MK
1496Futexes were first made available in a stable kernel release
1497with Linux 2.6.0.
1498
4c8cb0ff
MK
1499Initial futex support was merged in Linux 2.5.7 but with different
1500semantics from what was described above.
52dee70e 1501A four-argument system call with the semantics
fd3fa7ef 1502described in this page was introduced in Linux 2.5.40.
11b520ed 1503In Linux 2.5.70, one argument
a1d5f77c 1504was added.
11b520ed 1505In Linux 2.6.7, a sixth argument was added\(emmessy, especially
a1d5f77c 1506on the s390 architecture.
47297adb 1507.SH CONFORMING TO
8382f16d 1508This system call is Linux-specific.
47297adb 1509.SH NOTES
baf0f1f4
MK
1510Glibc does not provide a wrapper for this system call; call it using
1511.BR syscall (2).
74f58a64
MK
1512.\" TODO FIXME(Torvald) Above, we cite this section and claim it contains
1513.\" details on the synchronization semantics; add the C11 equivalents
1514.\" here (or whatever we find consensus for).
305cc415
MK
1515.\"
1516.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1517.\"
1518.SH EXAMPLE
1519.\" FIXME Is it worth having an example program?
1520.\" FIXME Anything obviously broken in the example program?
1521.\"
77da5feb 1522The program below demonstrates use of futexes in a program
305cc415
MK
1523where parent and child use a pair of futexes located inside a
1524shared anonymous mapping to synchronize access to a shared resource:
1525the terminal.
1526The two processes each write
1527.IR nloops
1528(a command-line argument that defaults to 5 if omitted)
1529messages to the terminal and employ a synchronization protocol
1530that ensures that they alternate in writing messages.
1531Upon running this program we see output such as the following:
1532
1533.in +4n
1534.nf
1535$ \fB./futex_demo\fP
1536Parent (18534) 0
1537Child (18535) 0
1538Parent (18534) 1
1539Child (18535) 1
1540Parent (18534) 2
1541Child (18535) 2
1542Parent (18534) 3
1543Child (18535) 3
1544Parent (18534) 4
1545Child (18535) 4
1546.fi
1547.in
1548.SS Program source
1549\&
1550.nf
1551/* futex_demo.c
1552
1553 Usage: futex_demo [nloops]
1554 (Default: 5)
1555
1556 Demonstrate the use of futexes in a program where parent and child
1557 use a pair of futexes located inside a shared anonymous mapping to
1558 synchronize access to a shared resource: the terminal. The two
1559 processes each write \(aqnum\-loops\(aq messages to the terminal and employ
1560 a synchronization protocol that ensures that they alternate in
1561 writing messages.
1562*/
1563#define _GNU_SOURCE
1564#include <stdio.h>
1565#include <errno.h>
1566#include <stdlib.h>
1567#include <unistd.h>
1568#include <sys/wait.h>
1569#include <sys/mman.h>
1570#include <sys/syscall.h>
1571#include <linux/futex.h>
1572#include <sys/time.h>
1573
1574#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\
1575 } while (0)
1576
1577static int *futex1, *futex2, *iaddr;
1578
1579static int
1580futex(int *uaddr, int futex_op, int val,
1581 const struct timespec *timeout, int *uaddr2, int val3)
1582{
1583 return syscall(SYS_futex, uaddr, futex_op, val,
1584 timeout, uaddr, val3);
1585}
1586
1587/* Acquire the futex pointed to by \(aqfutexp\(aq: wait for its value to
1588 become 1, and then set the value to 0. */
1589
1590static void
1591fwait(int *futexp)
1592{
1593 int s;
1594
1595 /* __sync_bool_compare_and_swap(ptr, oldval, newval) is a gcc
1596 built\-in function. It atomically performs the equivalent of:
1597
1598 if (*ptr == oldval)
1599 *ptr = newval;
1600
1601 It returns true if the test yielded true and *ptr was updated.
1602 The alternative here would be to employ the equivalent atomic
1603 machine\-language instructions. For further information, see
1604 the GCC Manual. */
1605
305cc415 1606 while (1) {
83e80dda 1607
63ad44cb 1608 /* Is the futex available? */
83e80dda 1609
305cc415
MK
1610 if (__sync_bool_compare_and_swap(futexp, 1, 0))
1611 break; /* Yes */
1612
63ad44cb 1613 /* Futex is not available; wait */
83e80dda 1614
63ad44cb
HS
1615 s = futex(futexp, FUTEX_WAIT, 0, NULL, NULL, 0);
1616 if (s == \-1 && errno != EAGAIN)
1617 errExit("futex\-FUTEX_WAIT");
305cc415
MK
1618 }
1619}
1620
1621/* Release the futex pointed to by \(aqfutexp\(aq: if the futex currently
1622 has the value 0, set its value to 1 and the wake any futex waiters,
1623 so that if the peer is blocked in fpost(), it can proceed. */
1624
1625static void
1626fpost(int *futexp)
1627{
1628 int s;
1629
1630 /* __sync_bool_compare_and_swap() was described in comments above */
1631
1632 if (__sync_bool_compare_and_swap(futexp, 0, 1)) {
1633
1634 s = futex(futexp, FUTEX_WAKE, 1, NULL, NULL, 0);
1635 if (s == \-1)
1636 errExit("futex\-FUTEX_WAKE");
1637 }
1638}
1639
1640int
1641main(int argc, char *argv[])
1642{
1643 pid_t childPid;
1644 int j, nloops;
1645
1646 setbuf(stdout, NULL);
1647
1648 nloops = (argc > 1) ? atoi(argv[1]) : 5;
1649
1650 /* Create a shared anonymous mapping that will hold the futexes.
1651 Since the futexes are being shared between processes, we
1652 subsequently use the "shared" futex operations (i.e., not the
1653 ones suffixed "_PRIVATE") */
1654
1655 iaddr = mmap(NULL, sizeof(int) * 2, PROT_READ | PROT_WRITE,
1656 MAP_ANONYMOUS | MAP_SHARED, \-1, 0);
1657 if (iaddr == MAP_FAILED)
1658 errExit("mmap");
1659
1660 futex1 = &iaddr[0];
1661 futex2 = &iaddr[1];
1662
1663 *futex1 = 0; /* State: unavailable */
1664 *futex2 = 1; /* State: available */
1665
1666 /* Create a child process that inherits the shared anonymous
35764662 1667 mapping */
305cc415
MK
1668
1669 childPid = fork();
92a46690 1670 if (childPid == \-1)
305cc415
MK
1671 errExit("fork");
1672
1673 if (childPid == 0) { /* Child */
1674 for (j = 0; j < nloops; j++) {
1675 fwait(futex1);
1676 printf("Child (%ld) %d\\n", (long) getpid(), j);
1677 fpost(futex2);
1678 }
1679
1680 exit(EXIT_SUCCESS);
1681 }
1682
1683 /* Parent falls through to here */
1684
1685 for (j = 0; j < nloops; j++) {
1686 fwait(futex2);
1687 printf("Parent (%ld) %d\\n", (long) getpid(), j);
1688 fpost(futex1);
1689 }
1690
1691 wait(NULL);
1692
1693 exit(EXIT_SUCCESS);
1694}
1695.fi
47297adb 1696.SH SEE ALSO
4c222281 1697.ad l
9913033c 1698.BR get_robust_list (2),
d806bc05 1699.BR restart_syscall (2),
14d8dd3b 1700.BR futex (7)
fea681da 1701.PP
f5ad572f
MK
1702The following kernel source files:
1703.IP * 2
1704.I Documentation/pi-futex.txt
1705.IP *
1706.I Documentation/futex-requeue-pi.txt
1707.IP *
1708.I Documentation/locking/rt-mutex.txt
1709.IP *
1710.I Documentation/locking/rt-mutex-design.txt
8fe019c7
MK
1711.IP *
1712.I Documentation/robust-futex-ABI.txt
43b99089 1713.PP
4c222281 1714Franke, H., Russell, R., and Kirwood, M., 2002.
52087dd3 1715\fIFuss, Futexes and Furwocks: Fast Userlevel Locking in Linux\fP
4c222281 1716(from proceedings of the Ottawa Linux Symposium 2002),
9b936e9e 1717.br
608bf950
SK
1718.UR http://kernel.org\:/doc\:/ols\:/2002\:/ols2002-pages-479-495.pdf
1719.UE
f42eb21b 1720
4c222281 1721Hart, D., 2009. \fIA futex overview and update\fP,
2ed26199
MK
1722.UR http://lwn.net/Articles/360699/
1723.UE
1724
4c222281 1725Hart, D. and Guniguntala, D., 2009.
0483b6cc 1726\fIRequeue-PI: Making Glibc Condvars PI-Aware\fP
4c222281 1727(from proceedings of the 2009 Real-Time Linux Workshop),
0483b6cc
MK
1728.UR http://lwn.net/images/conf/rtlws11/papers/proc/p10.pdf
1729.UE
1730
4c222281 1731Drepper, U., 2011. \fIFutexes Are Tricky\fP,
f42eb21b
MK
1732.UR http://www.akkadia.org/drepper/futex.pdf
1733.UE
9b936e9e
MK
1734.PP
1735Futex example library, futex-*.tar.bz2 at
1736.br
a605264d 1737.UR ftp://ftp.kernel.org\:/pub\:/linux\:/kernel\:/people\:/rusty/
608bf950 1738.UE
34f14794
MK
1739.\"
1740.\" FIXME Are there any other resources that should be listed
1741.\" in the SEE ALSO section?
74f58a64 1742.\" FIXME(Torvald) We should probably refer to the glibc code here, in
4c8cb0ff
MK
1743.\" particular the glibc-internal futex wrapper functions that are
1744.\" WIP, and the generic pthread_mutex_t and perhaps condvar
1745.\" implementations.