Program code and data . Code begins at the same fixed address, followed by data locations that
correspond to global C variables. The code and data areas are initialized directly from the contents of
an executable object file, in our case the hello executable. We will learn more about this part of the
address space when we study linking and loading in Chapter 7.
Heap. The code and data areas are followed immediately by the run-time heap. Unlike the code and
data areas, which are fixed in size once the process begins running, the heap expands and contracts
dynamically at runtime as a result of calls to C standard library routines such as malloc and free.
We will study heaps in detail when we learn about managing virtual memory in Chapter 10.
Shared libraries. Near the middle of the address space is an area that holds the code and data for
shared libraries such as the C standard library and the math library. The notion of a shared library
is a powerful, but somewhat difficult concept. We will learn how they work when we study dynamic
linking in Chapter 7.
Stack. At the top of the user’s virtual address space is the user stack that the compiler uses to implement
function calls. Like the heap, the user stack expands and contracts dynamically during the execution

of the program. In particular, each time we call a function, the stack grows. Each time we
return from a function, it contracts. We will learn how the compiler uses the stack in Chapter 3.
Kernel virtual memory. The kernel is the part of the operating system that is always resident in
memory. The top 1/4 of the address space is reserved for the kernel. Application programs are not
allowed to read or write the contents of this area or to directly call functions defined in the kernel
code.

Logo

更多推荐