diff options
author | davidxu <davidxu@FreeBSD.org> | 2012-01-16 04:39:10 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2012-01-16 04:39:10 +0000 |
commit | 048374848083ea70c8db1b41fbf306b92d637424 (patch) | |
tree | e31397ae47dce570c6153915c2d93ee3963d3206 /sys/kern | |
parent | c3eb99c02f5a835a7f7ab6408db640e2ec155392 (diff) | |
download | FreeBSD-src-048374848083ea70c8db1b41fbf306b92d637424.zip FreeBSD-src-048374848083ea70c8db1b41fbf306b92d637424.tar.gz |
Eliminate branch and insert an explicit reader memory barrier to ensure
that waiter bit is set before reading semaphore count.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_umtx.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 7d8a781..896f77c 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -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); |