Lines Matching defs:mtx

39 int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden;
40 int __thr_umutex_lock_spin(struct umutex *mtx, uint32_t id) __hidden;
41 int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
43 int __thr_umutex_unlock(struct umutex *mtx, uint32_t id) __hidden;
44 int __thr_umutex_trylock(struct umutex *mtx) __hidden;
45 int __thr_umutex_set_ceiling(struct umutex *mtx, uint32_t ceiling,
48 void _thr_umutex_init(struct umutex *mtx) __hidden;
51 int _thr_umtx_wait(volatile long *mtx, long exp,
53 int _thr_umtx_wait_uint(volatile u_int *mtx, u_int exp,
55 int _thr_umtx_timedwait_uint(volatile u_int *mtx, u_int exp, int clockid,
57 int _thr_umtx_wake(volatile void *mtx, int count, int shared) __hidden;
76 _thr_umutex_trylock(struct umutex *mtx, uint32_t id)
78 if (atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_UNOWNED, id))
80 if ((mtx->m_flags & UMUTEX_PRIO_PROTECT) == 0)
82 return (__thr_umutex_trylock(mtx));
86 _thr_umutex_trylock2(struct umutex *mtx, uint32_t id)
88 if (atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_UNOWNED, id) != 0)
90 if ((uint32_t)mtx->m_owner == UMUTEX_CONTESTED &&
91 __predict_true((mtx->m_flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) == 0))
92 if (atomic_cmpset_acq_32(&mtx->m_owner, UMUTEX_CONTESTED, id | UMUTEX_CONTESTED))
98 _thr_umutex_lock(struct umutex *mtx, uint32_t id)
100 if (_thr_umutex_trylock2(mtx, id) == 0)
102 return (__thr_umutex_lock(mtx, id));
106 _thr_umutex_lock_spin(struct umutex *mtx, uint32_t id)
108 if (_thr_umutex_trylock2(mtx, id) == 0)
110 return (__thr_umutex_lock_spin(mtx, id));
114 _thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
117 if (_thr_umutex_trylock2(mtx, id) == 0)
119 return (__thr_umutex_timedlock(mtx, id, timeout));
123 _thr_umutex_unlock2(struct umutex *mtx, uint32_t id, int *defer)
125 uint32_t flags = mtx->m_flags;
130 owner = mtx->m_owner;
133 } while (__predict_false(!atomic_cmpset_rel_32(&mtx->m_owner,
137 (void)_umtx_op_err(mtx, UMTX_OP_MUTEX_WAKE2, flags, 0, 0);
143 if (atomic_cmpset_rel_32(&mtx->m_owner, id, UMUTEX_UNOWNED))
145 return (__thr_umutex_unlock(mtx, id));
149 _thr_umutex_unlock(struct umutex *mtx, uint32_t id)
151 return _thr_umutex_unlock2(mtx, id, NULL);