Default Posix thread stack size

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Default Posix thread stack size

Raimo Niskanen-7
We just discovered that it appears the default Posix thread
stack size is 64KByte for OpenBSD (4.1). That seems a bit slim.
To compare I recall Solaris8 has got 2MByte as default.

Can I assume all C library routines in OpenBSD are tuned to be
careful with stack usage?

Is there some system parameter to tweak to increase the default
stack size. It would be nice to not force the application
into setting its stack size - it differs a lot between
different platforms, would be hard to maintain and
has an uncomfortable stoneage feeling.

--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB

Reply | Threaded
Open this post in threaded view
|

Re: Default Posix thread stack size

John Wright-6
On Fri, Sep 07, 2007 at 10:47:28AM +0200, Raimo Niskanen wrote:

> We just discovered that it appears the default Posix thread
> stack size is 64KByte for OpenBSD (4.1). That seems a bit slim.
> To compare I recall Solaris8 has got 2MByte as default.
>
> Can I assume all C library routines in OpenBSD are tuned to be
> careful with stack usage?
>
> Is there some system parameter to tweak to increase the default
> stack size. It would be nice to not force the application
> into setting its stack size - it differs a lot between
> different platforms, would be hard to maintain and
> has an uncomfortable stoneage feeling.

I usually have:

#ifdef __OpenBSD__
    size_t stacksize;
    pthread_attr_getstacksize(&attr, &stacksize);
    pthread_attr_setstacksize(&attr, stacksize * 2);
#endif

in my threaded stuff.

Doubling the size usually works for my C++ stuff.

Reply | Threaded
Open this post in threaded view
|

Re: Default Posix thread stack size

Valery Masiutsin
> I usually have:
>
> #ifdef __OpenBSD__
>     size_t stacksize;
>     pthread_attr_getstacksize(&attr, &stacksize);
>     pthread_attr_setstacksize(&attr, stacksize * 2);
> #endif
>
> in my threaded stuff.
>
Hello.

AFAIK Posix says nothing about default thread stack.
So you  should use pthread_attr_setstacksize most of the times.

Regards Valery