Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Feb 2010 07:31:05 +0000 (UTC)
From:      David Xu <davidxu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r203657 - head/sys/kern
Message-ID:  <201002080731.o187V5Pk072517@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: davidxu
Date: Mon Feb  8 07:31:05 2010
New Revision: 203657
URL: http://svn.freebsd.org/changeset/base/203657

Log:
  Set waiters flag before checking semaphore's counter,
  otherwise we might lose a wakeup. Tested on postgresql database server.

Modified:
  head/sys/kern/kern_umtx.c

Modified: head/sys/kern/kern_umtx.c
==============================================================================
--- head/sys/kern/kern_umtx.c	Mon Feb  8 06:28:33 2010	(r203656)
+++ head/sys/kern/kern_umtx.c	Mon Feb  8 07:31:05 2010	(r203657)
@@ -2853,6 +2853,8 @@ do_sem_wait(struct thread *td, struct _u
 	umtxq_insert(uq);
 	umtxq_unlock(&uq->uq_key);
 
+	suword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 1);
+
 	count = fuword32(__DEVOLATILE(uint32_t *, &sem->_count));
 	if (count != 0) {
 		umtxq_lock(&uq->uq_key);
@@ -2863,11 +2865,6 @@ do_sem_wait(struct thread *td, struct _u
 		return (0);
 	}
 
-	/*
-	 * set waiters byte and sleep.
-	 */
-	suword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 1);
-
 	umtxq_lock(&uq->uq_key);
 	umtxq_unbusy(&uq->uq_key);
 	umtxq_unlock(&uq->uq_key);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002080731.o187V5Pk072517>