6 /* Simple test program, has a race. Parent and child both modify y
7 with no locking. This is the program shown in Fig 2 of the
8 original Eraser paper by Savage et al. */
11 pthread_mutex_t mu
= PTHREAD_MUTEX_INITIALIZER
;
13 void* child_fn ( void* arg
)
15 /* "Thread 2" in the paper */
16 pthread_mutex_lock( &mu
);
18 pthread_mutex_unlock( &mu
);
25 const struct timespec delay
= { 0, 100 * 1000 * 1000 };
27 if (pthread_create(&child
, NULL
, child_fn
, NULL
)) {
28 perror("pthread_create");
32 /* "Thread 1" in the paper */
34 pthread_mutex_lock( &mu
);
36 pthread_mutex_unlock( &mu
);
38 if (pthread_join(child
, NULL
)) {
39 perror("pthread join");