Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jul 2012 22:06:23 +0000
From:      gmiller@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r239445 - in soc2012/gmiller/locking-head: . tools/regression/lib/libthr/lockprof
Message-ID:  <20120715220623.8874F106564A@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gmiller
Date: Sun Jul 15 22:06:23 2012
New Revision: 239445
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239445

Log:
   r239386@FreeBSD-dev:  root | 2012-07-13 19:44:47 -0500
   Give the conflict tests their own file.

Added:
  soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c
  soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.t
     - copied unchanged from r238936, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.t
Modified:
  soc2012/gmiller/locking-head/   (props changed)
  soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile
  soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c

Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile
==============================================================================
--- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile	Sun Jul 15 22:06:07 2012	(r239444)
+++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile	Sun Jul 15 22:06:23 2012	(r239445)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-TESTS=	lock-cycle recurse
+TESTS=	lock-cycle recurse conflict
 CFLAGS+= -DLOCK_PROFILING -g -Wall -Wextra -Werror -lthr_profile
 
 .PHONY: tests
@@ -16,3 +16,6 @@
 
 recurse: recurse.c check.c
 	${CC} -o recurse recurse.c check.c ${CFLAGS}
+
+conflict: conflict.c check.c
+	${CC} -o conflict conflict.c check.c ${CFLAGS}

Added: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c	Sun Jul 15 22:06:23 2012	(r239445)
@@ -0,0 +1,73 @@
+
+#include <pthread.h>
+#include <pthread_np.h>
+#include <unistd.h>
+
+#include "check.h"
+
+pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+void *
+conflict_thread_func(void *v)
+{
+	v = v;
+
+	pthread_mutex_lock(&mutex);
+
+	sleep(5);
+
+	pthread_mutex_unlock(&mutex);
+
+	return NULL;
+}
+
+void
+conflict_test()
+{
+	pthread_t thread1;
+	pthread_t thread2;
+
+	pthread_statistics_reset_np();
+
+	pthread_create(&thread1, NULL, conflict_thread_func, NULL);
+	pthread_create(&thread2, NULL, conflict_thread_func, NULL);
+
+	pthread_join(thread2, NULL);
+	pthread_join(thread1, NULL);
+}
+
+void
+check_stats_conflict(void)
+{
+	int		record_count = 0;
+	struct pthread_statistics_np stats;
+	long		tm;
+
+	pthread_statistics_begin_np(&stats);
+	while (pthread_statistics_next_np(&stats)) {
+		record_count++;
+	}
+	pthread_statistics_end_np(&stats);
+
+	check(record_count == 1);
+
+	check(stats.contest_count == 1);
+
+	tm = stats.wait_time.tv_sec * 1000000L +
+	    stats.wait_time.tv_nsec / 1000;
+	check(tm > 0);
+
+	tm = stats.wait_max.tv_sec * 1000000L + stats.wait_max.tv_nsec / 1000;
+	check(tm > 0);
+}
+
+int
+main(void)
+{
+	conflict_test();
+	check_stats_conflict();
+
+	show_test_results();
+
+	return 0;
+}

Copied: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.t (from r238936, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.t)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.t	Sun Jul 15 22:06:23 2012	(r239445, copy of r238936, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.t)
@@ -0,0 +1,10 @@
+#!/bin/sh
+# $FreeBSD$
+
+cd `dirname $0`
+
+executable=`basename $0 .t`
+
+make $executable 2>&1 > /dev/null
+
+exec ./$executable

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	Sun Jul 15 22:06:07 2012	(r239444)
+++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c	Sun Jul 15 22:06:23 2012	(r239445)
@@ -53,35 +53,6 @@
 	pthread_statistics_reset_np();
 }
 
-void *
-conflict_thread_func(void *v)
-{
-	v = v;
-
-	pthread_mutex_lock(&mutex);
-
-	sleep(5);
-
-	pthread_mutex_unlock(&mutex);
-
-	return NULL;
-}
-
-void
-conflict_test()
-{
-	pthread_t thread1;
-	pthread_t thread2;
-
-	pthread_statistics_reset_np();
-
-	pthread_create(&thread1, NULL, conflict_thread_func, NULL);
-	pthread_create(&thread2, NULL, conflict_thread_func, NULL);
-
-	pthread_join(thread2, NULL);
-	pthread_join(thread1, NULL);
-}
-
 void
 check_stats_single(void)
 {
@@ -159,31 +130,6 @@
 	check(record_count == 0);
 }
 
-void
-check_stats_conflict(void)
-{
-	int		record_count = 0;
-	struct pthread_statistics_np stats;
-	long		tm;
-
-	pthread_statistics_begin_np(&stats);
-	while (pthread_statistics_next_np(&stats)) {
-		record_count++;
-	}
-	pthread_statistics_end_np(&stats);
-
-	check(record_count == 1);
-
-	check(stats.contest_count == 1);
-
-	tm = stats.wait_time.tv_sec * 1000000L +
-	    stats.wait_time.tv_nsec / 1000;
-	check(tm > 0);
-
-	tm = stats.wait_max.tv_sec * 1000000L + stats.wait_max.tv_nsec / 1000;
-	check(tm > 0);
-}
-
 int
 main(void)
 {
@@ -196,9 +142,6 @@
 	multi_cycle();
 	check_stats_multi();
 
-	conflict_test();
-	check_stats_conflict();
-
 	show_test_results();
 
 	return 0;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120715220623.8874F106564A>