next up previous
Next: 3.2 Stack Up: 3 Components of a Previous: 3 Components of a

3.1 Text and Data Areas

Processes which are statically linked are born with their entire text loaded into virtual memory by the kernel, generally beginning at address 0. Since we use exactly the same executable file for both the original invocation and when restarting a process, we don't have to do anything special to save and restore the text. (Note that modern programming practice requires that text be loaded ``read-only'', so there is no chance that the text will be modified at run time.)

The ``data'' space of a UNIX process generally consists of 3 areas - initialized data, uninitialized data, and the heap. Initialized data is that data given values by the programmer at compile time. Uninitialized data is space allocated at compile time, but not given values by the programmer (the kernel will zero fill this area at load time). The heap is data allocated at run time by the brk() or sbrk() system calls (these are the system calls which underlie malloc()). A process's data generally begins at some pagesize boundary above the text, and is a contiguous area of memory. That is, the initialized data begins at the first pagesize boundary above the text, the uninitialized data comes next, followed by the heap which grows toward higher addresses at run time. Note that once the process begins execution, the initialized data may be overwritten, and thus at restart time, we cannot depend on the information in the executable file for this area. Instead the entire data segment is written to the checkpoint file at checkpoint time, and read into the address space at restart time. All one needs to know to accomplish this are the starting and ending addresses of the data segment.