Call Stack - Structure

Structure

A call stack is composed of stack frames (also called activation records or activation frames). These are machine dependent and ABI-dependent data structures containing subroutine state information. Each stack frame corresponds to a call to a subroutine which has not yet terminated with a return. For example, if a subroutine named DrawLine is currently running, having been called by a subroutine DrawSquare, the top part of the call stack might be laid out like this:

A diagram like this can be drawn in either direction as long as the placement of the top, and so direction of stack growth, is understood. Furthermore, independently of this, architectures differ as to whether call stacks grow towards higher addresses or towards lower addresses. The logic of the diagram is independent of the addressing choice.

The stack frame at the top of the stack is for the currently executing routine. The stack frame usually includes at least the following items (in push order):

  • the arguments (parameter values) passed to the routine (if any);
  • the return address back to the routine's caller (e.g. in the DrawLine stack frame, an address into DrawSquare's code); and
  • space for the local variables of the routine (if any).

Read more about this topic:  Call Stack

Famous quotes containing the word structure:

    Man is more disposed to domination than freedom; and a structure of dominion not only gladdens the eye of the master who rears and protects it, but even its servants are uplifted by the thought that they are members of a whole, which rises high above the life and strength of single generations.
    Karl Wilhelm Von Humboldt (1767–1835)

    Agnosticism is a perfectly respectable and tenable philosophical position; it is not dogmatic and makes no pronouncements about the ultimate truths of the universe. It remains open to evidence and persuasion; lacking faith, it nevertheless does not deride faith. Atheism, on the other hand, is as unyielding and dogmatic about religious belief as true believers are about heathens. It tries to use reason to demolish a structure that is not built upon reason.
    Sydney J. Harris (1917–1986)

    With sixty staring me in the face, I have developed inflammation of the sentence structure and definite hardening of the paragraphs.
    James Thurber (1894–1961)