Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libthr/thread/thr_umtx.h
Show All 38 Lines | |||||
#endif | #endif | ||||
#define DEFAULT_URWLOCK {0,0,0,0,{0,0,0,0}} | #define DEFAULT_URWLOCK {0,0,0,0,{0,0,0,0}} | ||||
int _umtx_op_err(void *, int op, u_long, void *, void *) __hidden; | int _umtx_op_err(void *, int op, u_long, void *, void *) __hidden; | ||||
int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden; | int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden; | ||||
int __thr_umutex_lock_spin(struct umutex *mtx, uint32_t id) __hidden; | int __thr_umutex_lock_spin(struct umutex *mtx, uint32_t id) __hidden; | ||||
int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id, | int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id, | ||||
const struct timespec *timeout) __hidden; | const struct timespec *timeout) __hidden; | ||||
int __thr_umutex_unlock(struct umutex *mtx, uint32_t id) __hidden; | int __thr_umutex_unlock(struct umutex *mtx) __hidden; | ||||
int __thr_umutex_trylock(struct umutex *mtx) __hidden; | int __thr_umutex_trylock(struct umutex *mtx) __hidden; | ||||
int __thr_umutex_set_ceiling(struct umutex *mtx, uint32_t ceiling, | int __thr_umutex_set_ceiling(struct umutex *mtx, uint32_t ceiling, | ||||
uint32_t *oldceiling) __hidden; | uint32_t *oldceiling) __hidden; | ||||
void _thr_umutex_init(struct umutex *mtx) __hidden; | void _thr_umutex_init(struct umutex *mtx) __hidden; | ||||
void _thr_urwlock_init(struct urwlock *rwl) __hidden; | void _thr_urwlock_init(struct urwlock *rwl) __hidden; | ||||
int _thr_umtx_wait(volatile long *mtx, long exp, | int _thr_umtx_wait(volatile long *mtx, long exp, | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | _thr_umutex_unlock2(struct umutex *mtx, uint32_t id, int *defer) | ||||
flags = mtx->m_flags; | flags = mtx->m_flags; | ||||
noncst = (flags & UMUTEX_NONCONSISTENT) != 0; | noncst = (flags & UMUTEX_NONCONSISTENT) != 0; | ||||
if ((flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) != 0) { | if ((flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) != 0) { | ||||
if (atomic_cmpset_rel_32(&mtx->m_owner, id, noncst ? | if (atomic_cmpset_rel_32(&mtx->m_owner, id, noncst ? | ||||
UMUTEX_RB_NOTRECOV : UMUTEX_UNOWNED)) | UMUTEX_RB_NOTRECOV : UMUTEX_UNOWNED)) | ||||
return (0); | return (0); | ||||
return (__thr_umutex_unlock(mtx, id)); | return (__thr_umutex_unlock(mtx)); | ||||
} | } | ||||
do { | do { | ||||
owner = mtx->m_owner; | owner = mtx->m_owner; | ||||
if (__predict_false((owner & ~UMUTEX_CONTESTED) != id)) | if (__predict_false((owner & ~UMUTEX_CONTESTED) != id)) | ||||
return (EPERM); | return (EPERM); | ||||
} while (__predict_false(!atomic_cmpset_rel_32(&mtx->m_owner, owner, | } while (__predict_false(!atomic_cmpset_rel_32(&mtx->m_owner, owner, | ||||
noncst ? UMUTEX_RB_NOTRECOV : UMUTEX_UNOWNED))); | noncst ? UMUTEX_RB_NOTRECOV : UMUTEX_UNOWNED))); | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |