This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[rfc] no more than 1020 threads total in a processes lifetime?
- To: GNU C Library <libc-alpha at sourceware dot cygnus dot com>
- Subject: [rfc] no more than 1020 threads total in a processes lifetime?
- From: Ben Collins <bcollins at debian dot org>
- Date: Sun, 24 Dec 2000 11:20:09 -0500
This program exemplifies a problem in a Debian bug report that where
after creating more than 1020 threads (on my sparc, 1023 for him on
i386), it could no longer create any more threads. However, the main
thread hung after this (seemingly in pthread_create()). Is this test
case messed in someway, or is this a bug?
--
-----------=======-=-======-=========-----------=====------------=-=------
/ Ben Collins -- ...on that fantastic voyage... -- Debian GNU/Linux \
` bcollins@debian.org -- bcollins@openldap.org -- bcollins@linux.com '
`---=========------=======-------------=-=-----=-===-======-------=--=---'
#include <stdio.h>
#include <pthread.h>
#define NUMTHREADS 1028
int init_th(int *);
void start_threads(void);
int i;
int main(int argc, char *argv[])
{
static pthread_once_t once_ctrl;
printf("Program begins...\n");
printf("Starting the master of all threads.\n");
pthread_once(&once_ctrl, (void (*)(void)) (start_threads));
return (0);
}
void start_threads(void)
{
pthread_t thread;
int error;
i = 0;
while(i++<NUMTHREADS){
printf("Starting thread #%i\n",i);
error = pthread_create(&thread,(pthread_attr_t *) NULL,
(void *(*)(void *)) &(init_th), (void *) &i);
if (error){
perror("pthread_create");
printf("Error #%i\n", error);
fflush(stdout);fflush(stderr);
}
}
printf("Master thread ends.\n");
}
int init_th(int *i_ptr)
{
int retval=0;
printf("This is thread #%i\n", *i_ptr);
pthread_exit(&retval);
}