1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2021-2024 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/>. */
24 /* Set this to non-zero from GDB to start a third worker thread. */
25 volatile int start_third_thread
= 0;
28 thread_worker_2 (void *arg
)
32 printf ("Hello from the third thread.\n");
35 for (i
= 0; i
< 300; ++i
)
42 thread_worker_1 (void *arg
)
48 if (start_third_thread
)
49 pthread_create (&thr
, NULL
, thread_worker_2
, NULL
);
51 printf ("Hello from the first thread.\n");
54 for (i
= 0; i
< 300; ++i
)
57 if (start_third_thread
)
58 pthread_join (thr
, &val
);
64 thread_idle_loop (void *arg
)
68 for (i
= 0; i
< 300; ++i
)
77 pthread_t thr
, thr_idle
;
80 if (getenv ("MAKE_EXTRA_THREAD") != NULL
)
81 pthread_create (&thr_idle
, NULL
, thread_idle_loop
, NULL
);
83 pthread_create (&thr
, NULL
, thread_worker_1
, NULL
);
84 pthread_join (thr
, &val
);
86 if (getenv ("MAKE_EXTRA_THREAD") != NULL
)
87 pthread_join (thr_idle
, &val
);