Central Processing Unit Management Lecture
Central Processing Unit Management Lecture
Objectives:
scheduling algorithm simply schedules the jobs according to their arrival time. The job
which comes first in the ready queue will get the CPU first. The lesser the arrival time of
the job, the sooner will the job get the CPU. FCFS scheduling may cause the problem of
starvation if the burst time of the first process is the longest among all the jobs.
Example:
P AT BT ET TT WT
1 3 4 11 8 4
2 5 9 20 15 6
3 8 4 24 16 12
4 0 7 7 7 0
5 12 6 30 18 12
Gantt Chart:
P4 P1 P2 P3 P5
0 7 11 20 24
30
30
CPU Utilization: *100 =100%
30
2. Shortest Job First (SJF)
scheduling algorithm, schedules the processes according to their burst time. The
process with the lowest burst time, among the list of available processes in the ready
queue, is going to be scheduled next.
Example:
P AT BT ET TT WT
1 3 4 11 8 4
2 5 9 30 25 16
3 8 4 15 7 3
4 0 7 7 7 0
5 12 6 21 9 3
Gantt Chart:
P4 P1 P3 P5 P2
0 7 11 15 21
30
30
CPU Utilization: *100 =100%
30
3. Non-Preemptive Priority
the processes are scheduled according to the priority number assigned to them. Once
the process gets scheduled, it will run till the completion.
Example:
P AT BT P ET TT WT
1 3 4 2 26 23 19
2 5 9 1 16 11 2
3 8 4 2 30 22 18
4 0 7 1 7 7 0
5 12 6 1 22 10 4
Gantt Chart:
P4 P2 P5 P1 P3
0 7 16 22 26
30
30
CPU Utilization: *100 =100%
30
4. Shortest Remaining Time First(SRTF)
the execution of the process can be stopped after certain amount of time. At the arrival
of every process, the short term scheduler schedules the process with the least
remaining burst time among the list of available processes and the running process.
Once all the processes are available in the ready queue, No preemption will be done
and the algorithm will work as SJF scheduling.
Example:
P AT BT ET TT WT
1 3 4 11 8 4
2 5 9 30 25 16
3 8 4 15 7 3
4 0 7 7 7 0
5 12 6 21 9 3
Gantt Chart:
P4 P4 P4 P1 P1 P3 P3 P5 P2
0 3 5 7 8 11 12 15 21
30
30
CPU Utilization: *100 =100%
30
5. Preemptive Priority
This Priority is compared with the priority of the other processes present in the ready
queue as well as with the one which is being executed by the CPU at that point of time.
The One with the highest priority among all the available processes will be given the
CPU next.
The difference between preemptive priority scheduling and non preemptive priority
scheduling is that, in the preemptive priority scheduling, the job which is being executed
can be stopped at the arrival of a higher priority job.
Example:
P AT BT P ET TT WT
1 3 4 2 26 23 19
2 5 9 1 16 11 2
3 8 4 2 30 22 18
4 0 7 1 7 7 0
5 12 6 1 22 10 4
Gantt Chart:
P4 P4 P4 P2 P2 P2 P5 P1 P3
0 3 5 7 8 12 16 22 26
30
30
CPU Utilization: *100 =100%
30
6. Round Robin
This is the preemptive version of first come first serve scheduling. The Algorithm focuses
on Time Sharing. In this algorithm, every process gets executed in a cyclic way. A
certain time slice is defined in the system which is called time quantum. Each process
present in the ready queue is assigned the CPU for that time quantum, if the execution
of the process is completed during that time then the process will terminate else the
process will go back to the ready queue and waits for the next turn to complete the
execution.
Example:
P AT BT ET TT WT
1 3 4 13 10 6
2 5 9 30 25 16
3 8 4 24 16 12
4 0 7 17 17 10
5 12 6 27 15 9
Gantt Chart:
P4 P1 P4 P2 P1 P3 P4 P5 P2 P3 P5 P2
0 3 6 9 12 13 16 17 20 23 24 27 30
30
CPU Utilization: *100 =100%
30
7. Multilevel Queue
Example:
P AT BT P QL ET TT WT
1 3 4 2 1 7 4 0
2 5 9 1 1 16 11 2
3 8 4 2 2 30 22 18
4 0 7 1 2 26 26 19
5 12 6 1 1 22 10 4
Gantt Chart:
P4 P1 P2 P5 P4 P3
0 3 7 16 22 26 30
30
CPU Utilization: *100 =100%
30
8. Multilevel Feedback Queue
allows a process to move between queues. The idea is to separate processes with
different CPU-burst characteristics. If a process uses too much CPU time, it will be
moved to a lower-priority queue. Similarly, a process that waits too long in a lower-
priority queue may be moved to a higher-priority queue.
Example:
P AT BT ET TT WT
1 3 4 13 10 6
2 5 9 18 13 4
3 8 4 20 12 8
4 0 7 26 26 19
5 12 6 30 18 12
Level:
1- 2 Quantum
2- 3 Quantum
3- SJF
Gantt Chart:
2 P4 P1 P2 P3 P5
0 2 5 7 9 11 13 15
3 P4 P1 P2 P3 P5
0 2 5 11 13 15 18 20 23
SJF P5 P4 P5
0 23 24 26
30
P1 P4 P1 P2 P3 P1 P5 P2 P3 P5 P5 P4 P5
0 2 5 7 9 11 13 15 18 20 23 24 26
30
30
CPU Utilization: *100 =100%
30
References
https://www.javatpoint.com/os-tutorial
https://www.gatevidyalay.com/turn-around-time-response-time-waiting-time/