mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-17 22:04:40 +00:00
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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=215652
|
@ -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 a new issue