1 /* Manythreads test program.
3 Free Software Foundation, Inc.
5 Written by Jeff Johnston <jjohnstn@redhat.com>
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
30 thread_function (void *arg
)
34 printf ("Thread <%d> executing\n", x
);
40 main (int argc
, char **argv
)
43 pthread_t threads
[256];
46 pthread_attr_init (&attr
);
47 pthread_attr_setstacksize (&attr
, PTHREAD_STACK_MIN
);
49 /* Create a ton of quick-executing threads, then wait for them to
51 for (i
= 0; i
< 1000; ++i
)
53 for (j
= 0; j
< 256; ++j
)
55 pthread_create (&threads
[j
], &attr
, thread_function
,
56 (void *)(i
* 1000 + j
));
59 for (j
= 0; j
< 256; ++j
)
61 pthread_join (threads
[j
], NULL
);
65 pthread_attr_destroy (&attr
);