SlideShare a Scribd company logo
1 of 17
Scheduling
Algorithms
Presented By:
Shekhar Singh Tomar
ContentsContents
 Introduction
 Scheduling Algorithms-
 First Come, First Served (FCFS)
 Shortest Job First (SJF)
 Priority
 Round Robin (RR)
IntroductionIntroduction
CPU scheduling deals with the problem of deciding which
of the processes in the ready queue is to be allocated the
CPU.
1- First Come, First Served (FCFS)1- First Come, First Served (FCFS)
SchedulingScheduling
 Implementation:
As each process becomes ready, it joins the ready queue.
When the current process finishes, the oldest process is selected
next.
 Characteristics:
Simple to implement
Non-preemptive
First-Come, First-Served (FCFS)First-Come, First-Served (FCFS)
SchedulingScheduling
Example- Process Burst Time
P1 24
P2 3
P3 3
 With FCFS, the process that requests the CPU first is allocated the CPU first
 Case 1: Suppose that the processes arrive in the order: P1 , P2 , P3
The Chart for the schedule is:
 Waiting time for P1 = 0; P2 = 24; P3 = 27
 Average waiting time: (0 + 24 + 27)/3 = 17
 Average turn-around time: (24 + 27 + 30)/3 = 27
P1 P2 P3
24 27 300
FCFS Scheduling (Cont.)FCFS Scheduling (Cont.)
 Case 2: Suppose that the processes arrive in the order: P2 , P3 , P1
 The chart for the schedule is:
 Waiting time for P1 = 6; P2 = 0; P3 = 3
 Average waiting time: (6 + 0 + 3)/3 = 3 (Much better than Case #1)
 Average turn-around time: (3 + 6 + 30)/3 = 13
P1P3P2
63 300
2-Shortest-Job-First (SJF) Scheduling2-Shortest-Job-First (SJF) Scheduling
 The SJF algorithm associates with each process the length of its
next CPU burst
 When the CPU becomes available, it is assigned to the process
that has the smallest next CPU burst (in the case of matching
bursts, FCFS is used)
 Two schemes:
Non-preemptive – once the CPU is given to the process, it
cannot be preempted until it completes its CPU burst.
Preemptive – It will preempt the currently executing process.
This scheme is know as the Shortest-Remaining-Time-First
(SRTF)
SJF Scheduling…SJF Scheduling…
Exponential Averaging
 Estimation based on historical data
 tn = length of the nth CPU burst
 τn = Estimate for nth CPU burst (stores past history)
 τn+1 = predicted value for n+1st
or next CPU burst
 α, 0 ≤ α 1≤
τn+1 = αtn + (1- α) τn
09/24/13 8
Process Arrival Time Burst Time
P1 0.0 6
P2 0.0 4
P3 0.0 1
P4 0.0 5
SJF (non-preemptive, simultaneous arrival)
Average waiting time = (0 + 1 + 5 + 10)/4 = 4
Average turn-around time = (1 + 5 + 10 + 16)/4 = 8
Example 1: Non-Preemptive SJFExample 1: Non-Preemptive SJF
(simultaneous arrival)(simultaneous arrival)
P1P3 P2
51 160
P4
10
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
SJF (non-preemptive, varied arrival times)
Average waiting time
= ( (0 – 0) + (8 – 2) + (7 – 4) + (12 – 5) )/4
= (0 + 6 + 3 + 7)/4 = 4
Average turn-around time:
= ( (7 – 0) + (12 – 2) + (8 - 4) + (16 – 5))/4
= ( 7 + 10 + 4 + 11)/4 = 8
Example 2: Non-Preemptive SJFExample 2: Non-Preemptive SJF
(varied arrival times)(varied arrival times)
P1 P3 P2
73 160
P4
8 12
Waiting time : sum of time that a process has spent waiting in the ready queue
Example 3: Preemptive SJFExample 3: Preemptive SJF
(Shortest-remaining-time-first)(Shortest-remaining-time-first)
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
SJF (preemptive , varied arrival times)
Average waiting time
= ( [(0 – 0) + (11 - 2)] + [(2 – 2) + (5 – 4)] + (4 - 4) + (7 – 5) )/4
= 9 + 1 + 0 + 2)/4
= 3
Average turn-around time = (16 + 7 + 5 + 11)/4 = 9.75
P1 P3P2
42 110
P4
5 7
P2 P1
16
Waiting time : sum of time that a process has spent waiting in the ready queue
3- Priority Scheduling3- Priority Scheduling
 The SJF algorithm is a special case of the general priority scheduling
algorithm
 Each process (or class of processes) is given a priority (integer
number).
 The CPU is allocated to the process with the highest priority (smallest
integer = highest priority)
 Priority scheduling can be either preemptive or non-preemptive
A preemptive approach will preempt the CPU if the priority of the
newly-arrived process is higher than the priority of the currently
running process
A non-preemptive approach will simply put the new process
(with the highest priority) at the head of the ready queue
 SJF is a priority scheduling algorithm where priority is the predicted
next CPU burst time.
 The main problem with priority scheduling is starvation, that is, low
priority processes may never execute.
 A solution is aging; as time progresses, the priority of a process in the
ready queue is increased
Example of Priority SchedulingExample of Priority Scheduling
Process Burst time Priority
P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2
0 1 6 16 18 19
Average wating time = (6+0+16+18+1)/5=8.2 milliseconds
P2 P5 P1 P3 P4
4- Round-Robin Scheduling4- Round-Robin Scheduling
 Developed in response to time-sharing systems.
 Each process gets a small unit of CPU time (time quantum),
 Each job is given control of the CPU for that time quantum.
(In the range of 10-100 milliseconds.)
 Control then passes to the next job (FIFO?)
 Average waiting time dependent on job size, quantum size
 RR scheduling algorithm is preemptive.
Example of RR with Time Quantum =Example of RR with Time Quantum =
44
Process Burst Time
P1 24
P2 3
P3 3
 The chart is:
 Typically, higher average turnaround than SJF, but better response.
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
Time Quantum and Context SwitchTime Quantum and Context Switch
TimeTime
Thank YouThank You

More Related Content

What's hot

basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed controlRai University
 
Process scheduling algorithms
Process scheduling algorithmsProcess scheduling algorithms
Process scheduling algorithmsShubham Sharma
 
Multi processor scheduling
Multi  processor schedulingMulti  processor scheduling
Multi processor schedulingShashank Kapoor
 
ARM Exception and interrupts
ARM Exception and interrupts ARM Exception and interrupts
ARM Exception and interrupts NishmaNJ
 
COMPUTER ORGANIZATION NOTES Unit 2
COMPUTER ORGANIZATION NOTES  Unit 2COMPUTER ORGANIZATION NOTES  Unit 2
COMPUTER ORGANIZATION NOTES Unit 2Dr.MAYA NAYAK
 
Microinstruction sequencing new
Microinstruction sequencing newMicroinstruction sequencing new
Microinstruction sequencing newMahesh Kumar Attri
 
Unit 3-pipelining & vector processing
Unit 3-pipelining & vector processingUnit 3-pipelining & vector processing
Unit 3-pipelining & vector processingvishal choudhary
 
Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Subhasis Dash
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And CorrectionRenu Kewalramani
 
RTOS for Embedded System Design
RTOS for Embedded System DesignRTOS for Embedded System Design
RTOS for Embedded System Designanand hd
 
Embedded systems notes
Embedded systems notesEmbedded systems notes
Embedded systems notesShikha Sharma
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInteX Research Lab
 
Pipeline hazard
Pipeline hazardPipeline hazard
Pipeline hazardAJAL A J
 

What's hot (20)

pipelining
pipeliningpipelining
pipelining
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed control
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
 
Process scheduling algorithms
Process scheduling algorithmsProcess scheduling algorithms
Process scheduling algorithms
 
Multi processor scheduling
Multi  processor schedulingMulti  processor scheduling
Multi processor scheduling
 
ARM Exception and interrupts
ARM Exception and interrupts ARM Exception and interrupts
ARM Exception and interrupts
 
Congestion control
Congestion controlCongestion control
Congestion control
 
COMPUTER ORGANIZATION NOTES Unit 2
COMPUTER ORGANIZATION NOTES  Unit 2COMPUTER ORGANIZATION NOTES  Unit 2
COMPUTER ORGANIZATION NOTES Unit 2
 
Microinstruction sequencing new
Microinstruction sequencing newMicroinstruction sequencing new
Microinstruction sequencing new
 
Unit 3-pipelining & vector processing
Unit 3-pipelining & vector processingUnit 3-pipelining & vector processing
Unit 3-pipelining & vector processing
 
Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1)
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And Correction
 
Interrupt
InterruptInterrupt
Interrupt
 
Unit2 arm
Unit2 armUnit2 arm
Unit2 arm
 
RTOS for Embedded System Design
RTOS for Embedded System DesignRTOS for Embedded System Design
RTOS for Embedded System Design
 
Embedded systems notes
Embedded systems notesEmbedded systems notes
Embedded systems notes
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Evolution of os
Evolution of osEvolution of os
Evolution of os
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer Architecture
 
Pipeline hazard
Pipeline hazardPipeline hazard
Pipeline hazard
 

Viewers also liked

CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OSharini0810
 
Operating System 5
Operating System 5Operating System 5
Operating System 5tech2click
 

Viewers also liked (8)

CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OS
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 

Similar to Sa by shekhar

Process management in os
Process management in osProcess management in os
Process management in osMiong Lazaro
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-schedulingNazir Ahmed
 
Ch6
Ch6Ch6
Ch6C.U
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling gopi7
 
csc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdfcsc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdfAkarshNag
 
Csc4320 chapter 5 2
Csc4320 chapter 5 2Csc4320 chapter 5 2
Csc4320 chapter 5 2pri534
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptxjamilaltiti1
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - EngineeringYogesh Santhan
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Nagarajan
 
Cpu scheduling(suresh)
Cpu scheduling(suresh)Cpu scheduling(suresh)
Cpu scheduling(suresh)Nagarajan
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithmBinal Parekh
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationdonny101
 

Similar to Sa by shekhar (20)

OSCh6
OSCh6OSCh6
OSCh6
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Ch5
Ch5Ch5
Ch5
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
Ch6
Ch6Ch6
Ch6
 
Ch05
Ch05Ch05
Ch05
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling
 
csc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdfcsc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdf
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Csc4320 chapter 5 2
Csc4320 chapter 5 2Csc4320 chapter 5 2
Csc4320 chapter 5 2
 
Os..
Os..Os..
Os..
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)
 
CH06.pdf
CH06.pdfCH06.pdf
CH06.pdf
 
Cpu scheduling(suresh)
Cpu scheduling(suresh)Cpu scheduling(suresh)
Cpu scheduling(suresh)
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
 

Recently uploaded

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Sa by shekhar

  • 2. ContentsContents  Introduction  Scheduling Algorithms-  First Come, First Served (FCFS)  Shortest Job First (SJF)  Priority  Round Robin (RR)
  • 3. IntroductionIntroduction CPU scheduling deals with the problem of deciding which of the processes in the ready queue is to be allocated the CPU.
  • 4. 1- First Come, First Served (FCFS)1- First Come, First Served (FCFS) SchedulingScheduling  Implementation: As each process becomes ready, it joins the ready queue. When the current process finishes, the oldest process is selected next.  Characteristics: Simple to implement Non-preemptive
  • 5. First-Come, First-Served (FCFS)First-Come, First-Served (FCFS) SchedulingScheduling Example- Process Burst Time P1 24 P2 3 P3 3  With FCFS, the process that requests the CPU first is allocated the CPU first  Case 1: Suppose that the processes arrive in the order: P1 , P2 , P3 The Chart for the schedule is:  Waiting time for P1 = 0; P2 = 24; P3 = 27  Average waiting time: (0 + 24 + 27)/3 = 17  Average turn-around time: (24 + 27 + 30)/3 = 27 P1 P2 P3 24 27 300
  • 6. FCFS Scheduling (Cont.)FCFS Scheduling (Cont.)  Case 2: Suppose that the processes arrive in the order: P2 , P3 , P1  The chart for the schedule is:  Waiting time for P1 = 6; P2 = 0; P3 = 3  Average waiting time: (6 + 0 + 3)/3 = 3 (Much better than Case #1)  Average turn-around time: (3 + 6 + 30)/3 = 13 P1P3P2 63 300
  • 7. 2-Shortest-Job-First (SJF) Scheduling2-Shortest-Job-First (SJF) Scheduling  The SJF algorithm associates with each process the length of its next CPU burst  When the CPU becomes available, it is assigned to the process that has the smallest next CPU burst (in the case of matching bursts, FCFS is used)  Two schemes: Non-preemptive – once the CPU is given to the process, it cannot be preempted until it completes its CPU burst. Preemptive – It will preempt the currently executing process. This scheme is know as the Shortest-Remaining-Time-First (SRTF)
  • 8. SJF Scheduling…SJF Scheduling… Exponential Averaging  Estimation based on historical data  tn = length of the nth CPU burst  τn = Estimate for nth CPU burst (stores past history)  τn+1 = predicted value for n+1st or next CPU burst  α, 0 ≤ α 1≤ τn+1 = αtn + (1- α) τn 09/24/13 8
  • 9. Process Arrival Time Burst Time P1 0.0 6 P2 0.0 4 P3 0.0 1 P4 0.0 5 SJF (non-preemptive, simultaneous arrival) Average waiting time = (0 + 1 + 5 + 10)/4 = 4 Average turn-around time = (1 + 5 + 10 + 16)/4 = 8 Example 1: Non-Preemptive SJFExample 1: Non-Preemptive SJF (simultaneous arrival)(simultaneous arrival) P1P3 P2 51 160 P4 10
  • 10. Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (non-preemptive, varied arrival times) Average waiting time = ( (0 – 0) + (8 – 2) + (7 – 4) + (12 – 5) )/4 = (0 + 6 + 3 + 7)/4 = 4 Average turn-around time: = ( (7 – 0) + (12 – 2) + (8 - 4) + (16 – 5))/4 = ( 7 + 10 + 4 + 11)/4 = 8 Example 2: Non-Preemptive SJFExample 2: Non-Preemptive SJF (varied arrival times)(varied arrival times) P1 P3 P2 73 160 P4 8 12 Waiting time : sum of time that a process has spent waiting in the ready queue
  • 11. Example 3: Preemptive SJFExample 3: Preemptive SJF (Shortest-remaining-time-first)(Shortest-remaining-time-first) Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (preemptive , varied arrival times) Average waiting time = ( [(0 – 0) + (11 - 2)] + [(2 – 2) + (5 – 4)] + (4 - 4) + (7 – 5) )/4 = 9 + 1 + 0 + 2)/4 = 3 Average turn-around time = (16 + 7 + 5 + 11)/4 = 9.75 P1 P3P2 42 110 P4 5 7 P2 P1 16 Waiting time : sum of time that a process has spent waiting in the ready queue
  • 12. 3- Priority Scheduling3- Priority Scheduling  The SJF algorithm is a special case of the general priority scheduling algorithm  Each process (or class of processes) is given a priority (integer number).  The CPU is allocated to the process with the highest priority (smallest integer = highest priority)  Priority scheduling can be either preemptive or non-preemptive A preemptive approach will preempt the CPU if the priority of the newly-arrived process is higher than the priority of the currently running process A non-preemptive approach will simply put the new process (with the highest priority) at the head of the ready queue  SJF is a priority scheduling algorithm where priority is the predicted next CPU burst time.  The main problem with priority scheduling is starvation, that is, low priority processes may never execute.  A solution is aging; as time progresses, the priority of a process in the ready queue is increased
  • 13. Example of Priority SchedulingExample of Priority Scheduling Process Burst time Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 0 1 6 16 18 19 Average wating time = (6+0+16+18+1)/5=8.2 milliseconds P2 P5 P1 P3 P4
  • 14. 4- Round-Robin Scheduling4- Round-Robin Scheduling  Developed in response to time-sharing systems.  Each process gets a small unit of CPU time (time quantum),  Each job is given control of the CPU for that time quantum. (In the range of 10-100 milliseconds.)  Control then passes to the next job (FIFO?)  Average waiting time dependent on job size, quantum size  RR scheduling algorithm is preemptive.
  • 15. Example of RR with Time Quantum =Example of RR with Time Quantum = 44 Process Burst Time P1 24 P2 3 P3 3  The chart is:  Typically, higher average turnaround than SJF, but better response. P1 P2 P3 P1 P1 P1 P1 P1 0 4 7 10 14 18 22 26 30
  • 16. Time Quantum and Context SwitchTime Quantum and Context Switch TimeTime