0% found this document useful (0 votes)
39 views

Central Processing Unit Management Lecture

The document discusses various CPU scheduling algorithms: 1. First Come First Serve schedules processes in the order of arrival time. 2. Shortest Job First schedules the process with the shortest burst time next. 3. Non-Preemptive Priority schedules based on priority, without interrupting running processes. 4. Round Robin gives each process a time slice to run before resuming others, for time sharing.

Uploaded by

Rolando Alag
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Central Processing Unit Management Lecture

The document discusses various CPU scheduling algorithms: 1. First Come First Serve schedules processes in the order of arrival time. 2. Shortest Job First schedules the process with the shortest burst time next. 3. Non-Preemptive Priority schedules based on priority, without interrupting running processes. 4. Round Robin gives each process a time slice to run before resuming others, for time sharing.

Uploaded by

Rolando Alag
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Central Processing Unit Management

Objectives:

 Identify and differentiate the different algorithm implemented by the CPU.


 Analyze different CPU scheduling algorithm.

CPU Scheduling Algorithm

1. First Come First Serve(FSFS)

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

The processes are permanently assigned to a queue that corresponds to an algorithm


upon entry to the system. This setup has the advantage of low scheduling overhead, but
the disadvantage of being inflexible.

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

Queue Level: 1-NPP


2-SRTF

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/

Albano, Gisela May and Pestrana, Angelito (2009). “Fundamentals of Operating


System”, A & C Printers, A N Domingo St. San Juan City, Philippines

Tanenbaum, Andrew S. (2015). “Modern Operating System” 4th Edition, Pearson


Education Inc., Upper Saddle River, New Jersey

You might also like