1 /* Pthreads test program.
2 Copyright 1996-2020 Free Software Foundation, Inc.
4 Written by Fred Fish of Cygnus Support
5 Contributed by Cygnus Support
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 static int verbose = 0;
33 static int from_thread1;
34 static int from_thread2;
37 static int full_coverage;
39 if (verbose) printf("common_routine (%d)\n", arg);
53 if (from_main && from_thread1 && from_thread2)
63 if (verbose) printf ("thread1 (%0lx) ; pid = %d\n", (long) arg, getpid ());
64 for (i=1; i <= 10000000; i++)
66 if (verbose) printf("thread1 %ld\n", (long) pthread_self ());
80 if (verbose) printf ("thread2 (%0lx) ; pid = %d\n", (long) arg, getpid ());
81 for (i=1; i <= 10000000; i++)
83 if (verbose) printf("thread2 %ld\n", (long) pthread_self ());
98 if (verbose) printf("a=%d\n", a);
106 pthread_t tid1, tid2;
112 if (verbose) printf ("pid = %d\n", getpid());
116 if (pthread_attr_init (&attr))
118 perror ("pthread_attr_init 1");
122 #ifdef PTHREAD_SCOPE_SYSTEM
123 if (pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM))
125 perror ("pthread_attr_setscope 1");
130 if (pthread_create (&tid1, &attr, thread1, (void *) 0xfeedface))
132 perror ("pthread_create 1");
135 if (verbose) printf ("Made thread %ld\n", (long) tid1);
138 if (pthread_create (&tid2, NULL, thread2, (void *) 0xdeadbeef))
140 perror ("pthread_create 2");
143 if (verbose) printf("Made thread %ld\n", (long) tid2);
147 for (j = 1; j <= 10000000; j++)
149 if (verbose) printf("top %ld\n", (long) pthread_self ());