- 论坛徽章:
- 0
|
少数系统支持运行期修改进程本身的stack大小:
sstk(2) - Linux man page
Name
sstk - change stack size
Synopsis
caddr_t sstk(int incr);
Description
(From the 4.3BSD Architecture Manual)
Each process begins execution with three logical areas of memories called text, data and stack. The text area is read-only and shared, while the data and stack areas are private to the process. Both the data and stack areas may be extended and contracted on program request. The call
caddr_t addr = sbrk(incr);
changes the size of the data area by incr bytes and returns the new end of the data area, while
caddr_t addr = sstk(incr);
changes the size of the stack area. The stack area is also automatically extended as needed. On the VAX the text and data areas are adjacent in the P0 region, while the stack section is in the P1 region, and grows downward.
Note
This call is not supported in 4.3BSD or 4.4BSD or glibc or Linux or any other known Unix-like system. Some systems have a routine of this name that returns ENOSYS.
See Also
sbrk(2)
linux系统下,运行期修改ulimit -s将影响之后创建的线程/进程,但不能修改当前进程的栈大小:
"On Linux/x86-32, the default stack size for a new thread is 2 megabytes", Unless the RLIMIT_STACK resource limit (ulimit -s) is set: in that case, "it determines the default stack size of new threads". |
|