CPU scheduling by real life example
CPU scheduling is a process which allows one process to use the CPU while the execution of another process is on hold due to unavailability of any resource like I/O etc.
why CPU scheduling
Deciding which process/thread should occupy the resource (CPU, DISK, etc).The aim of CPU scheduling is to make the system efficient, fast and fair.
Different time in CPU scheduling
1. Arrival Time
The time at which process enter the ready queue or state.
Real life example —
Let’s say you go to the bank to deposit the money.
You enter the bank at 10 o’clock.
10 o’clock is your arrival time.
2. Burst Time (Duration time)
The time required by a process to get executed on CPU.
Real life example —
Actual time takes to deposit money to the cashier.
If the cashier takes 15 minutes to update your bank balance.
15 minutes is your Burst time.
3. Completion time
The time at which a process complete it’s execution.
Real life example —
Let’s assume you come out at 11 o’clock from the bank.
11 o’clock is your completion time.
4. TurnAround Time
The amount of time taken to execute the particular process.
Real life example —
Let’s say you enter the bank at 10 o’clock and exit at 11 o’clock.
You spend 1 hour inside the bank.
1 hour your turnaround time.
Turnaround time = (completion time - arrival time)
5. Waiting Time
the amount of time a process has been waiting in the ready queue.
Real life example —
Suppose you spend 1 hour inside the bank but your work is done in 15 minutes. 45 minutes is your waiting time.
Waiting Time = (turnaround time - burst time)
6. Response Time
The amount of time from when a request was submitted until the first response is produced.
Real life example —
When you get the cashier first time. That is your response time.
Response Time = (the time at which a process get the CPU first time - arrival time)
Thank for reading!
