Difference Between Program and Process in Operating System (OS)
Program Vs Process in Operating System
- A program is a system activity that uses a set of instructions to perform a designated task.
- It is considered a passive entity as it resides on secondary memory.
- The resource requirement is less as it only requires memory for storage.
- The program performs tasks that are directly related to the operations of a user.
For example, notepad.exe is an executable file having a set of instructions that helps users to print and edit text files. When the user executes the program, it converts into the process.
- A process is an executing instance of a program.
- In other words, the process is a program in execution
- A process is entirely dependent on the program
- It is considered an active entity as it resides on the primary memory. (RAM)
- It requires resources like processing, memory address, CPU, input and output resources to perform the task.
For example, a user can run multiple instances of Microsoft Word program.
Difference between Program and Process
|A program is a set of instructions, written to complete some task||A process is a program in execution|
|A program is a passive/static entity||A process is an active/dynamic entity|
|A program resides in secondary memory. (Internal/external storage Disks)||A process is currently executing thus has to be in Primary Memory (RAM)|
|A program has a longer life span. It is stored on the hard disk in the computer.||A process has a limited life span. It is created when execution starts and terminates when execution is finished|
|A program only requires memory space to store itself||A process needs execution time in CPU, I/O requirements, shared resources, files, memory addresses and others|
|There is no Control Block in program||Process has its own control block called as Process Control Block (PCB)|
|A Program can not change it by itself||Many Processes can be working/using same program and change the program in realtime. This is why we need concurrency make sure critical section of program are not changed.|
|Code and data(files) are the only two logical components of a program||Process needs program data, priority, resources, process management, execution strategy chosen by CPU and many other things|
|Program doesn’t have any significant overhead||Process generally has a significant overhead|
|New processes require|
duplication of the parent process.
|No such duplication is needed.|
- Banker’s Algorithm
- bankers algorithm for deadlock avoidance in c (in above post itself)Resource Allocation Graph (RAG)
- Dining Philosopher’s Problem
- Bounded Buffer Problem / Producer Consumer Problem
- User Level thread Vs Kernel Level thread
- Multithreading models
- Difference between program and process