diff options
Diffstat (limited to 'gdb/testsuite/gdb.threads/fork-thread-pending.c')
-rw-r--r-- | gdb/testsuite/gdb.threads/fork-thread-pending.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.threads/fork-thread-pending.c b/gdb/testsuite/gdb.threads/fork-thread-pending.c index bc9026c..d2ced96 100644 --- a/gdb/testsuite/gdb.threads/fork-thread-pending.c +++ b/gdb/testsuite/gdb.threads/fork-thread-pending.c @@ -28,6 +28,7 @@ #define NUMTHREADS 10 volatile int done = 0; +static pthread_barrier_t barrier; static void * start (void *arg) @@ -45,6 +46,8 @@ thread_function (void *arg) printf ("Thread <%d> executing\n", x); + pthread_barrier_wait (&barrier); + while (!done) usleep (100); @@ -62,6 +65,8 @@ thread_forker (void *arg) printf ("Thread forker <%d> executing\n", x); + pthread_barrier_wait (&barrier); + switch ((pid = fork ())) { case -1: @@ -89,6 +94,9 @@ main (void) int args[NUMTHREADS]; int i, j; + i = pthread_barrier_init (&barrier, NULL, NUMTHREADS); + assert (i == 0); + /* Create a few threads that do mostly nothing, and then one that forks. */ for (j = 0; j < NUMTHREADS - 1; ++j) |