2.1.1. Process And Thread Concepts

An obvious function of a computer is executing programs. A program is a sequence of instructions that tell the computer what to do. When a computer executes a program, it keeps track of the position of the currently executing instruction within the program and of the data the instructions of the program use. This gives rise to the concept of a process as an executing program, consisting of the program itself and of the execution state that the computer keeps track of.

The abstract notions of program and state are backed by concrete entities. The program is represented as machine code instructions, which are stored as numbers in memory. The machine code instructions manipulate the state, which is also stored as numbers, either in memory or in registers.

It is often useful to have several processes cooperate. A cooperation between processes requires communication, which may be cumbersome when each process has a completely distinct program and a completely distinct state - the programs have to be kept compatible and the information about the state must be exchanged explicitly. The need to simplify communication gives rise to the concept of threads as activities that share parts of program and parts of state within a process.

The introduction of threads redefines the term process. When speaking about processes alone, the term process is used to refer to both the program and state as passive entities and the act of execution as an active entity. When speaking about processes and threads together, the term process is used to refer to the program and state as a passive entity and the term thread is used to refer to the act of execution as an active entity. A process is a passive shell that contains active threads executing within it.