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