[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


3.4 Stack Management

DECthreads sets a default stack size that is acceptable to most applications. You can also use the stacksize attribute to specify the stack size needed by any thread. This section discusses the cases in which the stack size is insufficient (resulting in stack overflow) and how to determine the optimal size of the stack.

Most VAX compilers do not probe the stack. Portable code that supports threads should use as little stack memory as practical. Most compilers on Alpha systems generate code in the procedure prologue to probe the stack ensuring there is enough space for the procedure to run. DECthreads provides guard pages (no access memory at the end of each thread's stack) to allow a very fast and simple probe. If you create a thread that might need to allocate large arrays on the stack, create the thread using an attributes object that specifies a large guard size attribute. A large stack guard region can help to prevent one thread from overflowing into another thread's stack region.