The question about the definition of the term "heap" in memory layer - Minix

This is a discussion on The question about the definition of the term "heap" in memory layer - Minix ; Hello guys. I'm newbie in OS.(Also, I'm not good at typing English) I have a question about the definition of the term "heap". Some people say that heap is initialized by values stored in the program's binary file. In the ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: The question about the definition of the term "heap" in memory layer

  1. The question about the definition of the term "heap" in memory layer

    Hello guys.

    I'm newbie in OS.(Also, I'm not good at typing English) I have a
    question about the definition of the term "heap". Some people say that
    heap is initialized by values stored in the program's binary file. In
    the contrast, the others say that heap is dynamically allocated by
    program which is running. I have confused.

    What definition is right?


  2. Re: The question about the definition of the term "heap" in memory layer

    advanced wrote:
    > I'm newbie in OS.(Also, I'm not good at typing English) I have a
    > question about the definition of the term "heap". Some people say that
    > heap is initialized by values stored in the program's binary file. In
    > the contrast, the others say that heap is dynamically allocated by
    > program which is running. I have confused.
    >
    > What definition is right?


    The second.

    An application's memory consists of two segments, one for code and one for
    data. The code segment contains read-only machine code. The data segment
    contains:

    * rodata --- read only data, statically allocated at compile time, and
    initialised from the executable file. (Minix doesn't enforce this as
    being read-only, as far as I know, but other systems do.)
    * data --- modifiable data, statically allocated at compile time, and
    initialised from the executable file.
    * bss --- modifiable data, statically allocated at compile time, and
    initialised to zero.
    * heap --- modifiable data, dynamically allocated at run time, and not
    initialised.

    There's also the stack, which is used for local variables and compiler
    housekeeping. This goes in the heap segment but is allocated in a different
    way.

    Example:

    const int i1 = 1; /* goes in the rodata area */
    int i2 = 1; /* goes in the data area */
    int i3; /* goes in the bss area */

    {
    int* p1 = malloc(4); /* goes in the heap
    (but the pointer itself is on the stack) */
    }

    The size of all these areas except the heap are set by the compiler when you
    compile the program. The size of the heap, however, can be changed using
    the 'chmem' command (when the program's not running. Minix doesn't support
    making the heap bigger for a running program; Linux, BSD, etc do).

    Does this help?

    --
    +- David Given --McQ-+ "I concluded from the beginning that this would be
    | dg@cowlark.com | the end; and I am right, for it is not half over
    | (dg@tao-group.com) | yet." --- Sir Boyle Roche
    +- www.cowlark.com --+

  3. Re: The question about the definition of the term "heap" in memory layer

    Thank you for detailed description.
    Your description is very helpful to me.


  4. Re: The question about the definition of the term "heap" in memory layer

    Thanks you for detailed description.
    Your description is very helpful to me.


+ Reply to Thread