From owner-p4-projects@FreeBSD.ORG Wed Mar 29 21:31:10 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D548216A420; Wed, 29 Mar 2006 21:31:09 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9D04716A400 for ; Wed, 29 Mar 2006 21:31:09 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6B04143D49 for ; Wed, 29 Mar 2006 21:31:09 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2TLV92C076363 for ; Wed, 29 Mar 2006 21:31:09 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2TLV9iQ076360 for perforce@freebsd.org; Wed, 29 Mar 2006 21:31:09 GMT (envelope-from jhb@freebsd.org) Date: Wed, 29 Mar 2006 21:31:09 GMT Message-Id: <200603292131.k2TLV9iQ076360@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 94259 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Mar 2006 21:31:10 -0000 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++) {