mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-29 16:38:05 +08:00
gdb/testsuite/
Fix racy FAILs. * gdb.threads/fork-thread-pending.c (barrier): New variable. (thread_function, thread_forker): Call pthread_barrier_wait for it. (main): Call pthread_barrier_init for it.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2011-12-26 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
Fix racy FAILs.
|
||||||
|
* gdb.threads/fork-thread-pending.c (barrier): New variable.
|
||||||
|
(thread_function, thread_forker): Call pthread_barrier_wait for it.
|
||||||
|
(main): Call pthread_barrier_init for it.
|
||||||
|
|
||||||
2011-12-26 Jan Kratochvil <jan.kratochvil@redhat.com>
|
2011-12-26 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
Fix double send_gdb leading to racy FAILs.
|
Fix double send_gdb leading to racy FAILs.
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#define NUMTHREADS 10
|
#define NUMTHREADS 10
|
||||||
|
|
||||||
volatile int done = 0;
|
volatile int done = 0;
|
||||||
|
static pthread_barrier_t barrier;
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
start (void *arg)
|
start (void *arg)
|
||||||
@ -45,6 +46,8 @@ thread_function (void *arg)
|
|||||||
|
|
||||||
printf ("Thread <%d> executing\n", x);
|
printf ("Thread <%d> executing\n", x);
|
||||||
|
|
||||||
|
pthread_barrier_wait (&barrier);
|
||||||
|
|
||||||
while (!done)
|
while (!done)
|
||||||
usleep (100);
|
usleep (100);
|
||||||
|
|
||||||
@ -62,6 +65,8 @@ thread_forker (void *arg)
|
|||||||
|
|
||||||
printf ("Thread forker <%d> executing\n", x);
|
printf ("Thread forker <%d> executing\n", x);
|
||||||
|
|
||||||
|
pthread_barrier_wait (&barrier);
|
||||||
|
|
||||||
switch ((pid = fork ()))
|
switch ((pid = fork ()))
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
@ -89,6 +94,9 @@ main (void)
|
|||||||
int args[NUMTHREADS];
|
int args[NUMTHREADS];
|
||||||
int i, j;
|
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
|
/* Create a few threads that do mostly nothing, and then one that
|
||||||
forks. */
|
forks. */
|
||||||
for (j = 0; j < NUMTHREADS - 1; ++j)
|
for (j = 0; j < NUMTHREADS - 1; ++j)
|
||||||
|
Reference in New Issue
Block a user