PERFORCE change 103893 for review
John Baldwin
jhb at FreeBSD.org
Mon Aug 14 19:54:59 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=103893
Change 103893 by jhb at jhb_mutex on 2006/08/14 19:53:56
Add a mutex cycle.
Affected files ...
.. //depot/projects/smpng/sys/modules/crash2/crash2.c#12 edit
Differences ...
==== //depot/projects/smpng/sys/modules/crash2/crash2.c#12 (text+ko) ====
@@ -88,6 +88,7 @@
static int event[NTHREADS];
static struct rwlock foo;
static struct mtx bar;
+static struct mtx abc, def, ghi, jkl;
static struct sx one, two, three, four;
static struct lock fee, fi, fo, fum;
@@ -99,6 +100,19 @@
/* Events. */
+static struct mtx *mtxen[] = { &abc, &def, &ghi, &jkl };
+
+static void
+mtx_deadlock(int thread)
+{
+
+ mtx_lock(mtxen[thread % 4]);
+ tsleep(mtxen, 0, "mtx_dead", hz/10);
+ mtx_lock(mtxen[(thread + 1) % 4]);
+}
+CRASH2_EVENT("mutex cycle", mtx_deadlock, mtx_deadlock, mtx_deadlock,
+ mtx_deadlock);
+
static struct lock *locks[] = { &fee, &fi, &fo, &fum };
static struct sx *sxs[] = { &one, &two, &three, &four };
@@ -124,7 +138,7 @@
{
lockmgr(locks[thread % 4], LK_EXCLUSIVE, NULL, curthread);
- tsleep(sxs, 0, "lk_dead", hz/10);
+ tsleep(locks, 0, "lk_dead", hz/10);
lockmgr(locks[(thread + 1) % 4], LK_EXCLUSIVE, NULL, curthread);
}
CRASH2_EVENT("lockmgr cycle", lockmgr_deadlock, lockmgr_deadlock,
@@ -367,6 +381,10 @@
rw_init(&foo, "foo");
mtx_init(&bar, "bar", NULL, MTX_DEF);
+ mtx_init(&abc, "abc", NULL, MTX_DEF);
+ mtx_init(&def, "def", NULL, MTX_DEF);
+ mtx_init(&ghi, "ghi", NULL, MTX_DEF);
+ mtx_init(&jkl, "jkl", NULL, MTX_DEF);
sx_init(&one, "one");
sx_init(&two, "two");
sx_init(&three, "three");
@@ -414,6 +432,10 @@
sx_destroy(&three);
sx_destroy(&two);
sx_destroy(&one);
+ mtx_destroy(&jkl);
+ mtx_destroy(&ghi);
+ mtx_destroy(&def);
+ mtx_destroy(&abc);
mtx_destroy(&bar);
rw_destroy(&foo);
return (0);
More information about the p4-projects
mailing list