Why a process stack?
We're taught to write nice modular code: divide your work into subroutines, and implement them as small, easily readable, and maintainable C functions. That's great.
The CPU, though, does not really understand how to invoke a C function, how to pass parameters, store local variables, and return a result to the calling function. Our savior, the compiler, takes over, converting C code into an assembly language that is capable of making this whole function thing work.
The compiler generates assembly code to invoke a function, passes along parameters, allocates space for local variables, and finally, emits a return result back to the caller. To do this, it uses the stack! So, similar to the heap, the stack is also a dynamic ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access