In this chapter, we look at the structure of a process, paying particular attention to the layout and contents of a process’s virtual memory. We also examine some of the attributes of a process. In later chapters, we examine further process attributes (for example, process credentials in Chapter 9, and process priorities and scheduling in Chapter 35). In Chapter 24 to Chapter 27, we look at how processes are created, how they terminate, and how they can be made to execute new programs.
A process is an instance of an executing program. In this section, we elaborate on this definition and clarify the distinction between a program and a process.
A program is a file containing a range of information that describes how to construct a process at run time. This information includes the following:
Binary format identification: Each program file includes metainformation describing the format of the executable file. This enables the kernel to interpret the remaining information in the file. Historically, two widely used formats for UNIX executable files were the original a.out (“assembler output”) format and the later, more sophisticated COFF (Common Object File Format). Nowadays, most UNIX implementations (including Linux) employ the Executable and Linking Format (ELF), which provides a number of advantages over the older formats.
Machine-language instructions: These encode the algorithm of the program.
Program entry-point address: This identifies the location of the instruction at which execution of the program should commence.
Data: The program file contains values used to initialize variables and also literal constants used by the program (e.g., strings).
Symbol and relocation tables: These describe the locations and names of functions and variables within the program. These tables are used for a variety of purposes, including debugging and run-time symbol resolution (dynamic linking).
Shared-library and dynamic-linking information: The program file includes fields listing the shared libraries that the program needs to use at run time and the pathname of the dynamic linker that should be used to load these libraries.
Other information: The program file contains various other information that describes how to construct a process.
One program may be used to construct many processes, or, put conversely, many processes may be running the same program.
We can recast the definition of a process given at the start of this section as follows: a process is an abstract entity, defined by the kernel, to which system resources are allocated in order to execute a program.
From the kernel’s point of view, a process consists of user-space memory containing program code and variables used by that code, and a range of kernel data structures that maintain information about the state of the process. The information recorded in the kernel data structures includes various identifier numbers (IDs) associated with the process, virtual memory tables, the table of open file descriptors, information relating to signal delivery and handling, process resource usages and limits, the current working directory, and a host of other information.