Use atomic instruction to set _has_writer, otherwise there is a race
causes userland to not wake up a thread sleeping in kernel. MFC after: 3 days
This commit is contained in:
parent
e64ac239f6
commit
b169d0efa1
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user