<blockquote>
<p>How come the stack cannot be increased during runtime in most operating system?</p>
</blockquote>
<p>This is wrong for Linux. On recent Linux systems, each thread has its own <a href="https://en.wikipedia.org/wiki/Call_stack" rel="noreferrer">call stack</a> (see <a href="https://man7.org/linux/man-pages/man7/pthreads.7.html" rel="noreferrer">pthreads(7)</a>), and an application could (with clever tricks) increase some call stacks using <a href="https://man7.org/linux/man-pages/man2/mmap.2.html" rel="noreferrer">mmap(2)</a> and <a href="https://man7.org/linux/man-pages/man2/mremap.2.html" rel="noreferrer">mremap(2)</a> after querying the call stacks thru <code>/proc/</code> (see <a href="https://man7.org/linux/man-pages/man5/proc.5.html" rel="noreferrer">proc(5)</a> and use <code>/proc/self/maps</code>) like e.g. <a href="https://man7.org/linux/man-pages/man1/pmap.1.html" rel="noreferrer">pmap(1)</a> does.</p>
<p>Of course, such code is architecture specific, since in some cases the call stack grows towards increasing addresses and in other cases towards decreasing addresses.</p>
<p>Read also <a href="http://pages.cs.wisc.edu/%7Eremzi/OSTEP/" rel="noreferrer"><em>Operating Systems: Three Easy Pieces</em></a> and the <a href="https://www.osdev.org/" rel="noreferrer">OSDEV</a> wiki, and study the source code of <a href="https://www.gnu.org/software/libc/" rel="noreferrer">GNU libc</a>.</p>
<p>BTW, Appel's book <a href="https://www.cambridge.org/core/books/compiling-with-continuations/7CA9C36DCE78AD82218E745F43A4E740" rel="noreferrer"><em>Compiling with Continuations</em></a>, his old paper <a href="https://www.cs.princeton.edu/%7Eappel/papers/45.pdf" rel="noreferrer"><em>Garbage Collection can be faster than Stack Allocation</em></a> and this paper on <a href="https://arxiv.org/pdf/1805.08842.pdf" rel="noreferrer"><em>Compiling with Continuations and LLVM</em></a> could interest you, and both are very related to your question: sometimes, there is almost &quot;no call stack&quot; and it makes no sense to &quot;increase it&quot;.</p>
How come the stack cannot be increased during runtime in most operating system?
<p>Is it to avoid fragmentation? Or some other reason? A set lifetime for a memory allocation is a pretty useful construct, compared to <code>malloc()</code> which has a manual lifetime.</p>