Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jan 2006 23:02:47 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 90521 for review
Message-ID:  <200601272302.k0RN2lBc064013@repoman.freebsd.org>

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

Change 90521 by jhb@jhb_slimer on 2006/01/27 23:02:37

	Integ changes from jhb_lock branch.

Affected files ...

.. //depot/projects/smpng/sys/modules/crash/crash.c#28 integrate

Differences ...

==== //depot/projects/smpng/sys/modules/crash/crash.c#28 (text+ko) ====

@@ -49,11 +49,12 @@
 #include <sys/mutex.h>
 #include <sys/proc.h>
 #include <sys/refcount.h>
+#include <sys/rwlock.h>
 #include <sys/sched.h>
-#include <sys/unistd.h>
-#include <sys/sx.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
 
 struct crash_event {
 	const char *ev_name;
@@ -69,6 +70,7 @@
 
 #define	MAX_EVENT	SET_COUNT(crash_event_set)
 
+static struct rwlock baz;
 static struct sx foo, bar, bar2;
 static struct cv event_cv;
 static struct mtx event_mtx, test_mtx, test1_mtx, test2_mtx;
@@ -83,6 +85,49 @@
 
 /* Events. */
 
+#ifdef WITNESS
+static void
+fault_with_lock(void)
+{
+	char c, *cp;
+
+	cp = NULL;
+	mtx_lock(&test_mtx);
+	c = *cp;
+	mtx_unlock(&test_mtx);
+	printf("Read value of %x\n", (int)c);
+}
+CRASH_EVENT("fault with a mutex held", fault_with_lock);
+#endif
+
+static void
+rwlock_wlock(void)
+{
+
+	rw_init(&baz, "baz");
+	kdb_enter("baz exists");
+	rw_wlock(&baz);
+	kdb_enter("baz has a writer");
+	rw_wunlock(&baz);
+	kdb_enter("baz is unlocked");
+	rw_destroy(&baz);
+}
+CRASH_EVENT("rw_wlock", rwlock_wlock);
+
+static void
+rwlock_rlock(void)
+{
+
+	rw_init(&baz, "baz");
+	kdb_enter("baz exists");
+	rw_rlock(&baz);
+	kdb_enter("baz has a reader");
+	rw_runlock(&baz);
+	kdb_enter("baz is unlocked");
+	rw_destroy(&baz);
+}
+CRASH_EVENT("rw_rlock", rwlock_rlock);
+
 static void
 msleep_spin_callout(void *dummy)
 {



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