Computer Organizations Unit 3 Process Scheduling
Computer Organizations Unit 3 Process Scheduling
Time-out
Medium Term
Scheduler
Event Wait
Event
Occurs Blocked Queue
Types of schedulers
Long-Term Scheduler Short-Term Scheduler Medium-Term Scheduler
It is a job scheduler. It is a CPU scheduler. It is a process swapping
scheduler.
It selects processes from It selects those processes It can re-introduce the
pool and loads them into which are ready to execute. process into memory and
memory for execution. execution can be continued.
Speed is lesser than short Speed is fastest among other Speed is in between both
term scheduler. two schedulers. short and long term
scheduler.
It is almost absent or It is also minimal in time It is a part of time sharing
minimal in time sharing sharing system. systems.
system.
Scheduling algorithms
1. First Come First Served (FCFS)
2. Shortest Job First (SJF)
3. Shortest Remaining Time Next (SRTN)
4. Round Robin (RR)
5. Priority
1. Preemptive
2. Non-Preemptive
First Come First Served (FCFS)
Selection criteria
• The process that request first is served first.
• It means that processes are served in the exact order of their
arrival.
Head P1 P2 Tail P3
Decision Mode
• Non preemptive: Once a process is selected, it runs until it is
blocked for an I/O or some other event or it is terminated.
Implementation:
• This strategy can be easily implemented by using FIFO (First In
First Out) queue.
• When CPU becomes free, a process from the first position in a
queue is selected to run.
First Come First Served (FCFS)
Example Process Arrival Time (T0) Time required for completion (∆T)
(CPU Burst Time)
P0 0 10
P1 1 6
P2 3 2
P3 5 4
Gantt Chart
P0 P1 P2 P3
0 10 16 18 22
First Come First Served (FCFS)
Process
Example
Arrival Time Burst Time Finish Time Turnaround Time Waiting Time
(T0) (∆T) (T1) (TAT = T1-T0) (WT = TAT-∆T)
P0 0 10 10 10 0
P1 1 6 16 15 9
P2 3 2 18 15 13
P3 5 4 22 17 13
Gantt Chart
P0 P1 P2 P3
0 10 16 18 22
Gantt Chart
P0 P2 P3 P1
0 10 12 16 22
Shortest Job First (SJF)
Process Arrival Time Burst Time Finish Time Turnaround Time Waiting Time
(T0) (∆T) (T1) (TAT = T1-T0) (WT = TAT-∆T)
P0 0 10 10 10 0
P1 1 6 22 21 15
P2 3 2 12 9 7
P3 5 4 16 11 7
Gantt Chart
P0 P2 P3 P1
0 10 12 16 22
Gantt Chart
P0 P1 P2 P1 P3 P0
0 1 3 5 9 13 22
ProcessProcess
Remaining
Process Time
Remaining
Remaining Time
Time Remaining
Process Process Time
Remaining Time
P1 P0 6 P0 9 9P0 9
P0 9
P0 P2 9 P1 2 4P3 4
P1 P3 4 4
Shortest Remaining Time Next (SRTN)
Process Arrival Time Burst Time Finish Time Turnaround Time Waiting Time
(T0) (∆T) (T1) (TAT = T1-T0) (WT = TAT-∆T)
P0 0 10 22 22 12
P1 1 6 9 8 2
P2 3 2 5 2 0
P3 5 4 13 8 4
Gantt Chart
P0 P1 P2 P1 P3 P0
0 1 3 5 9 13 22
P0 P1 P2 P0 P3 P1 P0
0 4 5 9 10 12 13 17 18 22 23 25 26 28
Gantt Chart (small values for priority means higher priority of a process)
P0 P3 P2 P1
0 10 14 16 22
Non Preemptive Priority Scheduling
Process Arrival Time Burst Time Finish Time Turnaround Time Waiting Time
(T0) (∆T) (T1) (TAT = T1-T0) (WT = TAT-∆T)
P0 0 10 10 10 0
P1 1 6 22 21 15
P2 3 2 16 13 11
P3 5 4 14 9 5
Gantt Chart (small values for priority means higher priority of a process)
P0 P3 P2 P1
0 10 14 16 22
Gantt Chart (small values for priority means higher priority of a process)
P0 P1 P2 P3 P1 P0
0 1 3 5 9 13 22
ProcessProcess
PriorityPriority Priority
Process Process Priority
Process Priority
P1 P0 4 P0 5 5P0 5P0 5
P0 P2 5 P1 2 4P1 4
P1 P3 4 0
Preemptive Priority Scheduling
Process Arrival Time Burst Time Finish Time Turnaround Time Waiting Time
(T0) (∆T) (T1) (TAT = T1-T0) (WT = TAT-∆T)
P0 0 10 22 22 12
P1 1 6 13 12 6
P2 3 2 5 2 0
P3 5 4 9 4 0
Gantt Chart (small values for priority means higher priority of a process)
P0 P1 P2 P3 P1 P0
0 1 3 5 9 13 22