]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
More thread test scheduler sensitivity fixes
authorBart Van Assche <bvanassche@acm.org>
Thu, 28 Jul 2011 09:33:55 +0000 (09:33 +0000)
committerBart Van Assche <bvanassche@acm.org>
Thu, 28 Jul 2011 09:33:55 +0000 (09:33 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11925

drd/tests/annotate_ignore_rw.c
drd/tests/annotate_ignore_write.c

index c57117d99173af22e62908ce15dded23940cfaed..d8913dbc51fe344c1ef4acb3bf7ed89d0214aaad 100644 (file)
@@ -22,6 +22,7 @@ static void* thread_func(void* arg)
 
 int main(int argc, char** argv)
 {
+  const struct timespec delay = { 0, 100 * 1000 * 1000 };
   int optchar;
   int ign_rw = 1;
   pthread_t tid;
@@ -39,6 +40,9 @@ int main(int argc, char** argv)
   }
 
   pthread_create(&tid, 0, thread_func, 0);
+
+  nanosleep(&delay, 0);
+
   if (ign_rw)
     ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN();
   /* Read s_b and modify s_a. */
index 2b71eb2c8b8672b796432919b3f0d1498b415035..8b7dc2f1660cb4419d3dbd8d443f4141f517380c 100644 (file)
@@ -22,6 +22,7 @@ static void* thread_func(void* arg)
 
 int main(int argc, char** argv)
 {
+  const struct timespec delay = { 0, 100 * 1000 * 1000 };
   int optchar;
   int ign_rw = 1;
   pthread_t tid;
@@ -39,6 +40,10 @@ int main(int argc, char** argv)
   }
 
   pthread_create(&tid, 0, thread_func, 0);
+
+  /* Let the code in the created thread run first. */
+  nanosleep(&delay, 0);
+
   if (ign_rw)
     ANNOTATE_IGNORE_WRITES_BEGIN();
   /* Read s_b and modify s_a. */
@@ -50,7 +55,7 @@ int main(int argc, char** argv)
    * Insert a delay here in order to make sure the load of s_c happens
    * after s_c has been modified.
    */
-  sleep(1);
+  nanosleep(&delay, 0);
 
   /* Read s_c and modify s_a. */
   s_a = s_c;