Commit | Line | Data |
---|---|---|
4778a5f8 TV |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
3666a048 | 3 | Copyright 2020-2021 Free Software Foundation, Inc. |
4778a5f8 TV |
4 | |
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. | |
9 | ||
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. | |
14 | ||
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/>. */ | |
17 | ||
18 | #include <pthread.h> | |
19 | #include <unistd.h> | |
20 | #include <stdlib.h> | |
21 | ||
22 | pid_t pid; | |
23 | ||
24 | static pthread_barrier_t threads_started_barrier; | |
25 | ||
26 | static void | |
27 | all_started (void) | |
28 | { | |
29 | } | |
30 | ||
31 | static void * | |
32 | fun (void *dummy) | |
33 | { | |
34 | int i; | |
35 | ||
36 | pthread_barrier_wait (&threads_started_barrier); | |
37 | ||
38 | for (i = 0; i < 180; i++) | |
39 | sleep (1); | |
40 | ||
41 | pthread_exit (NULL); | |
42 | } | |
43 | ||
44 | int | |
45 | main (void) | |
46 | { | |
47 | int i; | |
48 | pthread_t thread; | |
49 | ||
50 | pid = getpid (); | |
51 | ||
52 | pthread_barrier_init (&threads_started_barrier, NULL, 2); | |
53 | ||
54 | pthread_create (&thread, NULL, fun, NULL); | |
55 | ||
56 | pthread_barrier_wait (&threads_started_barrier); | |
57 | ||
58 | all_started (); | |
59 | ||
60 | for (i = 0; i < 180; i++) | |
61 | sleep (1); | |
62 | ||
63 | exit (EXIT_SUCCESS); | |
64 | } |