various phases through which the execution of process happens throughout its life.
Major states are
- new - a state when newly created . start point where the process is not in RAM, PID is created, memory is allocated.
- running- here the scheduler selects processes to run. A process in which the instruction get executed by CPU. here context switching happens as there are multiple programs wanting to execute. from here processes can either go in terminated state or blocked state.
- Ready - in the state where it is waiting for execution by CPU and loaded in the memory. the processes are here in the READY QUEUE.
- blocked(waiting) - where process is waiting for an event or IO operation to complete. here the processes which are IO bound come.
- terminated- process completing their cycles.
- swapout
*A data structure maintained by operating system to store all the information related to process
Suppose your computer is running:
- Chrome
- VS Code
- Spotify
- Terminal
Question:
How does OS remember:
Which process was running?
Which process should run next?
Where did a process stop?
How much memory does each process have?
Imagine CPU says:
“I paused Chrome. But now I forgot where Chrome stopped.”
Disaster.
Chrome would restart from beginning every time.
So OS needs a way to remember:
Everything about every running process.
This memory record is called:
PCB (Process Control Block)*
PCB is stored in:
Kernel Space (Main Memory/RAM)
Why?
Because OS frequently needs it for:
- scheduling
- process switching
- memory management
It must be quickly accessible.
Very important question.
PCB gets created:
When process enters New State
Meaning:
When process is created,
OS automatically creates PCB.
And when process terminates:
PCB gets deleted.
This is the most important part.
You must understand each field deeply.
A unique number assigned to each process.
Example:
Chrome → PID 2051VS Code → PID 3010Spotify → PID 4102
Why needed?
Because OS must identify processes uniquely.
Like:
Roll number in college.
Stores:
Current state of process.
Example:
ReadyRunningWaitingTerminated
Why needed?
OS must know:
Which process currently doing what.
Example:
If process is:
WAITING
Scheduler will not give CPU.
Very important field.
Stores:
Address of next instruction to execute.
Question:
Why needed?
Suppose Chrome paused.
When resumed:
OS must know:
“Execution kaha se continue karna hai?”
Example:
1. a = 5;2. b = 10;3. c = a+b;
Suppose paused after line 2.
Program Counter remembers:
Next = line 3
Otherwise process restarts.
Stores temporary execution data.
Remember:
Registers are:
Fast memory inside CPU.
During process switching:
OS saves register values into PCB.
Why?
Because process may resume later.
Without saving:
Calculations lost.
Contains:
- priority
- queue info
- scheduling parameters
Example:
Priority = High
Scheduler uses this.
To decide:
Who gets CPU first?
Stores:
- memory location
- base address
- limit registers
- page table
Meaning:
OS remembers:
Process memory kaha hai?
Without this:
Memory chaos.
Stores:
- open files
- devices being used
- I/O requests
Example:
Chrome downloading file.
PCB records:
Disk access active
Stores:
- CPU usage
- execution time
- limits
Used for:
Performance tracking.
Billing in servers/cloud.
Important diagram for exams.
--------------------------------| Process ID (PID) |--------------------------------| Process State |--------------------------------| Program Counter |--------------------------------| CPU Registers |--------------------------------| Scheduling Information |--------------------------------| Memory Information |--------------------------------| I/O Status Information |--------------------------------| Accounting Information |--------------------------------
Understand the logic.
PCB contains:
Everything OS needs to manage process.