Lines Matching defs:futex

38  *	The futex system call coordinates notifying threads waiting for
62 * futex(FUTEX_WAIT, &lock, v | 2, NULL, NULL, 0);
78 * futex(FUTEX_WAKE, &lock, 1, NULL, NULL, 0);
81 * The goal is to avoid the futex system call unless there is
85 * For a simple implementation, futex(FUTEX_WAIT) could queue
95 * The futex(FUTEX_CMP_REQUEUE, &lock, n, &lock2, m, val)
101 * a hash function; we must distinguish futex queues exactly by
121 #include <sys/futex.h>
136 * futex::fx_qlock ordered by kva of struct futex
139 * -> futex::fx_abortlock only one at a time
145 * A futex is addressed either by a vmspace+va (private) or by
157 * struct futex
159 * Kernel state for a futex located at a particular address in a
170 struct futex {
188 * State for a thread to wait on a futex. Threads wait on fw_cv
190 * a different futex queue at any time under the futex's lock.
195 struct futex *fw_futex;
226 const struct futex *fa = n;
246 const struct futex *fa = na;
247 const struct futex *fb = nb;
255 .rbto_node_offset = offsetof(struct futex, fx_node),
261 const struct futex *fa = n;
271 const struct futex *fa = na;
272 const struct futex *fb = nb;
280 .rbto_node_offset = offsetof(struct futex, fx_node),
283 static void futex_wait_dequeue(struct futex_wait *, struct futex *);
319 * Initialize the futex subsystem.
333 * Finalize the futex subsystem.
347 * Initialize the futex queue. Caller must call futex_queue_fini
353 futex_queue_init(struct futex *f)
373 futex_queue_drain(struct futex *f)
395 * Finalize the futex queue initialized by futex_queue_init. Queue
400 futex_queue_fini(struct futex *f)
413 * Initialize a futex key for lookup, etc.
434 * Release a futex key.
447 * Create a futex. Initial reference count is 1, representing the
449 * key, either transferring it to the newly-created futex, or releasing
454 static struct futex *
457 struct futex *f;
476 * Destroy a futex created with futex_create. Reference count
482 futex_destroy(struct futex *f)
508 futex_hold(struct futex *f)
530 futex_rele(struct futex *f)
574 futex_rele_not_last(struct futex *f)
587 * Try to find an existing futex va reference in the specified key
588 * On success, return 0, set f to found futex or to NULL if not found,
597 futex_lookup_by_key(union futex_key *fk, bool shared, struct futex **fp)
599 struct futex *f;
622 * Try to insert the futex f into the tree by va. If there
623 * already is a futex for its va, acquire a reference to it, and
626 * Return 0 on success, ENFILE if there already is a futex but its
630 futex_insert(struct futex *f, struct futex **fp)
632 struct futex *f0;
662 * Find a futex at the userland pointer uaddr in the current
663 * process's VM space. On success, return the futex in f and
669 futex_lookup(int *uaddr, bool shared, struct futex **fp)
709 * Find or create a futex at the userland pointer uaddr in the
710 * current process's VM space. On success, return the futex in f
716 futex_lookup_create(int *uaddr, bool shared, struct futex **fp)
720 struct futex *f = NULL;
750 * Create a futex record. This transfers ownership of the key
760 * Insert our new futex, or use existing if someone else beat
782 * Initialize a record for a thread to wait on a futex matching
794 cv_init(&fw->fw_cv, "futex");
803 * Finalize a record for a futex waiter. Must not be on any
804 * futex's queue.
819 * Put fw on the futex queue. Must be done before futex_wait.
821 * any existing futex's waiter list.
824 futex_wait_enqueue(struct futex_wait *fw, struct futex *f)
839 * Remove fw from the futex queue. Precludes subsequent
844 futex_wait_dequeue(struct futex_wait *fw, struct futex *f)
864 struct futex *f;
869 * Grab the futex queue. It can't go away as long as we hold
907 * Release our reference to the futex now that we are not
914 * aborting and no longer associated with a futex.
924 * fw must be a waiter on a futex's queue. Wait until deadline on
925 * the clock clkid, or forever if deadline is NULL, for a futex
926 * wakeup. Return 0 on explicit wakeup or destruction of futex,
928 * will no longer be on a futex queue on return.
1003 futex_wake(struct futex *f, unsigned nwake, struct futex *f2,
1030 * Drop the futex reference on behalf of the
1032 * reference on the futex (our caller should
1097 futex_queue_lock(struct futex *f)
1108 futex_queue_unlock(struct futex *f)
1124 futex_queue_lock2(struct futex *f, struct futex *f2)
1147 /* Otherwise, use the ordering on the kva of the futex pointer. */
1164 futex_queue_unlock2(struct futex *f, struct futex *f2)
1187 /* Otherwise, use the ordering on the kva of the futex pointer. */
1200 * Implement futex(FUTEX_WAIT).
1207 struct futex *f;
1235 /* Get the futex, creating it if necessary. */
1263 * We cannot drop our reference to the futex here, because
1287 * Implement futex(FUTEX_WAKE) and futex(FUTEX_WAKE_BITSET).
1292 struct futex *f;
1302 /* Look up the futex, if any. */
1307 /* If there's no futex, there are no waiters to wake. */
1320 /* Release the futex. */
1334 * Implement futex(FUTEX_REQUEUE) and futex(FUTEX_CMP_REQUEUE).
1340 struct futex *f = NULL, *f2 = NULL;
1351 * Look up or create the source futex. For FUTEX_CMP_REQUEUE,
1353 * because FUTEX_CMP_REQUEUE always tests the futex word in
1369 * We may need to create the destination futex because it's
1489 panic("invalid futex op");
1524 panic("invalid futex cmp operation");
1531 * Implement futex(FUTEX_WAKE_OP).
1537 struct futex *f = NULL, *f2 = NULL;
1552 /* Look up the first futex, if any. */
1557 /* Look up the second futex, if any. */
1610 * Implement the futex system call with all the parameters
1657 * __futex(2) system call: generic futex operations.
1751 * Try to release the robust futex at uva in the current process
1760 struct futex *f;
1776 * 1. User space cleared the futex word but died before
1781 * the futex in user space. Any other waiters are
1784 * In both of these cases, the futex word will be 0 (because
1786 * do is detect this situation if it's the pending futex and
1787 * issue a wake without modifying the futex word.
1803 * We need to handle the case where this thread owned the futex,
1805 * kernel state to look up. All we can do is mark the futex
1812 * before calling __futex() to wait, and the futex needs
1838 * Look for a shared futex since we have no positive indication
1846 * If there's no kernel state for this futex, there's nothing to
1852 /* Work under the futex queue lock. */
1882 /* Unlock the queue and release the futex. */
1916 * Helper routine to fetch the futex robust list head that
1952 * Decode a robust futex list word into the entry and entry
1966 * Helper routine to fetch and decode a robust futex entry
2017 " unmapped robust futex list head\n",
2049 " exhausted robust futex limit\n",
2054 /* If there's a pending futex, it may need to be released too. */