Add DRD suppression patterns for races triggered by std::ostream
[valgrind.git] / helgrind / tests / tc01_simple_race.c
blob8e36b5b5ac4a72da9a1eaac69e34f451ea64d224
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <stdlib.h>
6 /* Simple test program, has a race. Parent and child both modify x
7 with no locking. */
9 int x = 0;
11 void* child_fn ( void* arg )
13 /* Unprotected relative to parent */
14 x++;
15 return NULL;
18 int main ( void )
20 const struct timespec delay = { 0, 100 * 1000 * 1000 };
21 pthread_t child;
22 if (pthread_create(&child, NULL, child_fn, NULL)) {
23 perror("pthread_create");
24 exit(1);
26 nanosleep(&delay, 0);
27 /* Unprotected relative to child */
28 x++;
30 if (pthread_join(child, NULL)) {
31 perror("pthread join");
32 exit(1);
35 return 0;