1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

Eliminate branch and insert an explicit reader memory barrier to ensure

that waiter bit is set before reading semaphore count.
This commit is contained in:
David Xu 2012-01-16 04:39:10 +00:00
parent 8ff9d52cd0
commit 29a06690ca
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=230194

View File

@ -2804,9 +2804,8 @@ do_sem_wait(struct thread *td, struct _usem *sem, struct timespec *timeout)
umtxq_insert(uq);
umtxq_unlock(&uq->uq_key);
if (fuword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters)) == 0)
casuword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 0, 1);
casuword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 0, 1);
rmb();
count = fuword32(__DEVOLATILE(uint32_t *, &sem->_count));
if (count != 0) {
umtxq_lock(&uq->uq_key);