SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

First Come First Serve
First Come First ServeFirst Come First Serve
First Come First ServeEdwin Makeu
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)Nagarajan
 
cpu scheduling
cpu schedulingcpu scheduling
cpu schedulinghashim102
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithmssathish sak
 
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERSVTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERSvtunotesbysree
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
message passing vs shared memory
message passing vs shared memorymessage passing vs shared memory
message passing vs shared memoryHamza Zahid
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)Shayek Parvez
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process SchedulingDamian T. Gordon
 
Process management in os
Process management in osProcess management in os
Process management in osMiong Lazaro
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process SchedulingShipra Swati
 
Priority Scheduling
Priority Scheduling  Priority Scheduling
Priority Scheduling JawadHaider36
 
OpenMP Tutorial for Beginners
OpenMP Tutorial for BeginnersOpenMP Tutorial for Beginners
OpenMP Tutorial for BeginnersDhanashree Prasad
 

Was ist angesagt? (20)

First Come First Serve
First Come First ServeFirst Come First Serve
First Come First Serve
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)
 
cpu scheduling
cpu schedulingcpu scheduling
cpu scheduling
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
Ch 11 - Priority
Ch 11 - PriorityCh 11 - Priority
Ch 11 - Priority
 
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERSVTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
message passing vs shared memory
message passing vs shared memorymessage passing vs shared memory
message passing vs shared memory
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Pipeline
PipelinePipeline
Pipeline
 
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process Scheduling
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Priority Scheduling
Priority Scheduling  Priority Scheduling
Priority Scheduling
 
OpenMP Tutorial for Beginners
OpenMP Tutorial for BeginnersOpenMP Tutorial for Beginners
OpenMP Tutorial for Beginners
 

Ähnlich wie Sa by shekhar

Operating System 5
Operating System 5Operating System 5
Operating System 5tech2click
 
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
 

Ähnlich wie Sa by shekhar (20)

Operating System 5
Operating System 5Operating System 5
Operating System 5
 
OSCh6
OSCh6OSCh6
OSCh6
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
Ch5
Ch5Ch5
Ch5
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
Ch6
Ch6Ch6
Ch6
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
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..
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
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)
 

Kürzlich hochgeladen

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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
[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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 

Kürzlich hochgeladen (20)

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 ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 

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