Stack and stack size

Source: Internet
Author: User

The executing program maintains a master stack for the initial (or primary) thread that executes the program, and maintains a different stack for each dependent thread. A stack is a temporary memory address space that retains parameters and automatic variables during a subroutine or function reference call. If the size of the thread stack is too small, a stack overflow may occur, resulting in a silent data corruption or segment failure.

Compiling a Fortran program with the f95 -stackvar option forces local variables and arrays to be allocated on the stack as if they were automatic variables. An explicit parallelization program implies the use of -stackvarfor OpenMP programs, because this option increases the ability of the optimizer to parallelize calls in the loop. (For a discussion of the -stackvar flag, see the Fortran User Guide .) However, if there is not enough memory allocated for the stack, the use causes a stack overflow.

Use the limit C-shell command or the ulimit Bourne or Korn shell command to display or set the stack size of the initial thread (or the main course). Typically, the default stack size for the initial thread is 8 MB.

Each subordinate thread of an OpenMP program has its own thread stack. This stack simulates the initial (or main) thread stack, but is unique to the thread. The PRIVATE array of threads and variables (for threads that are local) are allocated in the thread stack. On 32-bit SPARC V8 and x86 platforms, the default size is 4 MB, and on 64-bit SPARC V9 and x86 platforms, the default size is 8 MB. The size of the slave thread stack is set by the omp_stacksize environment variable.

Stack and stack size

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.