Date: Wed, 29 Mar 2006 21:31:09 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 94259 for review Message-ID: <200603292131.k2TLV9iQ076360@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=94259 Change 94259 by jhb@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++) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603292131.k2TLV9iQ076360>