srinivasansreedharan
Junior Member level 3
If a C program contains no recursion or reentrancy, the call stack is not actually needed.In other words, stack-allocated variables can be turned into global variables (by the compiler) when there is no possibility that more than one instance of a function may be running at a time. Even though turning stack variables into globals would increase the speed of code (the overhead of manipulating the stack would disappear), and it would eliminate the possibility of stack over ow, all embedded compilers generate code that uses a stack. Explain why. In other words, what specic benets are gained through stack-based memory allocation?