xref: /netbsd-src/external/gpl3/gdb/dist/gdb/testsuite/gdb.server/attach-flag.c (revision 4b169a6ba595ae283ca507b26b15fdff40495b1c)
1 #include <pthread.h>
2 #include <unistd.h>
3 
4 static const int NTHREADS = 10;
5 static pthread_barrier_t barrier;
6 
7 static void *
thread_func(void * p)8 thread_func (void *p)
9 {
10   pthread_barrier_wait (&barrier);
11   return NULL;
12 }
13 
14 int
main(void)15 main (void)
16 {
17   alarm (60);
18 
19   pthread_t threads[NTHREADS];
20   pthread_barrier_init (&barrier, NULL, NTHREADS + 2);
21 
22   for (int i = 0; i < NTHREADS; i++)
23     pthread_create (&threads[i], NULL, thread_func, NULL);
24 
25   pthread_barrier_wait (&barrier);
26 
27   for (int i = 0; i < NTHREADS; i++)
28     pthread_join (threads[i], NULL);
29 }
30