By using following code i am able to create only 254 threads. Is it possible to get more than 2100 threads in a single process,by configuring the values.(in linux kernel 2.4 redhat 9) or some thing else ?
#include<stdio.h>
#include<pthread.h>
#include<unistd.h>
#include<limits.h>
#include<sys/time.h>
#include<sys/resource.h>
#include<errno.h>
void print(void);
int main()
{
int i=0,j=0;
pthread_t t;
void** m;
//int i=0;
struct rlimit rlimit;
rlimit.rlim_max=RLIM_INFINITY;
rlimit.rlim_cur=RLIM_INFINITY;
i=setrlimit(RLIMIT_AS,&rlimit);
//i=getrlimit(RLIMIT_AS,&rlimit);
if(!i)
printf("hard limit=%ud,soft limit=%ud limit=%ud",rlimit.rlim_max,rlimit.rlim_cur,RLIM_INFINITY);
#include<pthread.h>
#include<unistd.h>
#include<limits.h>
#include<sys/time.h>
#include<sys/resource.h>
#include<errno.h>
void print(void);
int main()
{
int i=0,j=0;
pthread_t t;
void** m;
//int i=0;
struct rlimit rlimit;
rlimit.rlim_max=RLIM_INFINITY;
rlimit.rlim_cur=RLIM_INFINITY;
i=setrlimit(RLIMIT_AS,&rlimit);
//i=getrlimit(RLIMIT_AS,&rlimit);
if(!i)
printf("hard limit=%ud,soft limit=%ud limit=%ud",rlimit.rlim_max,rlimit.rlim_cur,RLIM_INFINITY);
//printf("Total Threads = %d\n",PTHREAD_THREADS_MAX);
for(i=0;errno!=EAGAIN,!j;i++){
j=pthread_create(&t,NULL,print,NULL);
printf("Thread created value %d\n",j);
poll(0,0,100);
for(i=0;errno!=EAGAIN,!j;i++){
j=pthread_create(&t,NULL,print,NULL);
printf("Thread created value %d\n",j);
poll(0,0,100);
//if(j<0)
//printf("Unable to create thread %d\n",j);
}
//if (errno==EAGAIN)
perror("HI:");
while(1);
_/*sleep(2);
printf("IN loop\n");
}*/
//pthread_join(t,m);
return 0;
}
//printf("Unable to create thread %d\n",j);
}
//if (errno==EAGAIN)
perror("HI:");
while(1);
_/*sleep(2);
printf("IN loop\n");
}*/
//pthread_join(t,m);
return 0;
}
void print()
{
static int j=0;{
printf("%d:thread\t",j++);
while(1){
//printf("%d:thread\t",j++);
sleep(2);
}
}
Thanks and regards
Prakash
Find out what India is talking about on Yahoo! Answers India.
So, whatÂ’s NEW about the NEW Yahoo! Messenger? Find out. __._,_.___
http://www.linuxhubli.org
SPONSORED LINKS
| Linux operating system | Unix operating system | Linux software |
| Linux |
YAHOO! GROUPS LINKS
- Visit your group "linuxhubli" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
