Stack Attributes
In POSIX 1003.1c-compliant systems, support for user specification of stack attributes is optional. Linux POSIX supports control for a system-managed stack, and supports user-managed stacks.
The stacks for threads are allocated high in memory with the “grow on demand” flag set and spaced 2 MB apart. This means that they start off small (about 4 KB) and grow to 2 MB. However, the entire 2 MB space is reserved for the stack, which means that mapping something into a fixed address space could cause later growth of the stack to fail. On our test machine with 256 MB RAM and 256 MB swap space, we found that the maximum number of threads that could be created using only pthread_create() was about 230 threads.
The creators of Linux POSIX recommend that you not set stack attributes unless you have strong reasons for doing so, since they believe that the above stack allocation strategy is nearly optimal, and that resetting the stack size may result in nonportable and less reliable programs.