Can somebody ran this simple test program on Linux 2.1.x
and report results? Or tell what is wrong with the test?
Regards,
Dmitriy Budko [EMAIL PROTECTED]
From: Angus Mackay <[EMAIL PROTECTED]>
> >well, here is the code. please tell me what I have done wrong in regards to
> >the 1023 problem if you can.
> What versions of Linux kernel, glibc and gcc did you use?
I have tryed it on glibc-2.0.7 with both gcc-2.7.2 and egcs-2.8.1, and
under LynxOS 3.0 (that is the RTOS we use were I work).
under Linux it allows me to create 1 less than PTHREAD_MAX_THREADS which
is understandable considering when you link with pthreads main then
takes two threads, only one of which is a pthread.
I have tried putting a sleep(1) in mythread, it takes 1023 seconds but it
still fails. under LynxOS it fails at 97. under solaris it has worked
with over 100000 threads(quite fast too:
(amackay@hydra)~/tmp$ time ./pt 100000 > /dev/null
6.231u 0.292s 6.524real 99.98% )
here is the code I am testing this problem with:
=======8< pt.c ======#define _REENTRANT
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
int n_threads = 0;
void *
mythread(void *unused)
{
printf("thread %d reporting\n", n_threads);
n_threads++;
return (void *)13;
}
void create_and_wait(void)
{
pthread_t tid;
int res;
void *ret;
if( (res=pthread_create(&tid, NULL, mythread, NULL)) != 0 ) {
fprintf( stderr, "error creating thread: %d\n", res);
exit(5);
}
if(pthread_join(tid, &ret) != 0)
{
fprintf( stderr, "error joining thread\n");
}
if (ret != (void *)13)
{
fprintf(stderr, "thread exicution failed.\n");
exit(5);
}
}
int main(int argc, char **argv)
{
int i;
int limit;
if(argc>1)
{
limit = atoi(argv[1]);
}
else
{
limit = 1024;
}
for(i=0; i<limit; i++)
{
create_and_wait();
}
return 0;
}
======= pt.c >8======
thanks.
cheers, Angus.