A program and a process are related terms. The major difference between program and process is that program is a group of instructions to carry out a specified task whereas the process is a program in execution. While a process is an active entity, a program is considered to be a passive one.
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
Comparison Chart
Basis for comparison | Program | Process |
---|---|---|
Basic | Program is a set of instruction. | When a program is executed, it is known as process. |
Nature | Passive | Active |
Lifespan | Longer | Limited |
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 accommodating 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 address space of a program is composed of the instruction, data and stack. 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 related to 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 that is to be executed later.
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. Sharing of resources among multiple processes is employed by current machines, but in actual a single processor is distributed among several processes.
Key Differences Between Program and Process
- A program is a definite group of ordered operations that are to be performed. On the other hand, an instance of a program being executed is a process.
- 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.
Conclusion
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 event of a program in execution.
Sunil says
Nice
Jessica Wintory says
This helped clear a lot of confusion. Thank you.
MD ASLAM KHAN says
This was really helpful. Thank you
Ravi says
Simple and good explanation. Thanks
Shivam Chaurasia says
Thank you so much
Zelalem says
Thanks
SM Bishal says
They use very clear and natural English,
Anybody can understand this topic.
It has simplified learning.
Thank you “Script Writer”
Sanjay Godara says
Thanks. Cleared my blurry perception of process and program
Aaron says
Excellent!A lot of help!
Sujeet says
THANKS, A LOT
It makes me understand the concept in which i was confused before..
Mattjoe says
Thank you very much for this…
kartik says
thanks a lot