Date: Mon, 10 Apr 2006 19:17:41 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 94944 for review Message-ID: <200604101917.k3AJHfrB047925@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=94944 Change 94944 by jhb@jhb_slimer on 2006/04/10 19:16:57 Various upgrade/downgrade tests for rwlocks. Affected files ... .. //depot/projects/smpng/sys/modules/crash/crash.c#31 edit Differences ... ==== //depot/projects/smpng/sys/modules/crash/crash.c#31 (text+ko) ==== @@ -86,6 +86,73 @@ /* Events. */ +static void +upgrade_baz(void) +{ + rw_init(&baz, "baz"); + rw_rlock(&baz); + if (rw_try_upgrade(&baz) == 0) { + printf("crash: umm, upgrade failed?\n"); + rw_runlock(&baz); + } else + rw_wunlock(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("rlock baz, upgrade, and release", upgrade_baz); + +static void +downgrade_baz(void) +{ + rw_init(&baz, "baz"); + rw_wlock(&baz); + rw_downgrade(&baz); + rw_runlock(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("wlock baz, downgrade, and release", downgrade_baz); + +static void +upgrade_excl_baz(void) +{ + rw_init(&baz, "baz"); + rw_wlock(&baz); + rw_try_upgrade(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("wlock baz, upgrade", upgrade_excl_baz); + +static void +downgrade_shared_baz(void) +{ + rw_init(&baz, "baz"); + rw_rlock(&baz); + rw_downgrade(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("rlock baz, downgrade", downgrade_shared_baz); + +static void +runlock_upgraded_baz(void) +{ + rw_init(&baz, "baz"); + rw_rlock(&baz); + rw_try_upgrade(&baz); + rw_runlock(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("rlock baz, upgrade, runlock", runlock_upgraded_baz); + +static void +wunlock_downgraded_baz(void) +{ + rw_init(&baz, "baz"); + rw_wlock(&baz); + rw_downgrade(&baz); + rw_wunlock(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("wlock baz, downgrade, wunlock", wunlock_downgraded_baz); + #ifdef WITNESS static void @@ -356,8 +423,8 @@ if (sx_try_upgrade(&foo) == 0) { printf("crash: umm, upgrade failed?\n"); sx_sunlock(&foo); - } - sx_xunlock(&foo); + } else + sx_xunlock(&foo); } CRASH_EVENT("slock foo, upgrade, and release", upgrade_foo);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604101917.k3AJHfrB047925>