Default stack size

What is the default stack size in 6.3.1?
Can it be made dynamic? What are the pitfalls?

Regards,

Francois

Francois Joubert <sommerfj@webmail.co.za> wrote:

What is the default stack size in 6.3.1?

There is no 6.3.1.

But, I don’t think this has changed in any 6.3.0 release.

The default maximum stack size for the first thread in the process is
512K, the default maximum stack size for any further threads is 128K.

Can it be made dynamic? What are the pitfalls?

By default, the stack is dynamic – it will grow on demand until
it hits the maximum size. The size of the first stack can be
modified by a link-time flag (-N IIRC), the size of the subsequent
threads’ stacks can be modified at thread creation time with
pthread_setstacksize().

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

David Gibbswrote:
Francois Joubert <> sommerfj@webmail.co.za> > wrote:
What is the default stack size in 6.3.1?

There is no 6.3.1.

But, I don’t think this has changed in any 6.3.0 release.

The default maximum stack size for the first thread in the process is
512K, the default maximum stack size for any further threads is 128K.

Can it be made dynamic? What are the pitfalls?

By default, the stack is dynamic – it will grow on demand until

it hits the maximum size. The size of the first stack can be
modified by a link-time flag (-N IIRC), the size of the subsequent
threads’ stacks can be modified at thread creation time with
pthread_setstacksize().

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com[/quote:6fb5d0f075]

Is it possible to control how the initial thread in process handles
it’s stack allocation, I know that subsquent threads can be forced to
allocate their entire stack upfront using the
pthread_attr_setstacklazy() function. Can these be done for the
initial thread ?

William

You can set the initial thread’s stacksize and whether it is lazy or not with the ldrel utility.

For example, a 2Mb stack that is lazily allocated -

ldrel -S2M -L executable

You can omit the -L option to set a non-lazy stack.

whoey wrote:

David Gibbswrote:
Francois Joubert <> sommerfj@webmail.co.za> > wrote:
What is the default stack size in 6.3.1?

There is no 6.3.1.

But, I don’t think this has changed in any 6.3.0 release.

The default maximum stack size for the first thread in the process is
512K, the default maximum stack size for any further threads is 128K.

Can it be made dynamic? What are the pitfalls?

By default, the stack is dynamic – it will grow on demand until
it hits the maximum size. The size of the first stack can be
modified by a link-time flag (-N IIRC), the size of the subsequent
threads’ stacks can be modified at thread creation time with
pthread_setstacksize().

-David

Colin Burgess wrote:

You can set the initial thread’s stacksize and whether it is lazy or not
with the ldrel utility.

For example, a 2Mb stack that is lazily allocated -

ldrel -S2M -L executable

You can omit the -L option to set a non-lazy stack.

What does “lazy” mean, for the stack?

Is a lazy stack allocated page-by-page only when needed?

And is a non-lazy stack preallocated on startup with its max size?

There’s a way to make the stack being non-lazy at link-time?

Davide


/* Ancri Davide - */

Davide Ancri wrote:

Colin Burgess wrote:
You can set the initial thread’s stacksize and whether it is lazy or
not with the ldrel utility.

For example, a 2Mb stack that is lazily allocated -

ldrel -S2M -L executable

You can omit the -L option to set a non-lazy stack.

What does “lazy” mean, for the stack?

Is a lazy stack allocated page-by-page only when needed?

Yes, for a lazy stack only the virtual memory is pre-allocated. Additional pages of
physical memory are allocated on an on-demand basis.

And is a non-lazy stack preallocated on startup with its max size?

Correct.

There’s a way to make the stack being non-lazy at link-time?

No. There is no way to pass args to ldrel via qcc other than the size.