PERFORCE change 94259 for review
John Baldwin
jhb at FreeBSD.org
Wed Mar 29 21:31:10 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=94259
Change 94259 by jhb at jhb_slimer on 2006/03/29 21:31:05
Add a test case for sleeping while holding a mutex.
Affected files ...
.. //depot/projects/smpng/sys/modules/crash2/crash2.c#3 edit
Differences ...
==== //depot/projects/smpng/sys/modules/crash2/crash2.c#3 (text+ko) ====
@@ -85,6 +85,7 @@
static struct proc *kthread[NTHREADS];
static int event[NTHREADS];
static struct rwlock foo;
+static struct mtx bar;
static int mod_event(struct module *module, int cmd, void *arg);
static int load(void *arg);
@@ -95,6 +96,16 @@
/* Events. */
static void
+bar_sleep(void)
+{
+
+ mtx_lock(&bar);
+ tsleep(&bar, curthread->td_priority, "bar", hz/100);
+ mtx_unlock(&bar);
+}
+CRASH2_EVENT("sleep holding bar", bar_sleep, bar_sleep, bar_sleep, bar_sleep);
+
+static void
whack_foo(void)
{
switch (arc4random() % 10) {
@@ -255,6 +266,7 @@
int error, i;
rw_init(&foo, "foo");
+ mtx_init(&bar, "bar", NULL, MTX_DEF);
mtx_init(&event_mtx, "crash2 event", NULL, MTX_DEF);
cv_init(&event_cv, "crash2");
for (i = 0; i < NTHREADS; i++) {
More information about the p4-projects
mailing list