diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 951fef6cfc03..43570ce5f9be 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -2839,7 +2839,8 @@ do_sem_wait(struct thread *td, struct _usem *sem, struct timespec *timeout) umtxq_insert(uq); umtxq_unlock(&uq->uq_key); - suword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 1); + if (fuword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters)) == 0) + casuword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 0, 1); count = fuword32(__DEVOLATILE(uint32_t *, &sem->_count)); if (count != 0) {