|
From: <sv...@va...> - 2011-07-27 08:54:01
|
Author: bart
Date: 2011-07-27 09:49:12 +0100 (Wed, 27 Jul 2011)
New Revision: 11923
Log:
More thread tool regression test scheduler sensitivity fixes
Modified:
trunk/drd/tests/annotate_smart_pointer.cpp
trunk/drd/tests/atomic_var.c
trunk/drd/tests/pth_barrier.c
trunk/helgrind/tests/hg04_race.c
trunk/helgrind/tests/tc08_hbl2.c
Modified: trunk/drd/tests/annotate_smart_pointer.cpp
===================================================================
--- trunk/drd/tests/annotate_smart_pointer.cpp 2011-07-26 23:29:25 UTC (rev 11922)
+++ trunk/drd/tests/annotate_smart_pointer.cpp 2011-07-27 08:49:12 UTC (rev 11923)
@@ -305,6 +305,7 @@
int main(int argc, char** argv)
{
+ struct timespec delay = { 0, 100 * 1000 * 1000 };
const int nthreads = std::max(argc > 1 ? atoi(argv[1]) : 1, 1);
const int iterations = std::max(argc > 2 ? atoi(argv[2]) : 1, 1);
s_enable_annotations = argc > 3 ? !!atoi(argv[3]) : true;
@@ -318,6 +319,7 @@
for (int i = 0; i < nthreads; ++i)
T[i].Create(thread_func, new smart_ptr<counter>(p));
p = NULL;
+ nanosleep(&delay, 0);
for (int i = 0; i < nthreads; ++i)
T[i].Join();
}
Modified: trunk/drd/tests/atomic_var.c
===================================================================
--- trunk/drd/tests/atomic_var.c 2011-07-26 23:29:25 UTC (rev 11922)
+++ trunk/drd/tests/atomic_var.c 2011-07-27 08:49:12 UTC (rev 11923)
@@ -36,9 +36,6 @@
static void* thread_func_1(void* arg)
{
- struct timespec delay = { 0, 100 * 1000 * 1000 };
-
- nanosleep(&delay, 0);
s_y = 1;
(void) sync_add_and_fetch(&s_x, 1);
return 0;
@@ -56,11 +53,13 @@
{
int i;
const int n_threads = 2;
+ const struct timespec delay = { 0, 100 * 1000 * 1000 };
pthread_t tid[n_threads];
fprintf(stderr, "Start of test.\n");
pthread_create(&tid[0], 0, thread_func_1, 0);
pthread_create(&tid[1], 0, thread_func_2, 0);
+ nanosleep(&delay, 0);
for (i = 0; i < n_threads; i++)
pthread_join(tid[i], 0);
fprintf(stderr, "Test finished.\n");
Modified: trunk/drd/tests/pth_barrier.c
===================================================================
--- trunk/drd/tests/pth_barrier.c 2011-07-26 23:29:25 UTC (rev 11922)
+++ trunk/drd/tests/pth_barrier.c 2011-07-27 08:49:12 UTC (rev 11923)
@@ -64,6 +64,7 @@
static void barriers_and_races(const int nthread, const int iterations)
{
int i;
+ const struct timespec delay = { 0, 100 * 1000 * 1000 };
struct threadinfo* t;
pthread_barrier_t b;
int* array;
@@ -84,6 +85,8 @@
pthread_create(&t[i].tid, 0, (void*(*)(void*))threadfunc, &t[i]);
}
+ nanosleep(&delay, 0);
+
for (i = 0; i < nthread; i++)
{
pthread_join(t[i].tid, 0);
Modified: trunk/helgrind/tests/hg04_race.c
===================================================================
--- trunk/helgrind/tests/hg04_race.c 2011-07-26 23:29:25 UTC (rev 11922)
+++ trunk/helgrind/tests/hg04_race.c 2011-07-27 08:49:12 UTC (rev 11923)
@@ -14,12 +14,15 @@
int main()
{
+ const struct timespec delay = { 0, 100 * 1000 * 1000 };
pthread_t a, b;
pthread_create(&a, NULL, th, NULL);
- sleep(1); /* force ordering */
+ nanosleep(&delay, 0); /* force ordering */
pthread_create(&b, NULL, th, NULL);
+ nanosleep(&delay, 0); /* avoid false ordering between threads */
+
pthread_join(a, NULL);
pthread_join(b, NULL);
Modified: trunk/helgrind/tests/tc08_hbl2.c
===================================================================
--- trunk/helgrind/tests/tc08_hbl2.c 2011-07-26 23:29:25 UTC (rev 11922)
+++ trunk/helgrind/tests/tc08_hbl2.c 2011-07-27 08:49:12 UTC (rev 11923)
@@ -121,7 +121,7 @@
int main ( void )
{
- struct timespec delay = { 0, 100 * 1000 * 1000 };
+ const struct timespec delay = { 0, 100 * 1000 * 1000 };
pthread_t child;
int i;
@@ -130,13 +130,13 @@
exit(1);
}
- nanosleep(&delay, 0);
-
for (i = 0; i < LIMIT; i++) {
INC(x, "main");
if (i == 5) sleep(1); /* make sure child doesn't starve */
}
+ nanosleep(&delay, 0);
+
if (pthread_join(child, NULL)) {
perror("pthread join");
exit(1);
|