Author: davidxu
Date: Mon Jan 16 04:39:10 2012
New Revision: 230194
URL: http://svn.freebsd.org/changeset/base/230194

Log:
  Eliminate branch and insert an explicit reader memory barrier to ensure
  that waiter bit is set before reading semaphore count.

Modified:
  head/sys/kern/kern_umtx.c

Modified: head/sys/kern/kern_umtx.c
==============================================================================
--- head/sys/kern/kern_umtx.c   Mon Jan 16 04:09:45 2012        (r230193)
+++ head/sys/kern/kern_umtx.c   Mon Jan 16 04:39:10 2012        (r230194)
@@ -2804,9 +2804,8 @@ do_sem_wait(struct thread *td, struct _u
        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);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to