Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   futex    ( 2 )

быстрая блокировка пользовательского пространства (fast user-space locking)

  Name  |  Synopsis  |  Description  |    Return value    |  Error  |  Versions  |  Conforming to  |  Note  |  Examples  |  See also  |

Возвращаемое значение (Return value)

In the event of an error (and assuming that futex() was invoked via syscall(2)), all operations return -1 and set errno to indicate the error.

The return value on success depends on the operation, as described in the following list:

FUTEX_WAIT Returns 0 if the caller was woken up. Note that a wake-up can also be caused by common futex usage patterns in unrelated code that happened to have previously used the futex word's memory location (e.g., typical futex-based implementations of Pthreads mutexes can cause this under some conditions). Therefore, callers should always conservatively assume that a return value of 0 can mean a spurious wake-up, and use the futex word's value (i.e., the user-space synchronization scheme) to decide whether to continue to block or not.

FUTEX_WAKE Returns the number of waiters that were woken up.

FUTEX_FD Returns the new file descriptor associated with the futex.

FUTEX_REQUEUE Returns the number of waiters that were woken up.

FUTEX_CMP_REQUEUE Returns the total number of waiters that were woken up or requeued to the futex for the futex word at uaddr2. If this value is greater than val, then the difference is the number of waiters requeued to the futex for the futex word at uaddr2.

FUTEX_WAKE_OP Returns the total number of waiters that were woken up. This is the sum of the woken waiters on the two futexes for the futex words at uaddr and uaddr2.

FUTEX_WAIT_BITSET Returns 0 if the caller was woken up. See FUTEX_WAIT for how to interpret this correctly in practice.

FUTEX_WAKE_BITSET Returns the number of waiters that were woken up.

FUTEX_LOCK_PI Returns 0 if the futex was successfully locked.

FUTEX_LOCK_PI2 Returns 0 if the futex was successfully locked.

FUTEX_TRYLOCK_PI Returns 0 if the futex was successfully locked.

FUTEX_UNLOCK_PI Returns 0 if the futex was successfully unlocked.

FUTEX_CMP_REQUEUE_PI Returns the total number of waiters that were woken up or requeued to the futex for the futex word at uaddr2. If this value is greater than val, then difference is the number of waiters requeued to the futex for the futex word at uaddr2.

FUTEX_WAIT_REQUEUE_PI Returns 0 if the caller was successfully requeued to the futex for the futex word at uaddr2.