It looks like LinuxThreads package is not allowing more than
1024 pthread_create calls, even if the earlier threads are
detached. Probably the detach functionality is not working
properly. Trying this with DETACH attributes does not help
either. The following program is not able to create threads
after the 1022nd call. This works fine Solaris 2.6.
Huseyin
RedHat Linux 5.1
glibc 2.0.7 (with LinuxThreads)
/* gcc -g -O -Wall -D_REENTRANT -o ex ex.c -lpthread */
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
void * process(void * arg)
{
int rv;
rv = pthread_detach(pthread_self());
fprintf(stderr, "Starting process %d detach rv %d \n", (int) arg, rv);
return NULL;
int main()Quote:}
{
int retcode;
pthread_t ths[1040];
int i;
for(i=0; i < 1040; i++) {
retcode = pthread_create(&ths[i], NULL, process, (void*) i);
if (retcode != 0)
fprintf(stderr, "create failed for %d %d\n", i, retcode);
usleep(10000);
}
return 0;
Quote:}