Date: Mon, 09 Jul 2012 18:57:53 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r239192 - in soc2012/gmiller/locking-head: . tools/regression/lib/libthr/lockprof Message-ID: <20120709185753.59D84106566B@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gmiller Date: Mon Jul 9 18:57:52 2012 New Revision: 239192 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239192 Log: r239205@FreeBSD-dev: root | 2012-07-03 10:49:44 -0500 Add test for pthread_resetstatistics_np() and multithreaded tests for lock/unlock cycles. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Mon Jul 9 17:34:03 2012 (r239191) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Mon Jul 9 18:57:52 2012 (r239192) @@ -46,6 +46,12 @@ pthread_join(thread2, NULL); } +void +reset_stats() +{ + pthread_resetstatistics_np(); +} + #define MAX_TESTS (100) int success_count = 0; @@ -121,6 +127,50 @@ void check_stats_multi(void) { + int record_count = 0; + struct pthread_statistics_np stats; + long tm; + + pthread_getstatistics_begin_np(&stats); + while (pthread_getstatistics_next_np(&stats)) { + record_count++; + } + pthread_getstatistics_end_np(&stats); + + check(record_count == 1); + + pthread_getstatistics_begin_np(&stats); + pthread_getstatistics_next_np(&stats); + pthread_getstatistics_end_np(&stats); + + check(strcmp(stats.file, "lock-cycle.c") == 0); + check(stats.line == 16); + + tm = stats.hold_max.tv_sec * 1000000L + stats.hold_max.tv_nsec / 1000; + check(tm >= 30); + + tm = stats.hold_time.tv_sec * 1000000L + + stats.hold_time.tv_nsec / 1000; + check(tm >= 30000); + + printf("count = %d\n", stats.acq_count); + + check(stats.acq_count == 3000); +} + +void +check_stats_reset(void) +{ + int record_count = 0; + struct pthread_statistics_np stats; + + pthread_getstatistics_begin_np(&stats); + while (pthread_getstatistics_next_np(&stats)) { + record_count++; + } + pthread_getstatistics_end_np(&stats); + + check(record_count == 0); } int @@ -129,6 +179,9 @@ lock_cycle(); check_stats_single(); + reset_stats(); + check_stats_reset(); + multi_cycle(); check_stats_multi();
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120709185753.59D84106566B>