SlideShare ist ein Scribd-Unternehmen logo
1 von 31
CPU scheduling
Mohd Amir khan
CPU scheduling
 A process execution consist office cycle of CPU execution and input output
execution
 Every process begins with CPU burst that may be followed by input output
bus, then another CPU burst and then input output burst and so on
eventually in the last will end up on CPU burst
 CPU burst there are those processes which require most of time on CPU
 Input output bus which require most of the time on input output devices
for peripherals
 A good CPU scheduling idea should choose the mixture of both so that
both input and output devices and CPU can be utilized efficiently
Basic Concepts
 Maximum CPU utilization obtained with
multiprogramming
 CPU–I/O Burst Cycle – Process execution
consists of a cycle of CPU execution and
I/O wait
 CPU burst followed by I/O burst
 CPU burst distribution is of main concern
For example
o cricket team
o printing document
o addition of two numbers
CPU scheduling terminology
 Burst time /execution time /running time:- is the time causes required for
running on CPU
 Waiting time:- time spent by a process in ready state waiting for CPU
 Arrival time:- When a process enters ready state
 Turnaround time:- total time spent by a process in the system and around time
equal to {exit time - arrival time} or {burst time + waiting time}
 Response time:- Time between a process enters ready queue and get
scheduled on the CPU for the first time
 Exit time:- when process completes execution and exit from system
Histogram of CPU-burst Times
CPU scheduling Algorithm
 Two approaches
1. Non-Preemptive Scheduling:
2. Preemptive Scheduling:
 Non-preemptive
 Once resources(CPU Cycle) are allocated to a process, the process holds it till it completes its burst time or switches
to waiting state
 Process can not be interrupted until it terminates itself or its time is up.
 Rigid, not cost association
 Preemptive
 In this resources(CPU Cycle) are allocated to a process for a limited time
 Process can be interrupted in between.
 Flexible and cost associated
Scheduling Algorithm Optimization Criteria
 Max CPU utilization
 Max throughput
 Min turnaround time
 Min waiting time
 Min response time
First Come First serve (FCFS)
 It assign CPU to the process which arrives first
 Easy to understand and can easily be implemented using queue data structure
 Allows non-pre-emptive in nature
First- Come, First-Served (FCFS) Scheduling
Process Burst Time
P1 24
P2 3
P3 3
 Suppose that the processes arrive in the order: P1 , P2 , P3
The Gantt Chart for the schedule is:
 Waiting time for P1 = 0; P2 = 24; P3 = 27
 Average waiting time: (0 + 24 + 27)/3 = 17
P P P1 2 3
0 24 3027
A Gantt chart is a horizontal bar chart
developed as a production control tool in
1917 by Henry L. Gantt,
an American engineer and social scientist
Solve this
Pid AT BT TAT WT
A 3 4
B 5 3
C 0 2
D 5 1
E 4 3
Create Gantt Chart
Calculate Waiting Time of each and
average waiting time
Convoy Effect
Pid AT BT WT AWT
P1 0 100 0
P2 1 1 99
Create Gantt Chart
Pid AT BT WT AWT
P1 1 100 1
P2 0 1 0
Create Gantt Chart
Smaller process have to wait for long time for bigger process to release CPU
Advantages
 Easy to learn
 Easy to understand
 Easy to implement
 We used for background process where execution is not urgent
Disadvantages
 Suffer from Convoy effect
 Normally long average waiting time
 No consideration to burst time or arrival time/Priority
 Should not be used for interactive system
Shortest job first (non-preemptive) shortest
remaining time first(SRTF) (preemptive)
 Out of all available process CPU is assigned to the process having smallest burst time
requirement no priority, no seniority
 If there is tie first Come First serve is used to break tie
 Can we used both with non primitive and primitive approach
 Primitive version STRF is also called as optimal as it currently minimum average waiting
time
Example of SJF
Process Arrivall Time Burst Time
P1 1 6
P2 2 8
P3 4 7
P4 0 3
 SJF scheduling chart
 Average waiting time = (3 + 16 + 9 + 0) / 4 = 7
P3
0 3 24
P4
P1
169
P2
SJF (non-preemptive)
Pid AT BT TAT WT
A 3 1
B 1 4
C 4 2
D 0 6
E 2 3
Create Gantt Chart
Calculate Waiting Time of Processes
Example of Shortest-remaining-time-first
 Now we add the concepts of varying arrival times and preemption to
the analysis
Process Arrival Time Burst Time
P1 0 8
P2 1 4
P3 2 9
P4 3 5
 Preemptive SJF Gantt Chart
 Average waiting time = [(10-1)+(1-1)+(17-2)+5-3)]/4 = 26/4 = 6.5
P4
0 1 26
P1
P2
10
P3
P1
5 17
SRTF(Pre-emptive)
Pid AT BT TAT WT
A 3 4
B 5 3
C 0 2
D 5 1
E 4 3
Create Gantt Chart
Calculate Waiting Time of Processes
Advantages and disadvantages of shortest job
first scheduling algorithm
Advantages
 SRTF guarantees minimal average waiting
time
 Standard for other algorithm in terms of
average waiting time
 Better Average response time compare to
First Come First serve
Disadvantages
 Algorithm cannot be implemented as there
is no way to know the burst time of a
process
 Process with the longest CPU burst time
requirement will go into starvation
 No idea of priority, process with large burst
time have work response time
Priority Algorithm
 Here a priority is associated with each process
 At any instance of time out of all available process, CPU is allocated to the process
which posses the highest Priority
 Tie is broken with FCFS order
 No importance to arrival time or burst time
 Supports both non pre-emptive and pre-emptive version
Continue..
 A priority number (integer) is associated with each process
 The CPU is allocated to the process with the highest priority
 Preemptive
 Non-preemptive
 SJF is priority scheduling where priority is the inverse of predicted
next CPU burst time
 Problem  Starvation – low priority processes may never execute
 Solution  Aging – as time progresses increase the priority of the
process
Example of Priority
Scheduling(Non-preemptive)
Process Arrival Time Burst Time Priority
P1 1 10 5
P2 0 1 3
P3 2 2 5
P4 3 1 4
P5 1 5 7
Priority scheduling Gantt Chart
 Average waiting time
Non Pre-emptive
Pid AT BT Priority TAT WT
P1 0 4 2
P2 1 3 3
P3 2 1 4
P4 3 5 5
P5 4 2 5
Create Gantt Chart
Calculate Waiting Time of Processes
Pre-emptive
Pid AT BT Priority TAT WT
P1 0 4 2
P2 1 3 3
P3 2 1 4
P4 3 5 5
P5 4 2 5
Create Gantt Chart
Calculate Waiting Time of Processes
Advantages and disadvantages of priority
scheduling algorithm
Advantages
 Provide a facility of priority specially for
system process
 Allows to run important process first even
if it is a user process
Disadvantages
 Here process with smaller priority may
starve for CPU
 No idea of response time or waiting time
 Note aging is a technique of gradually
increasing the priority of process that wait
in the system for long time
Round Robin (RR)
 Each process gets a small unit of CPU time (time quantum q),
usually 10-100 milliseconds. After this time has elapsed, the
process is preempted and added to the end of the ready queue.
 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 at once. No process waits more than (n-1)q
time units.
 Timer interrupts every quantum to schedule next process
 Performance
 q large  FIFO
 q small  q must be large with respect to context switch, otherwise
overhead is too high
Continue.
 It is design for time sharing system where it is not necessary to complete one process
and then start another, but to be responsive and divide time of CPU among the
process in the ready state
 Here ready q to be treated as circular queue
 We will fix the time quantum up to which process can hold the CPU in one go within
which either a process terminates or process must release the CPU and re-enter in the
circular queue and wait for the next chance
 Round Robin is called preemptive in nature
Example of RR with Time Quantum =
4
Process Burst Time
P1 24
P2 3
P3 3
 The Gantt chart is:
 Typically, higher average turnaround than SJF, but better response
 q should be large compared to context switch time
 q usually 10ms to 100ms, context switch < 10 usec
P P P1 1 1
0 18 3026144 7 10 22
P2
P3
P1
P1
P1
Pre-emptive
Pid AT BT TAT WT
A 0 5
B 1 3
C 2 1
D 3 2
E 4 3
TQ=2
Create Queue
Create Gantt Chart
Calculate Waiting Time of Processes
Advantages and disadvantages of Round Robin
scheduling algorithm
 Advantages
 Perform best in terms of average response
time
 Works well in call to time sharing system,
client server architecture and interactive
system
 Kind of shortest job first implementation
 Disadvantages
 Longer process may starve
 Performance depends heavily on time
Quantum
 No idea of reality
1. The following is the set of processes whose arrival time, burst time and the priorities are given
below:
S.No. Process Arrival time (in ms) Bunt Time(in ms) Priority
1 P1 0 10 5
2 P2 0 5 2
3 P3 2 3 1
4 P4 5 20 4
5 P5 10 2 3
If Shortest job first ( vith pre-emption) scheduling policy and Priority scheduling policy(with pre-
emption) is used then, what will be the average waiting time in both the cases?
Ops:
A. 5.6 ms, 8 ms
B. None of the mentioned options
C. 6.8 ms, 7.6 ms
D. 0 5.6 ms, 7.6 ms
Question

Weitere ähnliche Inhalte

Was ist angesagt?

CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithmsShanu Kumar
 
Cpu scheduling algorithm on windows
Cpu scheduling algorithm on windowsCpu scheduling algorithm on windows
Cpu scheduling algorithm on windowssiddhartha pande
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.pptKeyreSebre
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGgarishma bhatia
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process SchedulingDamian T. Gordon
 
system interconnect architectures in ACA
system interconnect architectures in ACAsystem interconnect architectures in ACA
system interconnect architectures in ACAPankaj Kumar Jain
 
6 cpu scheduling
6 cpu scheduling6 cpu scheduling
6 cpu schedulingBaliThorat1
 
First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)nikeAthena
 
Parallel programming model
Parallel programming modelParallel programming model
Parallel programming modeleasy notes
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecturePankaj Kumar Jain
 
MPI message passing interface
MPI message passing interfaceMPI message passing interface
MPI message passing interfaceMohit Raghuvanshi
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
Priority Scheduling
Priority Scheduling  Priority Scheduling
Priority Scheduling JawadHaider36
 

Was ist angesagt? (20)

CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
 
Cpu scheduling algorithm on windows
Cpu scheduling algorithm on windowsCpu scheduling algorithm on windows
Cpu scheduling algorithm on windows
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process Scheduling
 
system interconnect architectures in ACA
system interconnect architectures in ACAsystem interconnect architectures in ACA
system interconnect architectures in ACA
 
6 cpu scheduling
6 cpu scheduling6 cpu scheduling
6 cpu scheduling
 
First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)
 
Parallel programming model
Parallel programming modelParallel programming model
Parallel programming model
 
Operations on Processes
Operations on ProcessesOperations on Processes
Operations on Processes
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Parallel programming model
Parallel programming modelParallel programming model
Parallel programming model
 
Shortest Job First
Shortest Job FirstShortest Job First
Shortest Job First
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecture
 
Semaphores
SemaphoresSemaphores
Semaphores
 
MPI message passing interface
MPI message passing interfaceMPI message passing interface
MPI message passing interface
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Priority Scheduling
Priority Scheduling  Priority Scheduling
Priority Scheduling
 

Ähnlich wie CPU scheduling

Ähnlich wie CPU scheduling (20)

Process management in os
Process management in osProcess management in os
Process management in os
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Operating System Scheduling
Operating System SchedulingOperating System Scheduling
Operating System Scheduling
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
CH06.pdf
CH06.pdfCH06.pdf
CH06.pdf
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
 
OSCh6
OSCh6OSCh6
OSCh6
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
CPU Scheduling.pdf
CPU Scheduling.pdfCPU Scheduling.pdf
CPU Scheduling.pdf
 
Ch5
Ch5Ch5
Ch5
 
Ch6
Ch6Ch6
Ch6
 
Fcfs and sjf
Fcfs and sjfFcfs and sjf
Fcfs and sjf
 
Csc4320 chapter 5 2
Csc4320 chapter 5 2Csc4320 chapter 5 2
Csc4320 chapter 5 2
 
Os..
Os..Os..
Os..
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
 
Process Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdf
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
 

Kürzlich hochgeladen

MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
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
 
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
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera 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
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
(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
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
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
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
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
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 

Kürzlich hochgeladen (20)

MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
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...
 
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...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
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
 
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 Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
(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...
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
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
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
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
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 

CPU scheduling

  • 2. CPU scheduling  A process execution consist office cycle of CPU execution and input output execution  Every process begins with CPU burst that may be followed by input output bus, then another CPU burst and then input output burst and so on eventually in the last will end up on CPU burst  CPU burst there are those processes which require most of time on CPU  Input output bus which require most of the time on input output devices for peripherals  A good CPU scheduling idea should choose the mixture of both so that both input and output devices and CPU can be utilized efficiently
  • 3. Basic Concepts  Maximum CPU utilization obtained with multiprogramming  CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait  CPU burst followed by I/O burst  CPU burst distribution is of main concern For example o cricket team o printing document o addition of two numbers
  • 4. CPU scheduling terminology  Burst time /execution time /running time:- is the time causes required for running on CPU  Waiting time:- time spent by a process in ready state waiting for CPU  Arrival time:- When a process enters ready state  Turnaround time:- total time spent by a process in the system and around time equal to {exit time - arrival time} or {burst time + waiting time}  Response time:- Time between a process enters ready queue and get scheduled on the CPU for the first time  Exit time:- when process completes execution and exit from system
  • 6. CPU scheduling Algorithm  Two approaches 1. Non-Preemptive Scheduling: 2. Preemptive Scheduling:  Non-preemptive  Once resources(CPU Cycle) are allocated to a process, the process holds it till it completes its burst time or switches to waiting state  Process can not be interrupted until it terminates itself or its time is up.  Rigid, not cost association  Preemptive  In this resources(CPU Cycle) are allocated to a process for a limited time  Process can be interrupted in between.  Flexible and cost associated
  • 7. Scheduling Algorithm Optimization Criteria  Max CPU utilization  Max throughput  Min turnaround time  Min waiting time  Min response time
  • 8. First Come First serve (FCFS)  It assign CPU to the process which arrives first  Easy to understand and can easily be implemented using queue data structure  Allows non-pre-emptive in nature
  • 9. First- Come, First-Served (FCFS) Scheduling Process Burst Time P1 24 P2 3 P3 3  Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is:  Waiting time for P1 = 0; P2 = 24; P3 = 27  Average waiting time: (0 + 24 + 27)/3 = 17 P P P1 2 3 0 24 3027 A Gantt chart is a horizontal bar chart developed as a production control tool in 1917 by Henry L. Gantt, an American engineer and social scientist
  • 10. Solve this Pid AT BT TAT WT A 3 4 B 5 3 C 0 2 D 5 1 E 4 3 Create Gantt Chart Calculate Waiting Time of each and average waiting time
  • 11. Convoy Effect Pid AT BT WT AWT P1 0 100 0 P2 1 1 99 Create Gantt Chart Pid AT BT WT AWT P1 1 100 1 P2 0 1 0 Create Gantt Chart Smaller process have to wait for long time for bigger process to release CPU
  • 12. Advantages  Easy to learn  Easy to understand  Easy to implement  We used for background process where execution is not urgent
  • 13. Disadvantages  Suffer from Convoy effect  Normally long average waiting time  No consideration to burst time or arrival time/Priority  Should not be used for interactive system
  • 14. Shortest job first (non-preemptive) shortest remaining time first(SRTF) (preemptive)  Out of all available process CPU is assigned to the process having smallest burst time requirement no priority, no seniority  If there is tie first Come First serve is used to break tie  Can we used both with non primitive and primitive approach  Primitive version STRF is also called as optimal as it currently minimum average waiting time
  • 15. Example of SJF Process Arrivall Time Burst Time P1 1 6 P2 2 8 P3 4 7 P4 0 3  SJF scheduling chart  Average waiting time = (3 + 16 + 9 + 0) / 4 = 7 P3 0 3 24 P4 P1 169 P2
  • 16. SJF (non-preemptive) Pid AT BT TAT WT A 3 1 B 1 4 C 4 2 D 0 6 E 2 3 Create Gantt Chart Calculate Waiting Time of Processes
  • 17. Example of Shortest-remaining-time-first  Now we add the concepts of varying arrival times and preemption to the analysis Process Arrival Time Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5  Preemptive SJF Gantt Chart  Average waiting time = [(10-1)+(1-1)+(17-2)+5-3)]/4 = 26/4 = 6.5 P4 0 1 26 P1 P2 10 P3 P1 5 17
  • 18. SRTF(Pre-emptive) Pid AT BT TAT WT A 3 4 B 5 3 C 0 2 D 5 1 E 4 3 Create Gantt Chart Calculate Waiting Time of Processes
  • 19. Advantages and disadvantages of shortest job first scheduling algorithm Advantages  SRTF guarantees minimal average waiting time  Standard for other algorithm in terms of average waiting time  Better Average response time compare to First Come First serve Disadvantages  Algorithm cannot be implemented as there is no way to know the burst time of a process  Process with the longest CPU burst time requirement will go into starvation  No idea of priority, process with large burst time have work response time
  • 20. Priority Algorithm  Here a priority is associated with each process  At any instance of time out of all available process, CPU is allocated to the process which posses the highest Priority  Tie is broken with FCFS order  No importance to arrival time or burst time  Supports both non pre-emptive and pre-emptive version
  • 21. Continue..  A priority number (integer) is associated with each process  The CPU is allocated to the process with the highest priority  Preemptive  Non-preemptive  SJF is priority scheduling where priority is the inverse of predicted next CPU burst time  Problem  Starvation – low priority processes may never execute  Solution  Aging – as time progresses increase the priority of the process
  • 22. Example of Priority Scheduling(Non-preemptive) Process Arrival Time Burst Time Priority P1 1 10 5 P2 0 1 3 P3 2 2 5 P4 3 1 4 P5 1 5 7 Priority scheduling Gantt Chart  Average waiting time
  • 23. Non Pre-emptive Pid AT BT Priority TAT WT P1 0 4 2 P2 1 3 3 P3 2 1 4 P4 3 5 5 P5 4 2 5 Create Gantt Chart Calculate Waiting Time of Processes
  • 24. Pre-emptive Pid AT BT Priority TAT WT P1 0 4 2 P2 1 3 3 P3 2 1 4 P4 3 5 5 P5 4 2 5 Create Gantt Chart Calculate Waiting Time of Processes
  • 25. Advantages and disadvantages of priority scheduling algorithm Advantages  Provide a facility of priority specially for system process  Allows to run important process first even if it is a user process Disadvantages  Here process with smaller priority may starve for CPU  No idea of response time or waiting time  Note aging is a technique of gradually increasing the priority of process that wait in the system for long time
  • 26. Round Robin (RR)  Each process gets a small unit of CPU time (time quantum q), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue.  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 at once. No process waits more than (n-1)q time units.  Timer interrupts every quantum to schedule next process  Performance  q large  FIFO  q small  q must be large with respect to context switch, otherwise overhead is too high
  • 27. Continue.  It is design for time sharing system where it is not necessary to complete one process and then start another, but to be responsive and divide time of CPU among the process in the ready state  Here ready q to be treated as circular queue  We will fix the time quantum up to which process can hold the CPU in one go within which either a process terminates or process must release the CPU and re-enter in the circular queue and wait for the next chance  Round Robin is called preemptive in nature
  • 28. Example of RR with Time Quantum = 4 Process Burst Time P1 24 P2 3 P3 3  The Gantt chart is:  Typically, higher average turnaround than SJF, but better response  q should be large compared to context switch time  q usually 10ms to 100ms, context switch < 10 usec P P P1 1 1 0 18 3026144 7 10 22 P2 P3 P1 P1 P1
  • 29. Pre-emptive Pid AT BT TAT WT A 0 5 B 1 3 C 2 1 D 3 2 E 4 3 TQ=2 Create Queue Create Gantt Chart Calculate Waiting Time of Processes
  • 30. Advantages and disadvantages of Round Robin scheduling algorithm  Advantages  Perform best in terms of average response time  Works well in call to time sharing system, client server architecture and interactive system  Kind of shortest job first implementation  Disadvantages  Longer process may starve  Performance depends heavily on time Quantum  No idea of reality
  • 31. 1. The following is the set of processes whose arrival time, burst time and the priorities are given below: S.No. Process Arrival time (in ms) Bunt Time(in ms) Priority 1 P1 0 10 5 2 P2 0 5 2 3 P3 2 3 1 4 P4 5 20 4 5 P5 10 2 3 If Shortest job first ( vith pre-emption) scheduling policy and Priority scheduling policy(with pre- emption) is used then, what will be the average waiting time in both the cases? Ops: A. 5.6 ms, 8 ms B. None of the mentioned options C. 6.8 ms, 7.6 ms D. 0 5.6 ms, 7.6 ms Question