aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.threads/manythreads.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2004-04-22 22:19:40 +0000
committerJeff Johnston <jjohnstn@redhat.com>2004-04-22 22:19:40 +0000
commit7339a42e03e6168e949e1a41755ab6698e2fa043 (patch)
tree5feafc0cd8ee72b83a019b59500f575f281f4403 /gdb/testsuite/gdb.threads/manythreads.c
parent017315e42d8bd16ffdfb88b0625d0b244e6c8e87 (diff)
downloadgdb-7339a42e03e6168e949e1a41755ab6698e2fa043.zip
gdb-7339a42e03e6168e949e1a41755ab6698e2fa043.tar.gz
gdb-7339a42e03e6168e949e1a41755ab6698e2fa043.tar.bz2
2004-04-22 Jeff Johnston <jjohnstn@redhat.com>
Daniel Jacobowitz <drow@mvista.com> * gdb.threads/manythreads.c: New testcase. * gdb.threads/manythreads.exp: Ditto.
Diffstat (limited to 'gdb/testsuite/gdb.threads/manythreads.c')
-rw-r--r--gdb/testsuite/gdb.threads/manythreads.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.threads/manythreads.c b/gdb/testsuite/gdb.threads/manythreads.c
new file mode 100644
index 0000000..c874b15
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/manythreads.c
@@ -0,0 +1,42 @@
+#include <pthread.h>
+#include <stdio.h>
+
+void *
+thread_function (void *arg)
+{
+ int x = (int)arg;
+
+ printf ("Thread <%d> executing\n", x);
+
+ return NULL;
+}
+
+int
+main (int argc, char **argv)
+{
+ pthread_attr_t attr;
+ pthread_t threads[256];
+ int i, j;
+
+ pthread_attr_init (&attr);
+
+ /* Create a ton of quick-executing threads, then wait for them to
+ complete. */
+ for (i = 0; i < 1000; ++i)
+ {
+ for (j = 0; j < 256; ++j)
+ {
+ pthread_create (&threads[j], &attr, thread_function,
+ (void *)(i * 1000 + j));
+ }
+
+ for (j = 0; j < 256; ++j)
+ {
+ pthread_join (threads[j], NULL);
+ }
+ }
+
+ pthread_attr_destroy (&attr);
+
+ return 0;
+}