Lines Matching refs:mtx

42 int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden;
43 int __thr_umutex_lock_spin(struct umutex *mtx, uint32_t id) __hidden;
44 int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
46 int __thr_umutex_unlock(struct umutex *mtx) __hidden;
47 int __thr_umutex_trylock(struct umutex *mtx) __hidden;
48 int __thr_umutex_set_ceiling(struct umutex *mtx, uint32_t ceiling,
51 void _thr_umutex_init(struct umutex *mtx) __hidden;
54 int _thr_umtx_wait(volatile long *mtx, long exp,
56 int _thr_umtx_wait_uint(volatile u_int *mtx, u_int exp,
58 int _thr_umtx_timedwait_uint(volatile u_int *mtx, u_int exp, int clockid,
60 int _thr_umtx_wake(volatile void *mtx, int count, int shared) __hidden;
79 _thr_umutex_trylock(struct umutex *mtx, uint32_t id)
82 if (atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_UNOWNED, id))
84 if (__predict_false((uint32_t)mtx->m_owner == UMUTEX_RB_OWNERDEAD) &&
85 atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_RB_OWNERDEAD,
88 if (__predict_false((uint32_t)mtx->m_owner == UMUTEX_RB_NOTRECOV))
90 if ((mtx->m_flags & UMUTEX_PRIO_PROTECT) == 0)
92 return (__thr_umutex_trylock(mtx));
96 _thr_umutex_trylock2(struct umutex *mtx, uint32_t id)
99 if (atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_UNOWNED, id) != 0)
101 if ((uint32_t)mtx->m_owner == UMUTEX_CONTESTED &&
102 __predict_true((mtx->m_flags & (UMUTEX_PRIO_PROTECT |
104 atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_CONTESTED,
107 if (__predict_false((uint32_t)mtx->m_owner == UMUTEX_RB_OWNERDEAD) &&
108 atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_RB_OWNERDEAD,
111 if (__predict_false((uint32_t)mtx->m_owner == UMUTEX_RB_NOTRECOV))
117 _thr_umutex_lock(struct umutex *mtx, uint32_t id)
120 if (_thr_umutex_trylock2(mtx, id) == 0)
122 return (__thr_umutex_lock(mtx, id));
126 _thr_umutex_lock_spin(struct umutex *mtx, uint32_t id)
129 if (_thr_umutex_trylock2(mtx, id) == 0)
131 return (__thr_umutex_lock_spin(mtx, id));
135 _thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
139 if (_thr_umutex_trylock2(mtx, id) == 0)
141 return (__thr_umutex_timedlock(mtx, id, timeout));
145 _thr_umutex_unlock2(struct umutex *mtx, uint32_t id, int *defer)
150 flags = mtx->m_flags;
154 if (atomic_cmpset_rel_32(&mtx->m_owner, id, noncst ?
157 return (__thr_umutex_unlock(mtx));
161 owner = mtx->m_owner;
164 } while (__predict_false(!atomic_cmpset_rel_32(&mtx->m_owner, owner,
168 (void)_umtx_op_err(mtx, UMTX_OP_MUTEX_WAKE2,
177 _thr_umutex_unlock(struct umutex *mtx, uint32_t id)
180 return (_thr_umutex_unlock2(mtx, id, NULL));