Lines Matching defs: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
20 int locked; /* 1 if lock acquired */
28 * lock is acquired. Additionally, some architectures such as
58 * In order to acquire the lock, the caller should declare a local node and
59 * pass a reference of the node to this function in addition to the lock.
60 * If the lock has already been acquired, then this will proceed to spin
61 * on this node->locked until the previous lock holder sets the node->locked
65 void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node)
79 prev = xchg(lock, node);
83 * only spin on its own node->locked value for lock acquisition.
84 * However, since this thread can immediately acquire the lock
87 * audit lock status, then set node->locked value here.
93 /* Wait until the lock holder passes the lock down. */
98 * Releases the lock. The caller should pass in the corresponding node that
99 * was used to acquire the lock.
102 void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node)
108 * Release the lock by setting it to NULL
110 if (likely(cmpxchg_release(lock, node, NULL) == node))
117 /* Pass lock to next waiter. */