Date: Wed, 31 Dec 2003 11:43:46 -0800 (PST) From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 44608 for review Message-ID: <200312311943.hBVJhkrV078570@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=44608 Change 44608 by jhb@jhb_blue on 2003/12/31 11:43:15 Use a macro to simplify the trylock stuff and make it print out the recursion count each time as well. Affected files ... .. //depot/projects/smpng/sys/modules/crash/crash.c#7 edit Differences ... ==== //depot/projects/smpng/sys/modules/crash/crash.c#7 (text+ko) ==== @@ -238,28 +238,22 @@ mtx_init(&test1_mtx, "test1", NULL, MTX_DEF); mtx_init(&test1_mtx, "test2", NULL, MTX_DEF | MTX_RECURSE); - status = mtx_trylock(&test1_mtx); - printf("Try lock of unlocked test1: %d\n", status); - if (status) - mtx_unlock(&test1_mtx); +#define TRYLOCK_TEST(lock, descr) do { \ + status = mtx_trylock((lock)); \ + printf("Try lock of " descr ": %d; recurse = %d\n", \ + status, (lock)->mtx_recurse); \ + if (status) \ + mtx_unlock((lock)); \ +} while(0) + TRYLOCK_TEST(&test1_mtx, "unlocked test1"); mtx_lock(&test1_mtx); - status = mtx_trylock(&test1_mtx); - printf("Try lock of non-recursive locked test1: %d\n", - status); - if (status) - mtx_unlock(&test1_mtx); + TRYLOCK_TEST(&test1_mtx, "non-recursive locked test1"); mtx_unlock(&test1_mtx); - status = mtx_trylock(&test2_mtx); - printf("Try lock of unlocked test2: %d\n", status); - if (status) - mtx_unlock(&test2_mtx); + TRYLOCK_TEST(&test2_mtx, "unlocked test2"); mtx_lock(&test2_mtx); - status = mtx_trylock(&test2_mtx); - printf("Try lock of recursive locked test2: %d\n", - status); - if (status) - mtx_unlock(&test2_mtx); + TRYLOCK_TEST(&test2_mtx, "recursive locked test2"); mtx_unlock(&test2_mtx); +#undef TRYLOCK_TEST break; default: panic("event %d is bogus\n", event);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312311943.hBVJhkrV078570>