1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include <sys/types.h>
30 volatile int done
= 0;
42 thread_function (void *arg
)
44 int x
= * (int *) arg
;
46 printf ("Thread <%d> executing\n", x
);
55 thread_forker (void *arg
)
57 int x
= * (int *) arg
;
63 printf ("Thread forker <%d> executing\n", x
);
65 switch ((pid
= fork ()))
74 i
= pthread_create (&thread
, NULL
, start
, NULL
);
76 i
= pthread_join (thread
, NULL
);
88 pthread_t threads
[NUMTHREADS
];
92 /* Create a few threads that do mostly nothing, and then one that
94 for (j
= 0; j
< NUMTHREADS
- 1; ++j
)
97 pthread_create (&threads
[j
], NULL
, thread_function
, &args
[j
]);
101 pthread_create (&threads
[j
], NULL
, thread_forker
, &args
[j
]);
103 for (j
= 0; j
< NUMTHREADS
; ++j
)
105 pthread_join (threads
[j
], NULL
);
This page took 0.031634 seconds and 4 git commands to generate.