Lines Matching refs:futex
38 * The futex system call coordinates notifying threads waiting for
62 * futex(&lock, FUTEX_WAIT, v | 2, NULL, NULL, 0,
79 * futex(&lock, FUTEX_WAKE, 1, NULL, NULL, 0, 0);
82 * The goal is to avoid the futex system call unless there is
86 * For a simple implementation, futex(FUTEX_WAIT) could queue
96 * The futex(&lock, FUTEX_CMP_REQUEUE, n, timeout, &lock2, m, val)
102 * a hash function; we must distinguish futex queues exactly by
122 #include <sys/futex.h>
137 * futex::fx_qlock ordered by kva of struct futex
140 * -> futex::fx_abortlock only one at a time
146 * A futex is addressed either by a vmspace+va (private) or by
158 * struct futex
160 * Kernel state for a futex located at a particular address in a
171 struct futex {
189 * State for a thread to wait on a futex. Threads wait on fw_cv
191 * a different futex queue at any time under the futex's lock.
196 struct futex *fw_futex;
227 const struct futex *fa = n;
247 const struct futex *fa = na;
248 const struct futex *fb = nb;
256 .rbto_node_offset = offsetof(struct futex, fx_node),
262 const struct futex *fa = n;
272 const struct futex *fa = na;
273 const struct futex *fb = nb;
281 .rbto_node_offset = offsetof(struct futex, fx_node),
284 static void futex_wait_dequeue(struct futex_wait *, struct futex *);
320 * Initialize the futex subsystem.
334 * Finalize the futex subsystem.
348 * Initialize the futex queue. Caller must call futex_queue_fini
354 futex_queue_init(struct futex *f)
374 futex_queue_drain(struct futex *f)
396 * Finalize the futex queue initialized by futex_queue_init. Queue
401 futex_queue_fini(struct futex *f)
414 * Initialize a futex key for lookup, etc.
435 * Release a futex key.
448 * Create a futex. Initial reference count is 1, representing the
450 * key, either transferring it to the newly-created futex, or releasing
455 static struct futex *
458 struct futex *f;
477 * Destroy a futex created with futex_create. Reference count
483 futex_destroy(struct futex *f)
509 futex_hold(struct futex *f)
531 futex_rele(struct futex *f)
575 futex_rele_not_last(struct futex *f)
588 * Try to find an existing futex va reference in the specified key
589 * On success, return 0, set f to found futex or to NULL if not found,
598 futex_lookup_by_key(union futex_key *fk, bool shared, struct futex **fp)
600 struct futex *f;
623 * Try to insert the futex f into the tree by va. If there
624 * already is a futex for its va, acquire a reference to it, and
627 * Return 0 on success, ENFILE if there already is a futex but its
631 futex_insert(struct futex *f, struct futex **fp)
633 struct futex *f0;
663 * Find a futex at the userland pointer uaddr in the current
664 * process's VM space. On success, return the futex in f and
670 futex_lookup(int *uaddr, bool shared, struct futex **fp)
710 * Find or create a futex at the userland pointer uaddr in the
711 * current process's VM space. On success, return the futex in f
717 futex_lookup_create(int *uaddr, bool shared, struct futex **fp)
721 struct futex *f = NULL;
751 * Create a futex record. This transfers ownership of the key
761 * Insert our new futex, or use existing if someone else beat
783 * Initialize a record for a thread to wait on a futex matching
795 cv_init(&fw->fw_cv, "futex");
804 * Finalize a record for a futex waiter. Must not be on any
805 * futex's queue.
820 * Put fw on the futex queue. Must be done before futex_wait.
822 * any existing futex's waiter list.
825 futex_wait_enqueue(struct futex_wait *fw, struct futex *f)
840 * Remove fw from the futex queue. Precludes subsequent
845 futex_wait_dequeue(struct futex_wait *fw, struct futex *f)
865 struct futex *f;
870 * Grab the futex queue. It can't go away as long as we hold
908 * Release our reference to the futex now that we are not
915 * aborting and no longer associated with a futex.
925 * fw must be a waiter on a futex's queue. Wait until deadline on
926 * the clock clkid, or forever if deadline is NULL, for a futex
927 * wakeup. Return 0 on explicit wakeup or destruction of futex,
929 * will no longer be on a futex queue on return.
1008 futex_wake(struct futex *f, unsigned nwake, struct futex *f2,
1035 * Drop the futex reference on behalf of the
1037 * reference on the futex (our caller should
1102 futex_queue_lock(struct futex *f)
1113 futex_queue_unlock(struct futex *f)
1129 futex_queue_lock2(struct futex *f, struct futex *f2)
1152 /* Otherwise, use the ordering on the kva of the futex pointer. */
1169 futex_queue_unlock2(struct futex *f, struct futex *f2)
1192 /* Otherwise, use the ordering on the kva of the futex pointer. */
1206 * Implement futex(FUTEX_WAIT) and futex(FUTEX_WAIT_BITSET): If
1207 * *uaddr == cmpval, wait until futex-woken on any of the bits in
1217 struct futex *f;
1245 /* Get the futex, creating it if necessary. */
1273 * We cannot drop our reference to the futex here, because
1297 * Implement futex(FUTEX_WAKE) and futex(FUTEX_WAKE_BITSET): Wake
1309 struct futex *f;
1319 /* Look up the futex, if any. */
1324 /* If there's no futex, there are no waiters to wake. */
1336 /* Release the futex. */
1351 * Implement futex(FUTEX_REQUEUE) and futex(FUTEX_CMP_REQUEUE): If
1365 struct futex *f = NULL, *f2 = NULL;
1376 * Look up or create the source futex. For FUTEX_CMP_REQUEUE,
1378 * because FUTEX_CMP_REQUEUE always tests the futex word in
1394 * We may need to create the destination futex because it's
1531 panic("invalid futex op");
1566 panic("invalid futex cmp operation");
1574 * Implement futex(FUTEX_WAKE_OP):
1589 struct futex *f = NULL, *f2 = NULL;
1604 /* Look up the first futex, if any. */
1609 /* Look up the second futex, if any. */
1663 * Implement the futex system call with all the parameters
1729 * __futex(2) system call: generic futex operations.
1823 * Try to release the robust futex at uva in the current process
1832 struct futex *f;
1848 * 1. User space cleared the futex word but died before
1853 * the futex in user space. Any other waiters are
1856 * In both of these cases, the futex word will be 0 (because
1858 * do is detect this situation if it's the pending futex and
1859 * issue a wake without modifying the futex word.
1875 * We need to handle the case where this thread owned the futex,
1877 * kernel state to look up. All we can do is mark the futex
1884 * before calling __futex() to wait, and the futex needs
1910 * Look for a shared futex since we have no positive indication
1918 * If there's no kernel state for this futex, there's nothing to
1924 /* Work under the futex queue lock. */
1954 /* Unlock the queue and release the futex. */
1988 * Helper routine to fetch the futex robust list head that
2024 * Decode a robust futex list word into the entry and entry
2038 * Helper routine to fetch and decode a robust futex entry
2089 " unmapped robust futex list head\n",
2121 " exhausted robust futex limit\n",
2126 /* If there's a pending futex, it may need to be released too. */