Process Image

Executable files are stored in a defined format on the disk, different operating systems may have different definitions for the actual format but there are generally common elements in the way they are stored. A format commonly used on Unix systems such as Linux is called Extensible Linked Format (ELF). An ELF programme consists of an ELF header, a program header table, a number of sections and an optional section header table. The header contains all the information the kernel needs to create a process image (i.e. load the programme into memory and allocate resources to prepare it for execution).

Programme code on a multitasking operating system must be re-entrant. This means it can be shared by multiple processes. To be re-entrant the code must not modify itself at any time and the data must be stored separately from the instruction text (such that each independent process can maintain its own data space).

When a programme is loaded as a process it is allocated a section of virtual memory which forms its useable address space. Within this process image there are typically at least four elements :

Program code (or text) | The program instructions to be executed. Note that it is not necessary for the processor to read the totality of a process into physical memory when a program is run, instead by a procedure known as ?dynamic paging? the next block of instructions is loaded as required and may be shared between processes.
Program data | May be distinguished as initialised variables including external global and static variables, uninitialised variables (known as a bss area on Unix derivative systems). Data blocks are not shared between processes by default.
Stack | A process will commonly have at least two last-in, first-out (LIFO) stacks, including a user stack for user mode and a kernel stack for kernel mode.
Process Control Block | Information needed by the operating system to control the process.