A program and a process are related terms. The major difference between program and process is that program is a set of instructions to perform a designated task whereas the process is a program in execution. A process is an active entity while a program is a passive entity.
There exist a many-to-one relationship between process and program, which means one program can invoke multiple processes or in other words multiple processes can be a part of the same program.
Content: Program Vs Process
|Basis for comparison||Program ||Process|
|Basic ||Program is a set of instruction.||Process is the program in execution.|
|Required resources||Program is stored on disk in some file and does not require any other resources.||Process holds resources such as CPU, memory address, disk, I/O etc.|
Definition of Program
A Program, in simple words, can be considered as a system activity. In batch processing system these are called executing jobs while in a real-time operating system it is called tasks or programs. A user can run multiple programs where the operating system facilitates its own internal programmed activities such as memory management using some techniques.
A program is a passive entity, for example, a file containing a group of instructions to be executed (executable file). It is so called because it doesn’t perform any action by itself, it has to be executed to realize the actions specified in it.
The instruction, data and stack of program constitute its address space. Assume P is the program we are writing, to realize execution of P, the operating system allocates memory to accommodate P’s address space. It schedules P for execution and also sets up an arrangement through which p can access file info. The CPU is shown in the dashed box because it is not always executing instructions of P; in fact, OS shares the CPU between the execution of P and executions of other programs.
Definition of Process
A Process is an execution of a program. It is considered as an active entity and realizes the actions specified in a program. Multiple processes can be associated with the same program. It handles the operating system activities through PCB (Process control Block) which includes program counter, stack, state etc. Program counter stores the next sequence of instruction to be executed.
It needs resources like processing, memory and I/O resources to accomplish management tasks. During the execution of a program, it could engage processor or I/O operation that makes a process different from a program.
Let us understand this from an example; we are writing a C program. While writing and storing a program in a file, it is just a script and does not perform any action, but when it is executed it turns into process hence process is dynamic in nature. Current machines enable several processes to share resources, but in actual one processor is shared among many processes.
Key Differences Between Program and Process
- A program is a specific set of ordered operations that are to be performed. On the other hand, a process is an instance of a program being executed.
- The nature of the program is passive as it does nothing until it gets executed whereas a process is dynamic or active in nature as it is an instance of executing program and perform the specific action.
- A program has a longer lifespan because it is stored in the memory until it is not manually deleted while a process has a shorter and limited lifespan because it gets terminated after the completion of the task.
- The resource requirement is much higher in case of a process; it could need processing, memory, I/O resources for the successful execution. In contrast, a program just requires memory for storage.
Program and process are relevant but are dissimilar. A program is just a script stored on disk or seem to as the previous stage of the process. On the contrary, the process is an instance of a program in execution.