cvs commit: src/sys/dev/md md.c

Pawel Jakub Dawidek pjd at FreeBSD.org
Thu Sep 16 13:43:23 PDT 2004


On Thu, Sep 16, 2004 at 12:40:23PM -0700, Nate Lawson wrote:
+> >@@ -379,9 +379,8 @@
+> > 	bp->bio_bcount = bp->bio_length;
+> > 	mtx_lock(&sc->queue_mtx);
+> > 	bioq_disksort(&sc->bio_queue, bp);
+> >-	mtx_unlock(&sc->queue_mtx);
+> >-
+> > 	wakeup(sc);
+> >+	mtx_unlock(&sc->queue_mtx);
+> > }
+> 
+> I think the original order is correct since you can occur 2 switches if 
+> you wakeup first and then unlock.

Nope, this order was wrong:

thread1		thread2
-----------------------
mtx_lock(mtx)
...
mtx_unlock(mtx)
		mtx_lock(mtx)
wakeup(ptr)
		msleep(ptr, mtx) <- Race, it will be never woken up.

-- 
Pawel Jakub Dawidek                       http://www.FreeBSD.org
pjd at FreeBSD.org                           http://garage.freebsd.pl
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-all/attachments/20040916/ecf44f4e/attachment.bin


More information about the cvs-all mailing list