 <blockquote> <p>Do all of the call stacks necessary for an application (if this is even possible to know) get allocated when the application gets launched?</p> </blockquote> <p>No. Typically, each thread's stack is allocated when that thread is created.</p> <blockquote> <p>Or do call stacks get allocated/de-allocated dynamically as applications spin off new threads?</p> </blockquote> <p>Yes.</p> <blockquote> <p>And if that is the case, (I know stacks have a fixed size), do the new stacks just get allocated right below the previous stacks-- So you would end up with a stack of stacks in the top addresses of memory? Or am I just fundamentally misunderstanding how call stacks are being created/used?</p> </blockquote> <p>It varies. But the stack just has to be at the top of a large enough chunk of available address space in the memory map for that particular process. It doesn't have to be at the very top. If you need 1MB for the stack, and you have 1MB, you can just reserve that 1MB and have the stack start at the top of it.</p> <blockquote> <p>How does the sp register work if there are multiple call stacks? Is it only used for the main call stack?</p> </blockquote> <p>A CPU has as many register sets as threads that can run at a time. When the running thread is switched, the leaving thread's stack pointer is saved and the new thread's stack pointer is restored -- just like all other registers.</p> <p>There is no "main thread of the OS". There are some kernel threads that do only kernel tasks, but also user-space threads also run in kernel space to run the OS code. Pure kernel threads have their own stacks somewhere in kernel memory. But just like normal threads, it doesn't have to be at the very top, the stack pointer just has to start at the highest address in the chunk used for that stack.</p>