Operating System - Linux
1751798 Members
5022 Online
108781 Solutions
New Discussion юеВ

Re: pthread_create fails on HP-UX (64-bit) with error code 11

 
SOLVED
Go to solution
jeet_xp
Occasional Advisor

pthread_create fails on HP-UX (64-bit) with error code 11

Hi,
I am using a client server program using RPC on HP-UX (Itanium), which uses pthread_create(). My program runs for a while but after sometime it fails with 11( i.e. lack of resources). I could not find what resources I lack. Then tuned kernel to max_thread_proc=512, still the problem remains.
note that I could run the programs 32-bit version on same machine without any problem but the 64-bit version shows the problem.

please let me know if anybody faced same problem or what are things to be checked to debug the problem.
10 REPLIES 10
AwadheshPandey
Honored Contributor

Re: pthread_create fails on HP-UX (64-bit) with error code 11

Dennis Handly
Acclaimed Contributor

Re: pthread_create fails on HP-UX (64-bit) with error code 11

I don't think it is the link Awadhesh provided, that is errno 22 (EINVAL), not 11 (EAGAIN).
jeet_xp
Occasional Advisor

Re: pthread_create fails on HP-UX (64-bit) with error code 11

Awadesh I have already seen the link which you have provided here before posting my query, anyways thanks for responding.
jeet_xp
Occasional Advisor

Re: pthread_create fails on HP-UX (64-bit) with error code 11

I have this sample code with me which fails after creating 280 threads or so. My kernel is tuned to create 512 threads per process. Interesting thing to note here is that the stack is doubled than the default. If the stack remains default it creates thread till 512.

I used following to compile the code
#cc +DD64 -lpthread -o thread thread.c

#include
#include
#include
#include
extern int errno;

static int count=0;
void *Start(void *a){
printf("I am a new thread [%d][%d]\n",count++,pthread_self());
while(1);
return NULL;
}

int main(){
pthread_t tid;
pthread_attr_t attr;
pthread_attr_init(&attr);
int rc;
while(1){
rc=pthread_attr_setstacksize(&attr,128*1024);
if(rc!=0){
perror("Thread stacksize failed ");
exit(1);
}
rc=pthread_create(&tid,&attr,Start,NULL);
if(rc!=0){
printf("errorno [%d], return code [%d]\n",errno,rc);
perror("Thread creation failed ");
exit(1);
}
// sleep(1);
};
return 0;
}

please let me know if this is a known issue with HPUX. where can I get list of all known issues and fixes for pthread in HPUX.
James R. Ferguson
Acclaimed Contributor
Solution

Re: pthread_create fails on HP-UX (64-bit) with error code 11

Hi:

> where can I get list of all known issues and fixes for pthread in HPUX.

That's easy; query the ITRC Patch Database. For example assuming release 11.23 (although you could be 11.31, I suppose) a search for 'pthread' shows a recent patch, PHCO_36323. See:

http://www1.itrc.hp.com/service/patch/search.do?BC=main|&pageOsid=hpux

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: pthread_create fails on HP-UX (64-bit) with error code 11

I ran your test case up to 2047, my max_thread_proc, both 32 and 64 bit. But I have a sleep in the thread function. When I take it out, it gets to 1984.

>#include
>extern int errno;

This is incorrect, replace by:
#include

>rc=pthread_attr_setstacksize(&attr,128*1024);
>if(rc!=0){
>perror("Thread stacksize failed ");

Might as well pull this out of the loop. Also perror won't work because the error returned is in rc.

>note here is that the stack is doubled than the default. If the stack remains default it creates thread till 512.

I'm confused. You're using 128 Kb, which is half the default of 256 Kb.

And if this is the issue, what is your maxdsiz and maxdsiz_64bit?
jeet_xp
Occasional Advisor

Re: pthread_create fails on HP-UX (64-bit) with error code 11

sorry for confusion, it was my mistake. Actually I was creating threads with 64Kb and now created with 128Kb, but the default is 256 Kb.
Problem is still there I don't know what went wrong, problem is not consistent but intermittent. I checked maxdsize and maxdsize_64bit they are 1GB and 4GB respectively.
Dennis Handly
Acclaimed Contributor

Re: pthread_create fails on HP-UX (64-bit) with error code 11

Any reason you want so many threads? Also, why each thread is in a 100% CPU loop? I had no problems when all of the CPU wasn't eaten up.

Also, you shouldn't make the thread stack size smaller than the default.
jeet_xp
Occasional Advisor

Re: pthread_create fails on HP-UX (64-bit) with error code 11

This is just an example to show the failure, my program is not the same but more complex than this and fails after creating lesser than these many number of threads.
But one thing is sure I keep on creating thread and canceling them in my program. The program is 64-bit. Can you please provide me version of your library?