3 ms·
> It is not correct to say that the stack is "not resizable." While the default stack size is set by the operating system, many programming languages and operat
by telotortium 4y ago
> It is not correct to say that the stack is "not resizable." While the default stack size is set by the operating system, many programming languages and operating systems allow you to specify the stack size when creating a new thread. However, it is true that once a thread has been created, its stack size typically cannot be changed.
Seems like a typical confused/pendantic Stack Overflow answer. I would say that stack size is "configurable", but not "resizable", because you indeed can't change the stack size (down, at least) of an already-created OS thread.
- titzer 4y agoYou can create pthreads with manually allocated stack segments and resize them later. https://www.ibm.com/docs/en/zos/2.2.0?topic=functions-pthread-attr-setstack-set-stack-attribute https://www.ibm.com/docs/en/zos/2.2.0?topic=functions-pthrea...
- telotortium 4y agoDoes that actually resize the stack in a way that the C runtime will recognize (e.g., add a guard page, making the stack size available to future calls of `pthread_getattr_get_np`)? I guess you'd only resize the stack yourself if your code was planning on somehow keeping track of the stack size, so I suppose it's not too big of a concern, but still.
- gpderetta 4y agoThe only way to resize the segment is mapping in pages at the end of the original stack, and that only works if you were careful and arranged for virtual space to be reserved and available at the end. And the only robust way to do that is to map something in. At that point might as well assign the space to the stack from the beginning. To