Operating System - HP-UX
1826420 Members
3141 Online
109692 Solutions
New Discussion

Re: POSIX stacksize and PA-RISC

 
SOLVED
Go to solution
Tarun Jain_1
Advisor

POSIX stacksize and PA-RISC


One of my threaded application is getting bus error because of the lower stack size of thread on PA machines. The application works fine for IA systems. I wanted to know why it is limited to 64 K on PA and is there any way to tune this value without using pthread() calls ?
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: POSIX stacksize and PA-RISC

Shalom,

What I've seen says ptthread is needed.

http://docs.hp.com/en/B2355-60105/pthread_attr_getdetachstate.3T.html

I would think that HP-UX 11i v2 would have the same stack size on PA-RISC as IA. Perhaps this issue is due to OS differences. 11.11 is older and may not have anticipated the needs of todays newer applications.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Tarun Jain_1
Advisor

Re: POSIX stacksize and PA-RISC

To explain more here is a simple program which used to fault on PA while works perfectly fine on IA.

+++++++++++++++++++++++++++++++++++++++++

#include
#include
#include
#include
#include

int* owner=NULL;
void* proc_monthread1(void*);
int main()
{
pthread_t odd_thread;
pthread_t even_thread;

pthread_attr_init(&odd_thread);

if ( pthread_create(&odd_thread, NULL,proc_monthread1, (void *)NULL) != 0 )
{
perror("");
exit(1);
}
sleep(600);
return 0;
}
void* proc_monthread1(void* arg)
{
char buff[1024*64];
char buff1[1024];
int i=0;
while (i++ < 25)
{
printf("I am thread 1\n");
sleep(1);
}
return NULL;
}
++++++++++++++++++++++++++++++++++++++++++++

Any answers to this ?

Compilation done using:
#cc thread_stack.c -g -o thre_pa -lpthread

ldd:
# ldd thre_pa
/usr/lib/libc.2 => /usr/lib/libc.2 /usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libc.2 => /usr/lib/libc.2 /usr/lib/libpthread.1 =>/usr/lib/libpthread.1

If I remove, 'buff' from thread, I know it works fine. Why do HP-UX PA-RISC comes with default stack size 64K which is not at all sufficient for even a very lightweight threaded application ?
Dennis Handly
Acclaimed Contributor

Re: POSIX stacksize and PA-RISC

On IPF, the size needed to be increased because of the RSE stack. They also looked at the number of support calls about this issue and make it bigger.

I've heard a newer libpthread patch will allow you to set an environment variable to increase the default. You can also use pthread_default_stacksize_np to set the default.

>SEP: 11.11 is older and may not have anticipated the needs of todays newer applications.

The man page for 11.31 still says 64 Kb.
Tarun Jain_1
Advisor

Re: POSIX stacksize and PA-RISC

>I've heard a newer libpthread patch will allow >you to set an environment variable to increase >the default. You can also use >pthread_default_stacksize_np to set the >default.

Dennis,
Can you please inform me about the libpthread patch for 11i v2 ? Since our application is already shipped to customer and to fix this we need to optimize our code to put all buffer on heap, we would like to inform customer about this patch and environment variable.
Dennis Handly
Acclaimed Contributor
Solution

Re: POSIX stacksize and PA-RISC

>Can you please inform me about the libpthread patch for 11i v2?

It appears this patch has been out for some time. For 11.23 it is CR JAGaf63003, PHCO_34718. The variable is PTHREAD_DEFAULT_STACK_SIZE.

>to fix this we need to optimize our code to put all buffer on heap

You could always use pthread_default_stacksize_np or pthread_attr_setstacksize rather than putting all buffers on the heap.
Tarun Jain_1
Advisor

Re: POSIX stacksize and PA-RISC

thanks for your quick response.

I have applied the patch and it is working with environment variable. We do not want to fix this with "setstacksize()" as this is required for larger portion of the application. Its okay if it works with some patch and setting environment variable.

I will close the thread. Thanks a bunch again for your response.
Tarun Jain_1
Advisor

Re: POSIX stacksize and PA-RISC

Thanks all.