Results 1 to 7 of 7

Thread: little confused about the memory stack thing

  1. #1
    Join Date
    Jul 2009
    Beans
    850
    Distro
    Ubuntu Development Release

    Question little confused about the memory stack thing

    so, im in the process of learning bout memory, cpu registers, all those treats I am, however, stumped on the concept of the stack. I went and read this and i think that i understood a bunch of it, but still stuck. So, i have a couple questions:

    Is all memory in a stack?
    Is a stack purely a 'concept' or a way of looking at the data, or is it really there in RAM? I got the impression that it was more a way of looking at the memory, but like i said, im confused

    Hope i put this in the right place......please by kind and move it if i didnt

    Thanks for any replies!
    "Microsoft Windows: A collection of 32bit extensions and a graphical shell for a 16bit patch to an 8bit O.S. originally coded for a 4bit microprocessor written by a 2bit company who cant stand 1 bit of competition." Jargon File 4.4.7

  2. #2
    Join Date
    Jan 2009
    Location
    MA
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: little confused about the memory stack thing

    A Stack is a data structure in memory that lets you do operations like push and pop. So, yeah, its a way of "looking at the data". The stack is implemented by a program in memory.

  3. #3
    Join Date
    Jul 2009
    Beans
    850
    Distro
    Ubuntu Development Release

    Re: little confused about the memory stack thing

    Quote Originally Posted by whiskeylover View Post
    A Stack is a data structure in memory that lets you do operations like push and pop. So, yeah, its a way of "looking at the data". The stack is implemented by a program in memory.
    thanks, sorry to be a pain, but does that mean all (used) memory can be 'seen' using the stack concept? So, is there any part of memory that doesnt use a stack?
    "Microsoft Windows: A collection of 32bit extensions and a graphical shell for a 16bit patch to an 8bit O.S. originally coded for a 4bit microprocessor written by a 2bit company who cant stand 1 bit of competition." Jargon File 4.4.7

  4. #4
    Join Date
    Jan 2009
    Location
    MA
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: little confused about the memory stack thing

    No. Simply put, a program is allocated memory by the OS. The program can then choose to create anything inside it (including as many stack objects as possible.)

    I suggest you pick up a good book on data structures.

  5. #5
    Join Date
    Dec 2006
    Beans
    217

    Re: little confused about the memory stack thing

    It is a concept, the hardware section talks about how it's implemented in hardware and then that some chips have a stack implemented in hardware (e.g you send it an electrical signal to put in an item or you send one to get it out and the hw behaves like a stack.

  6. #6
    Join Date
    Jan 2008
    Beans
    1,532

    Re: little confused about the memory stack thing

    A stack is a way of structuring data. Stacks can be created and used by programmers in source code, but that isn't the same thing as the architecture's concept of the stack.

    Each application has a stack that it uses to store local variables (variables that only exist in one function) and other things. When your program calls a function, that functions arguments and locals get pushed onto the stack, and when it returns, they are popped back off.

    Not all memory is a stack. There is also a global portion for storing globals, constants, and static variables; and an area called the "heap" which is used to store things that are allocated dynamically with malloc or new. There is also the memory that actually holds the executing program instructions which is called the text segment.

  7. #7
    Join Date
    Jul 2009
    Beans
    850
    Distro
    Ubuntu Development Release

    Re: little confused about the memory stack thing

    Quote Originally Posted by Simian Man View Post
    A stack is a way of structuring data. Stacks can be created and used by programmers in source code, but that isn't the same thing as the architecture's concept of the stack.

    Each application has a stack that it uses to store local variables (variables that only exist in one function) and other things. When your program calls a function, that functions arguments and locals get pushed onto the stack, and when it returns, they are popped back off.

    Not all memory is a stack. There is also a global portion for storing globals, constants, and static variables; and an area called the "heap" which is used to store things that are allocated dynamically with malloc or new. There is also the memory that actually holds the executing program instructions which is called the text segment.
    ahhh ok thank you very much, this was very helpful
    "Microsoft Windows: A collection of 32bit extensions and a graphical shell for a 16bit patch to an 8bit O.S. originally coded for a 4bit microprocessor written by a 2bit company who cant stand 1 bit of competition." Jargon File 4.4.7

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •