What is a Process?
A process is a program that is currently being executed. It contains program code, data, memory, and other resources required for execution.
Program vs Process
| Program | Process |
|---|---|
| Passive entity | Active entity |
| Stored on disk | Stored in memory |
| Static | Dynamic |
Process States
A process generally passes through the following states:
- New – Process is being created.
- Ready – Waiting for CPU allocation.
- Running – Instructions are being executed.
- Waiting – Waiting for an event or I/O operation.
- Terminated – Process execution is completed.
Process Control Block (PCB)
PCB is a data structure maintained by the Operating System that stores information about a process.
- Process ID
- Process State
- Program Counter
- CPU Registers
- Memory Information
CPU Scheduler
The CPU Scheduler selects a process from the ready queue and allocates CPU time to it.
Context Switching
Context Switching is the process of saving the state of one process and loading the state of another process so that CPU execution can continue smoothly.