SlideShare a Scribd company logo
1 of 29
Download to read offline
Amrita
School
of
Engineering,
Bangalore
Ms. Harika Pudugosula
Teaching Assistant
Department of Electronics & Communication Engineering
• Basic Concepts
• Scheduling Criteria
• Scheduling Algorithms
2
3
Scheduling Algorithm Optimization Criteria
• Max CPU utilization - keep CPU as busy as possible
• Max throughput - Number of processes that complete their execution per time unit
• Min turnaround time - amount of time to execute a particular process
• Min waiting time - amount of time that a process spends waiting in the ready queue
• Min response time - amount of time it takes from when a request was submitted
until the first response is produced, not output (for time-sharing environment)
Priority Scheduling
• A priority is associated with each process, and the CPUis allocated to the process
with the highest priority
• Priorities are generally indicated by some fixed range of numbers, such as 0 to 7 or 0
to 4,095
• There is no general agreement on whether 0 is the highest or lowest priority
• Some systems use low numbers to represent low priority; others use low numbers
for high priority
• In this text, we assume that low numbers represent high priority
• Equal-priority processes are scheduled in FCFS order
• SJF is a special case of the general priority scheduling, where priority is the inverse of
predicted next CPU burst time (the larger the CPU burst, the lower the priority, and
vice versa)
4
Example of Priority Scheduling
• Consider the following set of processes, assumed to have arrived at time 0 in the order
P1, P2, ···, P5, with the length of the CPU burst given in milliseconds:
Process Burst Time Priority
P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2
• Priority scheduling Gantt Chart
• Average waiting time = 8.2 msec
• Average turnaround time = (16+1+18+19+6)/5 =60/5=12msec
5
Priority Scheduling
• The CPU is allocated to the process with the highest priority (smallest integer 
highest priority)
• Preemptive - When a process arrives at the ready queue, its priority is compared
with the priority of the currently running process.
A preemptive priority scheduling algorithm will preempt the CPU if the
priority of the newly arrived process is higher than the priority of the
currently running process
• Nonpreemptive - A nonpreemptive priority scheduling algorithm will simply put
the new process at the head of the ready queue
6
Example of Priority Scheduling - nonpremptive
• Consider the following set of processes, P1,P2, P3, P4, P5, with the length of the CPU
burst given in milliseconds. Compute and compare which among the processes provides
minimum waiting time and minimum turnaround time
Process Burst Time Priority Arrival Time
P1 18 2 0
P2 18 3 1
P3 5 4 2
P4 8 1 3
P5 10 5 4
• P4 provides 15ms (min waiting time)
• P1 provides 18ms(min turnaround time)
• Average waiting time = (0+25+42+15+45)/5=25.4 msec
• Average turnaround time = (18+43+47+23+55)/5=37.2msec
7
Example of Priority Scheduling - premptive
• Consider the following set of processes, P1,P2, P3, P4, P5, with the length of the CPU
burst given in milliseconds. Compute and compare which among the processes provides
minimum waiting time and minimum turnaround time
Process Burst Time Priority Arrival Time
P1 18 2 0
P2 18 1 5
P3 5 4 3
P4 8 3 8
P5 10 5 1
• P2 provides 0ms (min waiting time)
• P2 provides 18ms(min turnaround time)
• Average waiting time = (18+0+41+28+48)/5=27 msec
• Average turnaround time = (36+18+46+36+58)/5=38.8msec
8
Priority Scheduling
• Problem  Starvation or Indefinite blocking – A process that is ready to run but
waiting for the CPU can be considered blocked. A priority scheduling algorithm can
leave some low priority processes waiting indefinitely. In a heavily loaded computer
system, a steady stream of higher-priority processes can prevent a low-priority
process from ever getting the CPU
• Solution  Aging – as time progresses increase the priority of the process that wait
(ready queue) in the system for a long time
9
Round-Robin Scheduling
• The round-robin (RR) scheduling algorithm is designed especially for time sharing
systems
• It is similar to FCFS scheduling, but preemption is added to enable the system to
switch between processes
• A small unit of time, called a time quantum or time slice, is defined. A time quantum
is generally from 10 to 100 milliseconds in length
• The ready queue is treated as a circular queue
• The CPU scheduler goes around the ready queue, allocating the CPU to each process
for a time interval of up to 1 time quantum
• To implement RR scheduling, we again treat the ready queue as a FIFO queue of
processes (new processes are added to the tail of the ready queue)
10
Round-Robin Scheduling
• The CPU scheduler picks the first process from the ready queue, sets a timer to
interrupt after 1 time quantum, and dispatches the process
• The process may have a CPU burst of less than 1 time quantum
• In this case, the process itself will release the CPU voluntarily
• The scheduler will then proceed to the next process in the ready queue
• If CPU burst of the currently running process is longer than 1 time quantum
• The timer will go off and will cause an interrupt to the operating system
• A context switch will be executed, and the process will be put at the tail of the
ready queue
• The CPU scheduler will then select the next process in the ready queue
• The average waiting time under the RR policy is often long
11
Example of RR with Time Quantum = 4
• Consider the following set of processes that arrive at time 0, with the length of the
CPU burst given in milliseconds:
Process Burst Time
P1 24
P2 3
P3 3
• The Gantt chart is:
• The average waiting time (10-4)+(4-0)+(7-0)/3 = 17/3 = 5.6
• The average turnaround time (30+7+10)/3 = 15.6
P P P
1 1 1
0 1
8 3
0
2
6
1
4
4 7 1
0 2
2
P
2
P
3
P
1
P
1
P
1
12
Round-Robin Scheduling
• In the RR scheduling algorithm, no process is allocated the CPU for more than 1 time
quantum in a row (unless it is the only runnable process). If a process’s CPU burst
exceeds 1 time quantum, that process is preempted and is put back in the ready
queue. The RR scheduling algorithm is thus preemptive
• If there are n processes in the ready queue and the time quantum is q, then each
process gets 1/n of the CPU time in chunks of at most q time units. Each process
must wait no longer than (n − 1) × q time units until its next time quantum. For
example, with five processes and a time quantum of 20 milliseconds, each process
will get up to 20 milliseconds every 100 milliseconds
• The performance of the RR algorithm depends heavily on the size of the time
quantum (q)
• q large  RR policy same as the FCFS policy (maintained by FIFO)
• q small  RR approach can result in a large number of context switches,
otherwise overhead is too high
13
Round-Robin Scheduling
• The performance of the RR algorithm depends heavily on the size of the time
quantum (q)
• q large  RR policy same as the FCFS policy (maintained by FIFO)
• q small  RR approach can result in a large number of context switches,
otherwise overhead is too high
14
Round-Robin Scheduling
• Turnaround time also depends on the
size of the time quantum
• The average turnaround time of a set of
processes does not necessarily improve
as the time-quantum size increases
• In general, the average turnaround time
can be improved if most processes finish
their next CPU burst in a single time
quantum
15
80% of CPU bursts
should be shorter
than q
Round-Robin Scheduling
• The time quantum should be large compared with the context switch time, it should
not be too large
• As we pointed out earlier, if the time quantum is too large, RR scheduling
degenerates to an FCFS policy
• A rule of thumb is that 80 percent of the CPU bursts should be shorter than the time
quantum
16
Multilevel Queue Scheduling
• Scheduling algorithms has been created
for situations in which processes are
easily classified into different groups
• For example, common division is
made between
• foreground (interactive)
processes - high priority and
• background (batch) processes -
low priority
• A multilevel queue scheduling
algorithm partitions the ready queue
into several separate queues
17
Multilevel Queue Scheduling
• The processes are permanently assigned to one queue, generally based on some
property of the process, such as memory size, process priority, or process type
• Each queue has its own scheduling algorithm
• The foreground queue might be scheduled by an RR algorithm
• The background queue is scheduled by an FCFS algorithm
• Scheduling must be done between the queues:
• Fixed priority scheduling; (i.e., serve all from foreground then from background).
Possibility of starvation.
• Time slice – each queue gets a certain amount of CPU time which it can schedule
amongst its processes; i.e., 80% to foreground in RR, 20% to background in FCFS
18
Multilevel Queue Scheduling
• Advantage:
• When the multilevel queue scheduling algorithm is used, processes are
permanently assigned to a queue when they enter the system
• If there are separate queues for foreground and background processes, for
example, processes do not move from one queue to the other, since processes do
not change their foreground or background nature
• This setup has the advantage of low scheduling overhead
• But it is inflexible
19
Multilevel Feedback Queue Scheduling
• The multilevel feedback queue scheduling algorithm, allows a process to move
between queues
• The idea is to separate processes according to the characteristics of their CPU bursts
• If a process uses too much CPU time, it will be moved to a lower-priority queue
• This scheme leaves I/O-bound and interactive processes in the higher-priority queues
• In addition, a process that waits too long in a lower-priority queue may be moved to a
higher-priority queue. This form of aging prevents starvation
• For example, consider a multilevel feedback queue scheduler with three queues,
numbered from 0 to 2
20
Example
• For example, consider a multilevel
feedback queue scheduler with three
queues, numbered from 0 to 2
• The scheduler first executes all
processes in queue 0. Only when queue
0 is empty will it execute processes in
queue 1. Similarly, processes in queue 2
will be executed only if queues 0 and 1
are empty
• A process that arrives for queue 1 will
preempt a process in queue 2. A process
in queue 1 will in turn be preempted by
a process arriving for queue 0
21
Example
• Three queues:
• Q0 – RR with time quantum 8 milliseconds
• Q1 – RR with time quantum 16 milliseconds
• Q2 – FCFS
• Scheduling
• A new job enters queue Q0
• When it gains CPU, job receives 8
milliseconds
• If it does not finish in 8 milliseconds, job
is moved to queue Q1
• At Q1 job is again served and receives 16
additional milliseconds
• If it still does not complete, it is preempted and
moved to queue Q2. Processes in queue 2 are
run on an FCFS basis but are run only when
queues 0 and 1 are empty
22
Multilevel Feedback Queue Scheduling
• Multilevel-feedback-queue scheduler defined by the following parameters:
• number of queues
• scheduling algorithms for each queue
• method used to determine when to upgrade a process
• method used to determine when to demote a process
• method used to determine which queue a process will enter when that process
needs service
23
Examples of FCFS with Arrival time
24
Consider the following set of
processes, with the length of the CPU
burst given in milliseconds. Compute
average waiting time and average
turnaround time
Examples of FCFS with Arrival time
25
Consider the following set of processes, with the length of the CPU burst given in
milliseconds. Compute average waiting time and average turnaround time
Examples of FCFS with Arrival time
26
Consider the following set of jobs, A, B, C, D, E, with the length of the CPU burst and
arrival time given in milliseconds. Compute average waiting time and average
turnaround time
Examples of FCFS with Arrival time
27
Consider the following set of processes, with the length of the CPU burst given in
milliseconds. Compute average waiting time and average turnaround time
28
References
1. Silberscatnz and Galvin, “Operating System Concepts,” Ninth Edition, John
Wiley and Sons, 2012.
2. https://slidetodoc.com/cpu-scheduling-1-st-case-fcfs-first-come/
29
Thank you

More Related Content

Similar to CPU Scheduling Part-III.pdf

ch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdfch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdfSonaliAjankar
 
Round-ribon algorithm presntation
Round-ribon algorithm presntationRound-ribon algorithm presntation
Round-ribon algorithm presntationJamsheed Ali
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxansariparveen06
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithmssathish sak
 
3 process scheduling
3 process scheduling3 process scheduling
3 process schedulingahad alam
 
operating system (1).pdf
operating system (1).pdfoperating system (1).pdf
operating system (1).pdfAliyanAbbas1
 
fggggggggggggggggggggggggggggggfffffffffffffffffff
fggggggggggggggggggggggggggggggffffffffffffffffffffggggggggggggggggggggggggggggggfffffffffffffffffff
fggggggggggggggggggggggggggggggfffffffffffffffffffadugnanegero
 
Process Scheduling Algorithms for Operating Systems
Process Scheduling Algorithms for Operating SystemsProcess Scheduling Algorithms for Operating Systems
Process Scheduling Algorithms for Operating SystemsKathirvelRajan2
 
3_process_scheduling.ppt----------------
3_process_scheduling.ppt----------------3_process_scheduling.ppt----------------
3_process_scheduling.ppt----------------DivyaBorade3
 
programming .pptx
programming .pptxprogramming .pptx
programming .pptxSHUJEHASSAN
 
scheduling Uni processor Long-term .ppt
scheduling  Uni processor Long-term .pptscheduling  Uni processor Long-term .ppt
scheduling Uni processor Long-term .pptSaba651353
 
Round Robin Algorithm.pptx
Round Robin Algorithm.pptxRound Robin Algorithm.pptx
Round Robin Algorithm.pptxSanad Bhowmik
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.pptKeyreSebre
 
Ch6
Ch6Ch6
Ch6C.U
 

Similar to CPU Scheduling Part-III.pdf (20)

Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
ch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdfch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdf
 
Round-ribon algorithm presntation
Round-ribon algorithm presntationRound-ribon algorithm presntation
Round-ribon algorithm presntation
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
3 process scheduling
3 process scheduling3 process scheduling
3 process scheduling
 
operating system (1).pdf
operating system (1).pdfoperating system (1).pdf
operating system (1).pdf
 
3_process_scheduling.ppt
3_process_scheduling.ppt3_process_scheduling.ppt
3_process_scheduling.ppt
 
fggggggggggggggggggggggggggggggfffffffffffffffffff
fggggggggggggggggggggggggggggggffffffffffffffffffffggggggggggggggggggggggggggggggfffffffffffffffffff
fggggggggggggggggggggggggggggggfffffffffffffffffff
 
3_process_scheduling.ppt
3_process_scheduling.ppt3_process_scheduling.ppt
3_process_scheduling.ppt
 
Process Scheduling Algorithms for Operating Systems
Process Scheduling Algorithms for Operating SystemsProcess Scheduling Algorithms for Operating Systems
Process Scheduling Algorithms for Operating Systems
 
3_process_scheduling.ppt----------------
3_process_scheduling.ppt----------------3_process_scheduling.ppt----------------
3_process_scheduling.ppt----------------
 
programming .pptx
programming .pptxprogramming .pptx
programming .pptx
 
scheduling Uni processor Long-term .ppt
scheduling  Uni processor Long-term .pptscheduling  Uni processor Long-term .ppt
scheduling Uni processor Long-term .ppt
 
Round Robin Algorithm.pptx
Round Robin Algorithm.pptxRound Robin Algorithm.pptx
Round Robin Algorithm.pptx
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 
Os2
Os2Os2
Os2
 
CPU Scheduling Part-II.pdf
CPU Scheduling Part-II.pdfCPU Scheduling Part-II.pdf
CPU Scheduling Part-II.pdf
 
Ch6
Ch6Ch6
Ch6
 
Operating system
Operating systemOperating system
Operating system
 

More from Harika Pudugosula

Artificial Neural Networks_Part-2.pptx
Artificial Neural Networks_Part-2.pptxArtificial Neural Networks_Part-2.pptx
Artificial Neural Networks_Part-2.pptxHarika Pudugosula
 
Artificial Neural Networks_Part-1.pptx
Artificial Neural Networks_Part-1.pptxArtificial Neural Networks_Part-1.pptx
Artificial Neural Networks_Part-1.pptxHarika Pudugosula
 
Multithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfMultithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfHarika Pudugosula
 
Multithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfMultithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfHarika Pudugosula
 
Multithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdfMultithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdfHarika Pudugosula
 
Memory Management Strategies - IV.pdf
Memory Management Strategies - IV.pdfMemory Management Strategies - IV.pdf
Memory Management Strategies - IV.pdfHarika Pudugosula
 
Memory Management Strategies - III.pdf
Memory Management Strategies - III.pdfMemory Management Strategies - III.pdf
Memory Management Strategies - III.pdfHarika Pudugosula
 
Memory Management Strategies - II.pdf
Memory Management Strategies - II.pdfMemory Management Strategies - II.pdf
Memory Management Strategies - II.pdfHarika Pudugosula
 
Memory Management Strategies - I.pdf
Memory Management Strategies - I.pdfMemory Management Strategies - I.pdf
Memory Management Strategies - I.pdfHarika Pudugosula
 
Virtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdfVirtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdfHarika Pudugosula
 
Virtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfVirtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfHarika Pudugosula
 
Operating System Structure Part-II.pdf
Operating System Structure Part-II.pdfOperating System Structure Part-II.pdf
Operating System Structure Part-II.pdfHarika Pudugosula
 
Operating System Structure Part-I.pdf
Operating System Structure Part-I.pdfOperating System Structure Part-I.pdf
Operating System Structure Part-I.pdfHarika Pudugosula
 
Lecture-4_Process Management.pdf
Lecture-4_Process Management.pdfLecture-4_Process Management.pdf
Lecture-4_Process Management.pdfHarika Pudugosula
 
Lecture_3-Process Management.pdf
Lecture_3-Process Management.pdfLecture_3-Process Management.pdf
Lecture_3-Process Management.pdfHarika Pudugosula
 

More from Harika Pudugosula (20)

Artificial Neural Networks_Part-2.pptx
Artificial Neural Networks_Part-2.pptxArtificial Neural Networks_Part-2.pptx
Artificial Neural Networks_Part-2.pptx
 
Artificial Neural Networks_Part-1.pptx
Artificial Neural Networks_Part-1.pptxArtificial Neural Networks_Part-1.pptx
Artificial Neural Networks_Part-1.pptx
 
Introduction.pptx
Introduction.pptxIntroduction.pptx
Introduction.pptx
 
CPU Scheduling Part-I.pdf
CPU Scheduling Part-I.pdfCPU Scheduling Part-I.pdf
CPU Scheduling Part-I.pdf
 
Multithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfMultithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdf
 
Multithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfMultithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdf
 
Multithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdfMultithreaded Programming Part- I.pdf
Multithreaded Programming Part- I.pdf
 
Deadlocks Part- III.pdf
Deadlocks Part- III.pdfDeadlocks Part- III.pdf
Deadlocks Part- III.pdf
 
Deadlocks Part- II.pdf
Deadlocks Part- II.pdfDeadlocks Part- II.pdf
Deadlocks Part- II.pdf
 
Deadlocks Part- I.pdf
Deadlocks Part- I.pdfDeadlocks Part- I.pdf
Deadlocks Part- I.pdf
 
Memory Management Strategies - IV.pdf
Memory Management Strategies - IV.pdfMemory Management Strategies - IV.pdf
Memory Management Strategies - IV.pdf
 
Memory Management Strategies - III.pdf
Memory Management Strategies - III.pdfMemory Management Strategies - III.pdf
Memory Management Strategies - III.pdf
 
Memory Management Strategies - II.pdf
Memory Management Strategies - II.pdfMemory Management Strategies - II.pdf
Memory Management Strategies - II.pdf
 
Memory Management Strategies - I.pdf
Memory Management Strategies - I.pdfMemory Management Strategies - I.pdf
Memory Management Strategies - I.pdf
 
Virtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdfVirtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdf
 
Virtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfVirtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdf
 
Operating System Structure Part-II.pdf
Operating System Structure Part-II.pdfOperating System Structure Part-II.pdf
Operating System Structure Part-II.pdf
 
Operating System Structure Part-I.pdf
Operating System Structure Part-I.pdfOperating System Structure Part-I.pdf
Operating System Structure Part-I.pdf
 
Lecture-4_Process Management.pdf
Lecture-4_Process Management.pdfLecture-4_Process Management.pdf
Lecture-4_Process Management.pdf
 
Lecture_3-Process Management.pdf
Lecture_3-Process Management.pdfLecture_3-Process Management.pdf
Lecture_3-Process Management.pdf
 

Recently uploaded

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Recently uploaded (20)

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

CPU Scheduling Part-III.pdf

  • 1. Amrita School of Engineering, Bangalore Ms. Harika Pudugosula Teaching Assistant Department of Electronics & Communication Engineering
  • 2. • Basic Concepts • Scheduling Criteria • Scheduling Algorithms 2
  • 3. 3 Scheduling Algorithm Optimization Criteria • Max CPU utilization - keep CPU as busy as possible • Max throughput - Number of processes that complete their execution per time unit • Min turnaround time - amount of time to execute a particular process • Min waiting time - amount of time that a process spends waiting in the ready queue • Min response time - amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
  • 4. Priority Scheduling • A priority is associated with each process, and the CPUis allocated to the process with the highest priority • Priorities are generally indicated by some fixed range of numbers, such as 0 to 7 or 0 to 4,095 • There is no general agreement on whether 0 is the highest or lowest priority • Some systems use low numbers to represent low priority; others use low numbers for high priority • In this text, we assume that low numbers represent high priority • Equal-priority processes are scheduled in FCFS order • SJF is a special case of the general priority scheduling, where priority is the inverse of predicted next CPU burst time (the larger the CPU burst, the lower the priority, and vice versa) 4
  • 5. Example of Priority Scheduling • Consider the following set of processes, assumed to have arrived at time 0 in the order P1, P2, ···, P5, with the length of the CPU burst given in milliseconds: Process Burst Time Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 • Priority scheduling Gantt Chart • Average waiting time = 8.2 msec • Average turnaround time = (16+1+18+19+6)/5 =60/5=12msec 5
  • 6. Priority Scheduling • The CPU is allocated to the process with the highest priority (smallest integer  highest priority) • Preemptive - When a process arrives at the ready queue, its priority is compared with the priority of the currently running process. A preemptive priority scheduling algorithm will preempt the CPU if the priority of the newly arrived process is higher than the priority of the currently running process • Nonpreemptive - A nonpreemptive priority scheduling algorithm will simply put the new process at the head of the ready queue 6
  • 7. Example of Priority Scheduling - nonpremptive • Consider the following set of processes, P1,P2, P3, P4, P5, with the length of the CPU burst given in milliseconds. Compute and compare which among the processes provides minimum waiting time and minimum turnaround time Process Burst Time Priority Arrival Time P1 18 2 0 P2 18 3 1 P3 5 4 2 P4 8 1 3 P5 10 5 4 • P4 provides 15ms (min waiting time) • P1 provides 18ms(min turnaround time) • Average waiting time = (0+25+42+15+45)/5=25.4 msec • Average turnaround time = (18+43+47+23+55)/5=37.2msec 7
  • 8. Example of Priority Scheduling - premptive • Consider the following set of processes, P1,P2, P3, P4, P5, with the length of the CPU burst given in milliseconds. Compute and compare which among the processes provides minimum waiting time and minimum turnaround time Process Burst Time Priority Arrival Time P1 18 2 0 P2 18 1 5 P3 5 4 3 P4 8 3 8 P5 10 5 1 • P2 provides 0ms (min waiting time) • P2 provides 18ms(min turnaround time) • Average waiting time = (18+0+41+28+48)/5=27 msec • Average turnaround time = (36+18+46+36+58)/5=38.8msec 8
  • 9. Priority Scheduling • Problem  Starvation or Indefinite blocking – A process that is ready to run but waiting for the CPU can be considered blocked. A priority scheduling algorithm can leave some low priority processes waiting indefinitely. In a heavily loaded computer system, a steady stream of higher-priority processes can prevent a low-priority process from ever getting the CPU • Solution  Aging – as time progresses increase the priority of the process that wait (ready queue) in the system for a long time 9
  • 10. Round-Robin Scheduling • The round-robin (RR) scheduling algorithm is designed especially for time sharing systems • It is similar to FCFS scheduling, but preemption is added to enable the system to switch between processes • A small unit of time, called a time quantum or time slice, is defined. A time quantum is generally from 10 to 100 milliseconds in length • The ready queue is treated as a circular queue • The CPU scheduler goes around the ready queue, allocating the CPU to each process for a time interval of up to 1 time quantum • To implement RR scheduling, we again treat the ready queue as a FIFO queue of processes (new processes are added to the tail of the ready queue) 10
  • 11. Round-Robin Scheduling • The CPU scheduler picks the first process from the ready queue, sets a timer to interrupt after 1 time quantum, and dispatches the process • The process may have a CPU burst of less than 1 time quantum • In this case, the process itself will release the CPU voluntarily • The scheduler will then proceed to the next process in the ready queue • If CPU burst of the currently running process is longer than 1 time quantum • The timer will go off and will cause an interrupt to the operating system • A context switch will be executed, and the process will be put at the tail of the ready queue • The CPU scheduler will then select the next process in the ready queue • The average waiting time under the RR policy is often long 11
  • 12. Example of RR with Time Quantum = 4 • Consider the following set of processes that arrive at time 0, with the length of the CPU burst given in milliseconds: Process Burst Time P1 24 P2 3 P3 3 • The Gantt chart is: • The average waiting time (10-4)+(4-0)+(7-0)/3 = 17/3 = 5.6 • The average turnaround time (30+7+10)/3 = 15.6 P P P 1 1 1 0 1 8 3 0 2 6 1 4 4 7 1 0 2 2 P 2 P 3 P 1 P 1 P 1 12
  • 13. Round-Robin Scheduling • In the RR scheduling algorithm, no process is allocated the CPU for more than 1 time quantum in a row (unless it is the only runnable process). If a process’s CPU burst exceeds 1 time quantum, that process is preempted and is put back in the ready queue. The RR scheduling algorithm is thus preemptive • If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units. Each process must wait no longer than (n − 1) × q time units until its next time quantum. For example, with five processes and a time quantum of 20 milliseconds, each process will get up to 20 milliseconds every 100 milliseconds • The performance of the RR algorithm depends heavily on the size of the time quantum (q) • q large  RR policy same as the FCFS policy (maintained by FIFO) • q small  RR approach can result in a large number of context switches, otherwise overhead is too high 13
  • 14. Round-Robin Scheduling • The performance of the RR algorithm depends heavily on the size of the time quantum (q) • q large  RR policy same as the FCFS policy (maintained by FIFO) • q small  RR approach can result in a large number of context switches, otherwise overhead is too high 14
  • 15. Round-Robin Scheduling • Turnaround time also depends on the size of the time quantum • The average turnaround time of a set of processes does not necessarily improve as the time-quantum size increases • In general, the average turnaround time can be improved if most processes finish their next CPU burst in a single time quantum 15 80% of CPU bursts should be shorter than q
  • 16. Round-Robin Scheduling • The time quantum should be large compared with the context switch time, it should not be too large • As we pointed out earlier, if the time quantum is too large, RR scheduling degenerates to an FCFS policy • A rule of thumb is that 80 percent of the CPU bursts should be shorter than the time quantum 16
  • 17. Multilevel Queue Scheduling • Scheduling algorithms has been created for situations in which processes are easily classified into different groups • For example, common division is made between • foreground (interactive) processes - high priority and • background (batch) processes - low priority • A multilevel queue scheduling algorithm partitions the ready queue into several separate queues 17
  • 18. Multilevel Queue Scheduling • The processes are permanently assigned to one queue, generally based on some property of the process, such as memory size, process priority, or process type • Each queue has its own scheduling algorithm • The foreground queue might be scheduled by an RR algorithm • The background queue is scheduled by an FCFS algorithm • Scheduling must be done between the queues: • Fixed priority scheduling; (i.e., serve all from foreground then from background). Possibility of starvation. • Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e., 80% to foreground in RR, 20% to background in FCFS 18
  • 19. Multilevel Queue Scheduling • Advantage: • When the multilevel queue scheduling algorithm is used, processes are permanently assigned to a queue when they enter the system • If there are separate queues for foreground and background processes, for example, processes do not move from one queue to the other, since processes do not change their foreground or background nature • This setup has the advantage of low scheduling overhead • But it is inflexible 19
  • 20. Multilevel Feedback Queue Scheduling • The multilevel feedback queue scheduling algorithm, allows a process to move between queues • The idea is to separate processes according to the characteristics of their CPU bursts • If a process uses too much CPU time, it will be moved to a lower-priority queue • This scheme leaves I/O-bound and interactive processes in the higher-priority queues • In addition, a process that waits too long in a lower-priority queue may be moved to a higher-priority queue. This form of aging prevents starvation • For example, consider a multilevel feedback queue scheduler with three queues, numbered from 0 to 2 20
  • 21. Example • For example, consider a multilevel feedback queue scheduler with three queues, numbered from 0 to 2 • The scheduler first executes all processes in queue 0. Only when queue 0 is empty will it execute processes in queue 1. Similarly, processes in queue 2 will be executed only if queues 0 and 1 are empty • A process that arrives for queue 1 will preempt a process in queue 2. A process in queue 1 will in turn be preempted by a process arriving for queue 0 21
  • 22. Example • Three queues: • Q0 – RR with time quantum 8 milliseconds • Q1 – RR with time quantum 16 milliseconds • Q2 – FCFS • Scheduling • A new job enters queue Q0 • When it gains CPU, job receives 8 milliseconds • If it does not finish in 8 milliseconds, job is moved to queue Q1 • At Q1 job is again served and receives 16 additional milliseconds • If it still does not complete, it is preempted and moved to queue Q2. Processes in queue 2 are run on an FCFS basis but are run only when queues 0 and 1 are empty 22
  • 23. Multilevel Feedback Queue Scheduling • Multilevel-feedback-queue scheduler defined by the following parameters: • number of queues • scheduling algorithms for each queue • method used to determine when to upgrade a process • method used to determine when to demote a process • method used to determine which queue a process will enter when that process needs service 23
  • 24. Examples of FCFS with Arrival time 24 Consider the following set of processes, with the length of the CPU burst given in milliseconds. Compute average waiting time and average turnaround time
  • 25. Examples of FCFS with Arrival time 25 Consider the following set of processes, with the length of the CPU burst given in milliseconds. Compute average waiting time and average turnaround time
  • 26. Examples of FCFS with Arrival time 26 Consider the following set of jobs, A, B, C, D, E, with the length of the CPU burst and arrival time given in milliseconds. Compute average waiting time and average turnaround time
  • 27. Examples of FCFS with Arrival time 27 Consider the following set of processes, with the length of the CPU burst given in milliseconds. Compute average waiting time and average turnaround time
  • 28. 28 References 1. Silberscatnz and Galvin, “Operating System Concepts,” Ninth Edition, John Wiley and Sons, 2012. 2. https://slidetodoc.com/cpu-scheduling-1-st-case-fcfs-first-come/