SlideShare a Scribd company logo
1 of 17
WELCOME
Presentation on
“ Different CPU scheduling algorithms,
make comparative chart to calculate
turnaround and waiting time ”
CPU Scheduling is a process of determining which process will own CPU for execution while another
process is on hold. The main task of CPU scheduling is to make sure that whenever the CPU remains idle,
the OS at least select one of the processes available in the ready queue for execution. The selection process
will be carried out by the CPU scheduler. It selects one of the processes in memory that are ready for
execution.
Introduction :
Scheduling is one of the basic functions of any operating system, because scheduling
of all the computer resources is done before their user. The CPU the most essential computer resource.
Types of CPU scheduling Algorithms:
There are mainly six types of process scheduling algorithms
1)First Come First Serve (FCFS)
2)Shortest-Job-First (SJF) Scheduling
3)Shortest Remaining Time
4)Priority Scheduling
5)Round Robin Scheduling
6)Multilevel Queue Scheduling
First Come First Serve (FCFS) :-
 In the "First come first serve" scheduling algorithm, as the name suggests, the process
which arrives first, gets executed first, or we can say that the process which requests the
CPU first, gets the CPU allocated first.
 First Come First Serve, is just like FIFO (First in First out) Queue data structure, where the
data element which is added to the queue first, is the one who leaves the queue first.
 This is used in Batch Systems.
 It's easy to understand and implement programmatically, using a Queue data structure,
where a new process enters through the tail of the queue, and the scheduler selects process
from the head of the queue.
 A perfect real life example of FCFS scheduling is buying tickets at ticket counter.
Advantages of FCFS:-
1) It is easy to implement.
2) It is easy to understand.
3) First come, First serve
Disadvantages of FCFS : –
1) The process with less execution time suffer i.e. waiting time is often quite
long.
2) Favors CPU Bound process then I/O bound process.
3) Here, first process will get the CPU first, other processes can get CPU only
after the current process has finished it’s execution. Now, suppose the first
process has large burst time, and other processes have less burst time, then
the processes will have to wait more unnecessarily, this will result in more
average waiting time, i.e., Convey effect.
Ex :
Gantt chart of the example
Turnaround Time for p1= (24-0) = 24
Turnaround Time for p2= (27-0) = 27
Turnaround Time for p3= (32-0) = 32
Average Turnaround Time = (24+27+32)/3 =27.67
Waiting Time for p1 = 0
Waiting Time for p2 = 24
Waiting Time for p3 = 27
Average Waiting Time = (0+24+27)/3 = 17
P1 P2 P3
0 24 27 32
Process Burst time
P1 24
P2 03
P3 05
2. Shortest-Job-First (SJF) Scheduling:-
Till now, we were scheduling the processes according to their arrival time (in FCFS
scheduling). However, SJF scheduling algorithm, schedules the processes according to their
burst time.
In SJF scheduling, the process with the lowest burst time, among the list of available processes
in the ready queue, is going to be scheduled next.
However, it is very difficult to predict the burst time needed for a process hence this algorithm
is very difficult to implement in the system.
Advantages of Shortest Job First (SJF):-
Maximum throughput.
Minimum average waiting and turnaround time.
Disadvantages of Shortest Job First (SJF):-
May suffer with the problem of starvation
It is not implementable because the exact Burst time for a process can't be known in advance.
3. Shortest Remaining Time:-
This Algorithm is the preemptive version of SJF scheduling. In 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. The context of the process is saved in the Process
Control Block when the process is removed from the execution and the next process is
scheduled. This PCB is accessed on the next execution of this process.
Advantages of Shortest Remaining Time:-
1)Short-burst jobs run fast
Disadvantages of Shortest Remaining Time:-
1) Long-burst (CPU intensive) jobs get a long mean waiting time
2) Rely on ability to estimate CPU burst length
4. Priority Scheduling:-
In this tutorial we will understand the priority scheduling algorithm, how it works and its advantages and
disadvantages.
In the Shortest Job First scheduling algorithm, the priority of a process is generally the inverse of the
CPU burst time, i.e. the larger the burst time the lower is the priority of that process.
In case of priority scheduling the priority is not always set as the inverse of the CPU burst time, rather it
can be internally or externally set, but yes the scheduling is done on the basis of priority of the process
where the process which is most urgent is processed first, followed by the ones with lesser priority in
order.
Processes with same priority are executed in FCFS manner.
Advantages of Priority Scheduling:-
 The priority of process is selected on the basis of memory requirement, user preference or
the requirement of time.
 Processes are executed on the basis of priority. So high priority does not need to wait for
long which saves time.
 It is easy to use.
 It is a user friendly algorithm.
 Simple to understand.
 it has reasonable support for priority.
Disadvantages of Priority Scheduling:-
 Some low priority processes waiting indefinitely.
 A process will be blocked when it is ready to run but has to wait for the CPU because some
other process is running currently.
 If a new higher priority process keeps on coming in the ready queue, If the system eventually
crashes, all low priority processes get lost.
If high priority processes take lots of CPU time, then the lower priority processes may starve and
will be postponed for an indefinite time
5. Round Robin Scheduling:-
The name of this algorithm comes from the round-robin principle, where each person gets an equal share of
something in turns. It is the oldest, simplest scheduling algorithm, which is mostly used for multitasking.
In Round-robin scheduling, each ready task runs turn by turn only in a cyclic queue for a limited time slice.
This algorithm also offers starvation free execution of processes.
Advantages of Round Robin algorithm:-
 It doesn't face the issues of starvation or convoy effect.
 All the jobs get a fair allocation of CPU.
 It deals with all process without any priority
 If you know the total number of processes on the run queue, then you can also assume the worst-case
response time for the same process.
 This scheduling method does not depend upon burst time. That's why it is easily implementable on the
system.
 Once a process is executed for a specific set of the period, the process is preempted, and another process
executes for that given time period.
Disadvantages of Round Robin algorithm:-
 If slicing time of OS is low, the processor output will be reduced.
 This method spends more time on context switching
 Its performance heavily depends on time quantum.
 Priorities cannot be set for the processes.
 Round-robin scheduling doesn't give special priority to more important tasks.
 Decreases comprehension
 Lower time quantum results in higher the context switching overhead in the system.
 Finding a correct time quantum is a quite difficult task in this system.
6. Multilevel Queue Scheduling:-
It may happen that processes in the ready queue can be divided into different classes where each class has its own
scheduling needs. For example, a common division is a foreground (interactive) process and background
(batch) processes. These two classes have different scheduling needs. For this kind of situation Multilevel Queue
Scheduling is used . Now, let us see how it works.
Ready Queue is divided into separate queues for each class of processes. For example, let us take three different types
of process System processes, Interactive processes and Batch Processes.
Advantages of Multilevel Queue Scheduling:
1) The processes are permanently assigned to the queue, so it has advantage of low scheduling overhead.
Disadvantages of Multilevel Queue Scheduling:
1) Some processes may starve for CPU if some higher priority queues are never becoming empty.
It is inflexible in nature.
Comparison Between the different CPU Scheduling Algorithm
Conclusion
1.Scheduling algorithms should not affect the behavior of the.
system (same results regardless of schedule).
2.However, the algorithms do impact the system's efficiency
and response time.
3.The best schemes are adaptive. To do absolutely best, we'd
have to be able to predict the future.
Thank You

More Related Content

Similar to CPU scheduling algorithms chart

PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptxDivyaKS18
 
cospptagain.pptx
cospptagain.pptxcospptagain.pptx
cospptagain.pptxRaunakJha15
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)Harshit Jain
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.pptKeyreSebre
 
Cpu scheduling final
Cpu scheduling finalCpu scheduling final
Cpu scheduling finalmarangburu42
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process SchedulingShipra Swati
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationAnitaSofiaKeyser
 
Cpu scheduling pre final formatting
Cpu scheduling pre final formattingCpu scheduling pre final formatting
Cpu scheduling pre final formattingmarangburu42
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxansariparveen06
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2) rohassanie
 
20118016 aryan sabat study and analysis of scheduler design
20118016 aryan sabat study and analysis of scheduler design20118016 aryan sabat study and analysis of scheduler design
20118016 aryan sabat study and analysis of scheduler design8016AryanSabat
 
Processor / CPU Scheduling
Processor / CPU SchedulingProcessor / CPU Scheduling
Processor / CPU SchedulingIzaz Roghani
 

Similar to CPU scheduling algorithms chart (20)

PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
 
cospptagain.pptx
cospptagain.pptxcospptagain.pptx
cospptagain.pptx
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 
Cpu scheduling final
Cpu scheduling finalCpu scheduling final
Cpu scheduling final
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
cosppt.pptx
cosppt.pptxcosppt.pptx
cosppt.pptx
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System Explanation
 
Cpu scheduling pre final formatting
Cpu scheduling pre final formattingCpu scheduling pre final formatting
Cpu scheduling pre final formatting
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
 
Operating system
Operating systemOperating system
Operating system
 
exp 3.docx
exp 3.docxexp 3.docx
exp 3.docx
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
 
20118016 aryan sabat study and analysis of scheduler design
20118016 aryan sabat study and analysis of scheduler design20118016 aryan sabat study and analysis of scheduler design
20118016 aryan sabat study and analysis of scheduler design
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Unit 2 notes
Unit 2 notesUnit 2 notes
Unit 2 notes
 
Processor / CPU Scheduling
Processor / CPU SchedulingProcessor / CPU Scheduling
Processor / CPU Scheduling
 

Recently uploaded

GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 

Recently uploaded (20)

GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 

CPU scheduling algorithms chart

  • 2. Presentation on “ Different CPU scheduling algorithms, make comparative chart to calculate turnaround and waiting time ”
  • 3. CPU Scheduling is a process of determining which process will own CPU for execution while another process is on hold. The main task of CPU scheduling is to make sure that whenever the CPU remains idle, the OS at least select one of the processes available in the ready queue for execution. The selection process will be carried out by the CPU scheduler. It selects one of the processes in memory that are ready for execution. Introduction : Scheduling is one of the basic functions of any operating system, because scheduling of all the computer resources is done before their user. The CPU the most essential computer resource.
  • 4. Types of CPU scheduling Algorithms: There are mainly six types of process scheduling algorithms 1)First Come First Serve (FCFS) 2)Shortest-Job-First (SJF) Scheduling 3)Shortest Remaining Time 4)Priority Scheduling 5)Round Robin Scheduling 6)Multilevel Queue Scheduling
  • 5. First Come First Serve (FCFS) :-  In the "First come first serve" scheduling algorithm, as the name suggests, the process which arrives first, gets executed first, or we can say that the process which requests the CPU first, gets the CPU allocated first.  First Come First Serve, is just like FIFO (First in First out) Queue data structure, where the data element which is added to the queue first, is the one who leaves the queue first.  This is used in Batch Systems.  It's easy to understand and implement programmatically, using a Queue data structure, where a new process enters through the tail of the queue, and the scheduler selects process from the head of the queue.  A perfect real life example of FCFS scheduling is buying tickets at ticket counter.
  • 6. Advantages of FCFS:- 1) It is easy to implement. 2) It is easy to understand. 3) First come, First serve Disadvantages of FCFS : – 1) The process with less execution time suffer i.e. waiting time is often quite long. 2) Favors CPU Bound process then I/O bound process. 3) Here, first process will get the CPU first, other processes can get CPU only after the current process has finished it’s execution. Now, suppose the first process has large burst time, and other processes have less burst time, then the processes will have to wait more unnecessarily, this will result in more average waiting time, i.e., Convey effect.
  • 7. Ex : Gantt chart of the example Turnaround Time for p1= (24-0) = 24 Turnaround Time for p2= (27-0) = 27 Turnaround Time for p3= (32-0) = 32 Average Turnaround Time = (24+27+32)/3 =27.67 Waiting Time for p1 = 0 Waiting Time for p2 = 24 Waiting Time for p3 = 27 Average Waiting Time = (0+24+27)/3 = 17 P1 P2 P3 0 24 27 32 Process Burst time P1 24 P2 03 P3 05
  • 8. 2. Shortest-Job-First (SJF) Scheduling:- Till now, we were scheduling the processes according to their arrival time (in FCFS scheduling). However, SJF scheduling algorithm, schedules the processes according to their burst time. In SJF scheduling, the process with the lowest burst time, among the list of available processes in the ready queue, is going to be scheduled next. However, it is very difficult to predict the burst time needed for a process hence this algorithm is very difficult to implement in the system. Advantages of Shortest Job First (SJF):- Maximum throughput. Minimum average waiting and turnaround time. Disadvantages of Shortest Job First (SJF):- May suffer with the problem of starvation It is not implementable because the exact Burst time for a process can't be known in advance.
  • 9. 3. Shortest Remaining Time:- This Algorithm is the preemptive version of SJF scheduling. In 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. The context of the process is saved in the Process Control Block when the process is removed from the execution and the next process is scheduled. This PCB is accessed on the next execution of this process. Advantages of Shortest Remaining Time:- 1)Short-burst jobs run fast Disadvantages of Shortest Remaining Time:- 1) Long-burst (CPU intensive) jobs get a long mean waiting time 2) Rely on ability to estimate CPU burst length
  • 10. 4. Priority Scheduling:- In this tutorial we will understand the priority scheduling algorithm, how it works and its advantages and disadvantages. In the Shortest Job First scheduling algorithm, the priority of a process is generally the inverse of the CPU burst time, i.e. the larger the burst time the lower is the priority of that process. In case of priority scheduling the priority is not always set as the inverse of the CPU burst time, rather it can be internally or externally set, but yes the scheduling is done on the basis of priority of the process where the process which is most urgent is processed first, followed by the ones with lesser priority in order. Processes with same priority are executed in FCFS manner. Advantages of Priority Scheduling:-  The priority of process is selected on the basis of memory requirement, user preference or the requirement of time.  Processes are executed on the basis of priority. So high priority does not need to wait for long which saves time.  It is easy to use.  It is a user friendly algorithm.  Simple to understand.  it has reasonable support for priority.
  • 11. Disadvantages of Priority Scheduling:-  Some low priority processes waiting indefinitely.  A process will be blocked when it is ready to run but has to wait for the CPU because some other process is running currently.  If a new higher priority process keeps on coming in the ready queue, If the system eventually crashes, all low priority processes get lost. If high priority processes take lots of CPU time, then the lower priority processes may starve and will be postponed for an indefinite time
  • 12. 5. Round Robin Scheduling:- The name of this algorithm comes from the round-robin principle, where each person gets an equal share of something in turns. It is the oldest, simplest scheduling algorithm, which is mostly used for multitasking. In Round-robin scheduling, each ready task runs turn by turn only in a cyclic queue for a limited time slice. This algorithm also offers starvation free execution of processes. Advantages of Round Robin algorithm:-  It doesn't face the issues of starvation or convoy effect.  All the jobs get a fair allocation of CPU.  It deals with all process without any priority  If you know the total number of processes on the run queue, then you can also assume the worst-case response time for the same process.  This scheduling method does not depend upon burst time. That's why it is easily implementable on the system.  Once a process is executed for a specific set of the period, the process is preempted, and another process executes for that given time period.
  • 13. Disadvantages of Round Robin algorithm:-  If slicing time of OS is low, the processor output will be reduced.  This method spends more time on context switching  Its performance heavily depends on time quantum.  Priorities cannot be set for the processes.  Round-robin scheduling doesn't give special priority to more important tasks.  Decreases comprehension  Lower time quantum results in higher the context switching overhead in the system.  Finding a correct time quantum is a quite difficult task in this system.
  • 14. 6. Multilevel Queue Scheduling:- It may happen that processes in the ready queue can be divided into different classes where each class has its own scheduling needs. For example, a common division is a foreground (interactive) process and background (batch) processes. These two classes have different scheduling needs. For this kind of situation Multilevel Queue Scheduling is used . Now, let us see how it works. Ready Queue is divided into separate queues for each class of processes. For example, let us take three different types of process System processes, Interactive processes and Batch Processes. Advantages of Multilevel Queue Scheduling: 1) The processes are permanently assigned to the queue, so it has advantage of low scheduling overhead. Disadvantages of Multilevel Queue Scheduling: 1) Some processes may starve for CPU if some higher priority queues are never becoming empty. It is inflexible in nature.
  • 15. Comparison Between the different CPU Scheduling Algorithm
  • 16. Conclusion 1.Scheduling algorithms should not affect the behavior of the. system (same results regardless of schedule). 2.However, the algorithms do impact the system's efficiency and response time. 3.The best schemes are adaptive. To do absolutely best, we'd have to be able to predict the future.