What happens when a computer program runs?

Posted by gaijinco on Stack Overflow See other posts from Stack Overflow or by gaijinco
Published on 2011-03-02T01:50:26Z Indexed on 2011/03/03 23:24 UTC
Read the original article Hit count: 200

Filed under:
|
|
|
|

I know the general theory but I can't fit in the details.

I know that a program resides in the secondary memory of a computer. Once the program begins execution it is entirely copied to the RAM. Then the processor retrive a few instructions (it depends on the size of the bus) at a time, puts them in registers and executes them.

I also know that a computer program uses two kinds of memory: stack and heap, which are also part of the primary memory of the computer. The stack is used for non-dynamic memory, and the heap for dynamic memory (for example, everything related to the new operator in C++)

What I can't understand is how those two things connect. At what point is the stack used for the execution of the instructions? Instructions go from the RAM, to the stack, to the registers?

© Stack Overflow or respective owner

Related posts about c++

Related posts about memory