diff options
Diffstat (limited to 'lib/libthr/thread/thr_umtx.h')
-rw-r--r-- | lib/libthr/thread/thr_umtx.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h index d74cc81..f3d95f1 100644 --- a/lib/libthr/thread/thr_umtx.h +++ b/lib/libthr/thread/thr_umtx.h @@ -120,7 +120,7 @@ _thr_umutex_timedlock(struct umutex *mtx, uint32_t id, } static inline int -_thr_umutex_unlock(struct umutex *mtx, uint32_t id) +_thr_umutex_unlock2(struct umutex *mtx, uint32_t id, int *defer) { uint32_t flags = mtx->m_flags; @@ -132,8 +132,12 @@ _thr_umutex_unlock(struct umutex *mtx, uint32_t id) return (EPERM); } while (__predict_false(!atomic_cmpset_rel_32(&mtx->m_owner, owner, UMUTEX_UNOWNED))); - if ((owner & UMUTEX_CONTESTED)) - (void)_umtx_op_err(mtx, UMTX_OP_MUTEX_WAKE2, flags, 0, 0); + if ((owner & UMUTEX_CONTESTED)) { + if (defer == NULL) + (void)_umtx_op_err(mtx, UMTX_OP_MUTEX_WAKE2, flags, 0, 0); + else + *defer = 1; + } return (0); } if (atomic_cmpset_rel_32(&mtx->m_owner, id, UMUTEX_UNOWNED)) @@ -142,6 +146,12 @@ _thr_umutex_unlock(struct umutex *mtx, uint32_t id) } static inline int +_thr_umutex_unlock(struct umutex *mtx, uint32_t id) +{ + return _thr_umutex_unlock2(mtx, id, NULL); +} + +static inline int _thr_rwlock_tryrdlock(struct urwlock *rwlock, int flags) { int32_t state; |