Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Aug 2006 21:02:31 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 103908 for review
Message-ID:  <200608142102.k7EL2VDU036093@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=103908

Change 103908 by jhb@jhb_mutex on 2006/08/14 21:01:30

	Less sucky.

Affected files ...

.. //depot/projects/smpng/sys/modules/crash2/crash2.c#14 edit

Differences ...

==== //depot/projects/smpng/sys/modules/crash2/crash2.c#14 (text+ko) ====

@@ -91,6 +91,7 @@
 static struct mtx abc, def, ghi, jkl;
 static struct sx one, two, three, four;
 static struct lock fee, fi, fo, fum;
+static int crash2_wait = 1;
 
 static int	mod_event(struct module *module, int cmd, void *arg);
 static int	load(void *arg);
@@ -105,10 +106,21 @@
 static void
 mtx_deadlock(int thread)
 {
+	static int barrier;
 
+	atomic_add_int(&barrier, 1);
+	while (barrier != NTHREADS)
+		cpu_spinwait();
 	mtx_lock(mtxen[thread % 4]);
 	DELAY(500);
+
+	atomic_add_int(&barrier, 1);
+	while (barrier != 2 * NTHREADS)
+		cpu_spinwait();
 	mtx_lock(mtxen[(thread + 1) % 4]);
+
+	while (crash2_wait)
+		cpu_spinwait();
 }
 CRASH2_EVENT("mutex cycle", mtx_deadlock, mtx_deadlock, mtx_deadlock,
     mtx_deadlock);



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