Lines Matching full:lock
3 * MCS lock defines
5 * This file contains the main data structure and API definitions of MCS lock.
7 * The MCS lock (proposed by Mellor-Crummey and Scott) is a simple spin-lock
9 * to acquire the lock spinning on a local variable.
10 * It avoids expensive cache bounces that common test-and-set spin-lock
22 * lock is acquired. Additionally, some architectures such as
50 * In order to acquire the lock, the caller should declare a local node and
51 * pass a reference of the node to this function in addition to the lock.
52 * If the lock has already been acquired, then this will proceed to spin
53 * on this node->locked until the previous lock holder sets the node->locked
57 void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node)
69 * with a LOCK primitive.
71 prev = xchg(lock, node);
74 * Lock acquired, don't need to set node->locked to 1. Threads
75 * only spin on its own node->locked value for lock acquisition.
76 * However, since this thread can immediately acquire the lock
79 * audit lock status, then set node->locked value here.
85 /* Wait until the lock holder passes the lock down. */
90 * Releases the lock. The caller should pass in the corresponding node that
91 * was used to acquire the lock.
94 void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node)
100 * Release the lock by setting it to NULL
102 if (likely(cmpxchg_release(lock, node, NULL) == node))
109 /* Pass lock to next waiter. */