|
From: <sv...@va...> - 2007-10-31 20:17:16
|
Author: sewardj
Date: 2007-10-31 20:17:16 +0000 (Wed, 31 Oct 2007)
New Revision: 7066
Log:
Restrict this test to two threads in an attempt to make the output
more repeatable.
Modified:
branches/THRCHECK/thrcheck/tests/tc21_pthonce.c
branches/THRCHECK/thrcheck/tests/tc21_pthonce.stderr.exp-glibc25-x86
branches/THRCHECK/thrcheck/tests/tc21_pthonce.stdout.exp
Modified: branches/THRCHECK/thrcheck/tests/tc21_pthonce.c
===================================================================
--- branches/THRCHECK/thrcheck/tests/tc21_pthonce.c 2007-10-31 19:29:33 UTC (rev 7065)
+++ branches/THRCHECK/thrcheck/tests/tc21_pthonce.c 2007-10-31 20:17:16 UTC (rev 7066)
@@ -40,19 +40,35 @@
#include <pthread.h>
-#define NUM_THREADS 4
+/* With more than 2 threads, the precise error reports vary between
+ platforms, in terms of the number of races detected. Make life
+ simple and just have 2 threads and so just 1 race. */
+#define NUM_THREADS 2
static pthread_once_t welcome_once_block = PTHREAD_ONCE_INIT;
static int unprotected1 = 0;
static int unprotected2 = 0;
+/* This is a hack: delay threads except the first enough so as to
+ ensure threads[0] gets to the pthread_once call first. This is so
+ as to ensure that this test produces results which aren't
+ scheduling sensitive. (sigh) */
+void maybe_stall ( int myid )
+{
+ assert(myid >= 0 && myid < NUM_THREADS);
+ if (myid > 0)
+ sleep(1);
+}
+
void welcome(void) {
printf("welcome: Welcome\n");
unprotected1++; /* this is harmless */
}
-void maybe_stall ( int myid );
-void* child ( void* argV ) { int r; maybe_stall( *(int*)argV );
+
+void* child ( void* argV ) {
+ int r;
+ maybe_stall( *(int*)argV );
r= pthread_once(&welcome_once_block, welcome); assert(!r);
printf("child: Hi, I'm thread %d\n", *(int*)argV);
unprotected2++; /* whereas this is a race */
@@ -73,19 +89,8 @@
for (i = 0; i < NUM_THREADS; i++) {
pthread_join(threads[i], NULL);
- //printf("main: joined to thread %d\n", i);
+ /* printf("main: joined to thread %d\n", i); */
}
printf("main: Goodbye\n");
return 0;
}
-
-/* This is a hack: delay threads except the first enough so as to
- ensure threads[0] gets to the pthread_once call first. This is so
- as to ensure that this test produces results which aren't
- scheduling sensitive. (sigh) */
-void maybe_stall ( int myid )
-{
- assert(myid >= 0 && myid < NUM_THREADS);
- if (myid > 0)
- sleep(1);
-}
Modified: branches/THRCHECK/thrcheck/tests/tc21_pthonce.stderr.exp-glibc25-x86
===================================================================
--- branches/THRCHECK/thrcheck/tests/tc21_pthonce.stderr.exp-glibc25-x86 2007-10-31 19:29:33 UTC (rev 7065)
+++ branches/THRCHECK/thrcheck/tests/tc21_pthonce.stderr.exp-glibc25-x86 2007-10-31 20:17:16 UTC (rev 7066)
@@ -3,16 +3,16 @@
at 0x........: clone (in /...libc...)
by 0x........: pthread_create@GLIBC_ (in /lib/libpthread...)
by 0x........: pthread_create@* (tc_intercepts.c:...)
- by 0x........: main (tc21_pthonce.c:70)
+ by 0x........: main (tc21_pthonce.c:86)
Thread #3 was created
at 0x........: clone (in /...libc...)
by 0x........: pthread_create@GLIBC_ (in /lib/libpthread...)
by 0x........: pthread_create@* (tc_intercepts.c:...)
- by 0x........: main (tc21_pthonce.c:70)
+ by 0x........: main (tc21_pthonce.c:86)
Possible data race during write of size 4 at 0x........
- at 0x........: child (tc21_pthonce.c:58)
+ at 0x........: child (tc21_pthonce.c:74)
by 0x........: mythread_wrapper (tc_intercepts.c:...)
by 0x........: ...
by 0x........: ...
Modified: branches/THRCHECK/thrcheck/tests/tc21_pthonce.stdout.exp
===================================================================
--- branches/THRCHECK/thrcheck/tests/tc21_pthonce.stdout.exp 2007-10-31 19:29:33 UTC (rev 7065)
+++ branches/THRCHECK/thrcheck/tests/tc21_pthonce.stdout.exp 2007-10-31 20:17:16 UTC (rev 7066)
@@ -1,6 +1,4 @@
welcome: Welcome
child: Hi, I'm thread 0
child: Hi, I'm thread 1
-child: Hi, I'm thread 2
-child: Hi, I'm thread 3
main: Goodbye
|