mirror of https://github.com/mkerrisk/man-pages
futex.2: Fix a bug in the example
The man page contains a trivial bug that's discussed here: https://stackoverflow.com/q/59628958 Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
4897b19d4e
commit
09e456c2d0
|
@ -1797,8 +1797,8 @@ fwait(int *futexp)
|
|||
while (1) {
|
||||
|
||||
/* Is the futex available? */
|
||||
const int zero = 0;
|
||||
if (atomic_compare_exchange_strong(futexp, &zero, 1))
|
||||
const int one = 1;
|
||||
if (atomic_compare_exchange_strong(futexp, &one, 0))
|
||||
break; /* Yes */
|
||||
|
||||
/* Futex is not available; wait */
|
||||
|
@ -1820,8 +1820,8 @@ fpost(int *futexp)
|
|||
|
||||
/* atomic_compare_exchange_strong() was described in comments above */
|
||||
|
||||
const int one = 1;
|
||||
if (atomic_compare_exchange_strong(futexp, &one, 0)) {
|
||||
const int zero = 0;
|
||||
if (atomic_compare_exchange_strong(futexp, &zero, 1)) {
|
||||
s = futex(futexp, FUTEX_WAKE, 1, NULL, NULL, 0);
|
||||
if (s == \-1)
|
||||
errExit("futex\-FUTEX_WAKE");
|
||||
|
|
Loading…
Reference in New Issue