SlideShare uma empresa Scribd logo
1 de 22
Scheduling Algorithms
Scheduling Algorithms FCFS
• First-come First-served (FCFS) (FIFO)
– Jobs are scheduled in order of arrival
– Non-preemptive
• Problem:
– Average waiting time depends on arrival order
• Advantage: really simple!
time
P1 P2 P3
0 16 20 24
P1P2 P3
0 4 8 24
Convoy Effect
• A CPU bound job will hold CPU until done,
– or it causes an I/O burst
• rare occurrence, since the thread is CPU-bound
⇒ long periods where no I/O requests issued, and CPU held
– Result: poor I/O device utilization
• Example: one CPU bound job, many I/O bound
• CPU bound runs (I/O devices idle)
• CPU bound blocks
• I/O bound job(s) run, quickly block on I/O
• CPU bound runs again
• I/O completes
• CPU bound still runs while I/O devices idle (continues…)
– Simple hack: run process whose I/O completed?
• What is a potential problem?
Scheduling Algorithms LIFO
• Last-In First-out (LIFO)
– Newly arrived jobs are placed at head of ready queue
– Improves response time for newly created threads
• Problem:
– May lead to starvation – early processes may never get
CPU
Problem
• You work as a short-order cook
– Customers come in and specify which dish they want
– Each dish takes a different amount of time to prepare
• Your goal:
– minimize average time the customers wait for their food
• What strategy would you use ?
– Note: most restaurants use FCFS.
Scheduling Algorithms: SJF
• Shortest Job First (SJF)
– Choose the job with the shortest next CPU burst
– Provably optimal for minimizing average waiting time
• Problem:
– Impossible to know the length of the next CPU burst
P1 P2P3
0 15 21 24
P1P2 P3
0 3 9 24
P2 P3
Scheduling Algorithms SRTF
• SJF can be either preemptive or non-preemptive
– New, short job arrives; current process has long time to execute
• Preemptive SJF is called shortest remaining time first
P1
P2
P3
0 6 2110
P1P3 P1
P2
0 6 2410 13
• Approximate next CPU-burst duration
– from the durations of the previous bursts
• The past can be a good predictor of the future
• No need to remember entire past history
• Use exponential average:
tnduration of the nth
CPU burst
τn+1 predicted duration of the (n+1)st
CPU burst
τn+1 = α tn + (1- α) τn
where 0 ≤ α ≤ 1
α determines the weight placed on past behavior
Shortest Job First Prediction
Priority Scheduling
• Priority Scheduling
– Choose next job based on priority
– For SJF, priority = expected CPU burst
– Can be either preemptive or non-preemptive
• Problem:
– Starvation: jobs can wait indefinitely
• Solution to starvation
– Age processes: increase priority as a function of waiting time
Round Robin
• Round Robin (RR)
– Often used for timesharing
– Ready queue is treated as a circular queue (FIFO)
– Each process is given a time slice called a quantum
– It is run for the quantum or until it blocks
– RR allocates the CPU uniformly (fairly) across participants.
– If average queue length is n, each participant gets 1/n
RR with Time Quantum = 20
Process Burst Time
P1 53
P2 17
P3 68
P4 24
• The Gantt chart is:
• Higher average turnaround than SJF,
• But better response time
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
0 20 37 57 77 97 117 121 134 154 162
Turnaround Time w/ Time Quanta
RR: Choice of Time Quantum
• Performance depends on length of the timeslice
– Context switching isn’t a free operation.
– If timeslice time is set too high
• attempting to amortize context switch cost, you get FCFS.
• i.e. processes will finish or block before their slice is up anyway
– If it’s set too low
• you’re spending all of your time context switching between threads.
– Timeslice frequently set to ~100 milliseconds
– Context switches typically cost < 1 millisecond
Moral:
Context switch is usually negligible (< 1% per timeslice)
unless you context switch too frequently and lose all
productivity
Scheduling Algorithms
• Multi-level Queue Scheduling
• Implement multiple ready queues based on job “type”
– interactive processes
– CPU-bound processes
– batch jobs
– system processes
– student programs
• Different queues may be scheduled using different algos
• Intra-queue CPU allocation is either strict or proportional
• Problem: Classifying jobs into queues is difficult
– A process may have CPU-bound phases as well as interactive ones
Multilevel Queue Scheduling
System Processes
Interactive Processes
Batch Processes
Student Processes
Lowest priority
Highest priority
Scheduling Algorithms
• Multi-level Feedback Queues
• Implement multiple ready queues
– Different queues may be scheduled using different algorithms
– Just like multilevel queue scheduling, but assignments are not static
• Jobs move from queue to queue based on feedback
– Feedback = The behavior of the job,
• e.g. does it require the full quantum for computation, or
• does it perform frequent I/O ?
• Very general algorithm
• Need to select parameters for:
– Number of queues
– Scheduling algorithm within each queue
– When to upgrade and downgrade a job
Multilevel Feedback Queues
Quantum = 2
Quantum = 4
Quantum = 8
FCFS
Lowest priority
Highest priority
A Multi-level System
low
high
high
priority
timeslice
I/O bound jobs
CPU bound jobs
Thread Scheduling
Since all threads share code & data segments
• Option 1: Ignore this fact
• Option 2: Gang scheduling
– run all threads belonging to a process together (multiprocessor only)
– if a thread needs to synchronize with another thread
• the other one is available and active
• Option 3: Two-level scheduling:
– Medium level scheduler
– schedule processes, and within each process, schedule threads
– reduce context switching overhead and improve cache hit ratio
• Option 4: Space-based affinity:
– assign threads to processors (multiprocessor only)
– improve cache hit ratio, but can bite under low-load condition
Real-time Scheduling
• Real-time processes have timing constraints
– Expressed as deadlines or rate requirements
• Common RT scheduling policies
– Rate monotonic
• Just one scalar priority related to the periodicity of the job
• Priority = 1/rate
• Static
– Earliest deadline first (EDF)
• Dynamic but more complex
• Priority = deadline
• Both require admission control to provide guarantees
Postscript
• The best schemes are adaptive.
• To do absolutely best we’d have to predict the future.
– Most current algorithms give highest priority to those that need
the least!
• Scheduling become increasingly ad hoc over the years.
– 1960s papers very math heavy, now mostly “tweak and see”
Problem
• What are metrics that schedulers should optimize for ?
– There are many, the right choice depends on the context
• Suppose:
– You own an airline, have one expensive plane, and passengers
waiting all around the globe
– You own a sweatshop, and need to evaluate workers
– You are at a restaurant, and are waiting for food
– You are an efficiency expert, and are evaluating government
procedures at the DMV
– You are trying to find a project partner or a co-author
– You own a software company that would like to deliver a product
by a deadline

Mais conteúdo relacionado

Mais procurados

SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSMargrat C R
 
First Come First Serve
First Come First ServeFirst Come First Serve
First Come First ServeKavya Kapoor
 
Cpu scheduling algorithms simulation using java
Cpu scheduling algorithms simulation using javaCpu scheduling algorithms simulation using java
Cpu scheduling algorithms simulation using javajsivasrinivas
 
First Come First Serve
First Come First ServeFirst Come First Serve
First Come First ServeEdwin Makeu
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithmsShanu Kumar
 
shortest job first
shortest job firstshortest job first
shortest job firsti i
 
Process scheduling algorithms
Process scheduling algorithmsProcess scheduling algorithms
Process scheduling algorithmsShubham Sharma
 
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinComparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinUniversitas Pembangunan Panca Budi
 
Comparision of scheduling algorithms
Comparision of scheduling algorithmsComparision of scheduling algorithms
Comparision of scheduling algorithmsTanya Makkar
 
17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria myrajendra
 

Mais procurados (19)

SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 
First Come First Serve
First Come First ServeFirst Come First Serve
First Come First Serve
 
Cpu scheduling algorithms simulation using java
Cpu scheduling algorithms simulation using javaCpu scheduling algorithms simulation using java
Cpu scheduling algorithms simulation using java
 
Sa by shekhar
Sa by shekharSa by shekhar
Sa by shekhar
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
First Come First Serve
First Come First ServeFirst Come First Serve
First Come First Serve
 
OSCh6
OSCh6OSCh6
OSCh6
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
 
Os..
Os..Os..
Os..
 
shortest job first
shortest job firstshortest job first
shortest job first
 
Process scheduling algorithms
Process scheduling algorithmsProcess scheduling algorithms
Process scheduling algorithms
 
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinComparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
 
9 cm402.19
9 cm402.199 cm402.19
9 cm402.19
 
Ch5
Ch5Ch5
Ch5
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Comparision of scheduling algorithms
Comparision of scheduling algorithmsComparision of scheduling algorithms
Comparision of scheduling algorithms
 
17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 

Semelhante a Planificacion

Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithmssathish sak
 
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time SystemsSara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systemsknowdiff
 
dataprocess using different technology.ppt
dataprocess using different technology.pptdataprocess using different technology.ppt
dataprocess using different technology.pptssuserf6eb9b
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxansariparveen06
 
3 process scheduling
3 process scheduling3 process scheduling
3 process schedulingahad alam
 
fggggggggggggggggggggggggggggggfffffffffffffffffff
fggggggggggggggggggggggggggggggffffffffffffffffffffggggggggggggggggggggggggggggggfffffffffffffffffff
fggggggggggggggggggggggggggggggfffffffffffffffffffadugnanegero
 
Process Scheduling Algorithms for Operating Systems
Process Scheduling Algorithms for Operating SystemsProcess Scheduling Algorithms for Operating Systems
Process Scheduling Algorithms for Operating SystemsKathirvelRajan2
 
3_process_scheduling.ppt----------------
3_process_scheduling.ppt----------------3_process_scheduling.ppt----------------
3_process_scheduling.ppt----------------DivyaBorade3
 
What to do when detect deadlock
What to do when detect deadlockWhat to do when detect deadlock
What to do when detect deadlockSyed Zaid Irshad
 
Operating system 30 preemptive scheduling
Operating system 30 preemptive schedulingOperating system 30 preemptive scheduling
Operating system 30 preemptive schedulingVaibhav Khanna
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithmsPaurav Shah
 
ch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdfch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdfSonaliAjankar
 

Semelhante a Planificacion (20)

Sceduling
ScedulingSceduling
Sceduling
 
Ch6 cpu scheduling
Ch6   cpu schedulingCh6   cpu scheduling
Ch6 cpu scheduling
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time SystemsSara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
 
dataprocess using different technology.ppt
dataprocess using different technology.pptdataprocess using different technology.ppt
dataprocess using different technology.ppt
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
 
3 process scheduling
3 process scheduling3 process scheduling
3 process scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
3_process_scheduling.ppt
3_process_scheduling.ppt3_process_scheduling.ppt
3_process_scheduling.ppt
 
fggggggggggggggggggggggggggggggfffffffffffffffffff
fggggggggggggggggggggggggggggggffffffffffffffffffffggggggggggggggggggggggggggggggfffffffffffffffffff
fggggggggggggggggggggggggggggggfffffffffffffffffff
 
3_process_scheduling.ppt
3_process_scheduling.ppt3_process_scheduling.ppt
3_process_scheduling.ppt
 
Process Scheduling Algorithms for Operating Systems
Process Scheduling Algorithms for Operating SystemsProcess Scheduling Algorithms for Operating Systems
Process Scheduling Algorithms for Operating Systems
 
3_process_scheduling.ppt----------------
3_process_scheduling.ppt----------------3_process_scheduling.ppt----------------
3_process_scheduling.ppt----------------
 
What to do when detect deadlock
What to do when detect deadlockWhat to do when detect deadlock
What to do when detect deadlock
 
Os2
Os2Os2
Os2
 
Operating system 30 preemptive scheduling
Operating system 30 preemptive schedulingOperating system 30 preemptive scheduling
Operating system 30 preemptive scheduling
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
CPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdfCPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdf
 
ch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdfch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdf
 
Lect07
Lect07Lect07
Lect07
 

Mais de David Lilue

Mais de David Lilue (11)

Principios de diseño de Interfaces
Principios de diseño de InterfacesPrincipios de diseño de Interfaces
Principios de diseño de Interfaces
 
Historia de las Interfaces
Historia de las InterfacesHistoria de las Interfaces
Historia de las Interfaces
 
Memoria2
Memoria2Memoria2
Memoria2
 
Filesystem2
Filesystem2Filesystem2
Filesystem2
 
Disco
DiscoDisco
Disco
 
Memvirtual
MemvirtualMemvirtual
Memvirtual
 
Sincronizacion Procesos
Sincronizacion ProcesosSincronizacion Procesos
Sincronizacion Procesos
 
Thread
ThreadThread
Thread
 
Semaforos
SemaforosSemaforos
Semaforos
 
Proceso
ProcesoProceso
Proceso
 
Deadlock
DeadlockDeadlock
Deadlock
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Último (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Planificacion

  • 2. Scheduling Algorithms FCFS • First-come First-served (FCFS) (FIFO) – Jobs are scheduled in order of arrival – Non-preemptive • Problem: – Average waiting time depends on arrival order • Advantage: really simple! time P1 P2 P3 0 16 20 24 P1P2 P3 0 4 8 24
  • 3. Convoy Effect • A CPU bound job will hold CPU until done, – or it causes an I/O burst • rare occurrence, since the thread is CPU-bound ⇒ long periods where no I/O requests issued, and CPU held – Result: poor I/O device utilization • Example: one CPU bound job, many I/O bound • CPU bound runs (I/O devices idle) • CPU bound blocks • I/O bound job(s) run, quickly block on I/O • CPU bound runs again • I/O completes • CPU bound still runs while I/O devices idle (continues…) – Simple hack: run process whose I/O completed? • What is a potential problem?
  • 4. Scheduling Algorithms LIFO • Last-In First-out (LIFO) – Newly arrived jobs are placed at head of ready queue – Improves response time for newly created threads • Problem: – May lead to starvation – early processes may never get CPU
  • 5. Problem • You work as a short-order cook – Customers come in and specify which dish they want – Each dish takes a different amount of time to prepare • Your goal: – minimize average time the customers wait for their food • What strategy would you use ? – Note: most restaurants use FCFS.
  • 6. Scheduling Algorithms: SJF • Shortest Job First (SJF) – Choose the job with the shortest next CPU burst – Provably optimal for minimizing average waiting time • Problem: – Impossible to know the length of the next CPU burst P1 P2P3 0 15 21 24 P1P2 P3 0 3 9 24 P2 P3
  • 7. Scheduling Algorithms SRTF • SJF can be either preemptive or non-preemptive – New, short job arrives; current process has long time to execute • Preemptive SJF is called shortest remaining time first P1 P2 P3 0 6 2110 P1P3 P1 P2 0 6 2410 13
  • 8. • Approximate next CPU-burst duration – from the durations of the previous bursts • The past can be a good predictor of the future • No need to remember entire past history • Use exponential average: tnduration of the nth CPU burst τn+1 predicted duration of the (n+1)st CPU burst τn+1 = α tn + (1- α) τn where 0 ≤ α ≤ 1 α determines the weight placed on past behavior Shortest Job First Prediction
  • 9. Priority Scheduling • Priority Scheduling – Choose next job based on priority – For SJF, priority = expected CPU burst – Can be either preemptive or non-preemptive • Problem: – Starvation: jobs can wait indefinitely • Solution to starvation – Age processes: increase priority as a function of waiting time
  • 10. Round Robin • Round Robin (RR) – Often used for timesharing – Ready queue is treated as a circular queue (FIFO) – Each process is given a time slice called a quantum – It is run for the quantum or until it blocks – RR allocates the CPU uniformly (fairly) across participants. – If average queue length is n, each participant gets 1/n
  • 11. RR with Time Quantum = 20 Process Burst Time P1 53 P2 17 P3 68 P4 24 • The Gantt chart is: • Higher average turnaround than SJF, • But better response time P1 P2 P3 P4 P1 P3 P4 P1 P3 P3 0 20 37 57 77 97 117 121 134 154 162
  • 12. Turnaround Time w/ Time Quanta
  • 13. RR: Choice of Time Quantum • Performance depends on length of the timeslice – Context switching isn’t a free operation. – If timeslice time is set too high • attempting to amortize context switch cost, you get FCFS. • i.e. processes will finish or block before their slice is up anyway – If it’s set too low • you’re spending all of your time context switching between threads. – Timeslice frequently set to ~100 milliseconds – Context switches typically cost < 1 millisecond Moral: Context switch is usually negligible (< 1% per timeslice) unless you context switch too frequently and lose all productivity
  • 14. Scheduling Algorithms • Multi-level Queue Scheduling • Implement multiple ready queues based on job “type” – interactive processes – CPU-bound processes – batch jobs – system processes – student programs • Different queues may be scheduled using different algos • Intra-queue CPU allocation is either strict or proportional • Problem: Classifying jobs into queues is difficult – A process may have CPU-bound phases as well as interactive ones
  • 15. Multilevel Queue Scheduling System Processes Interactive Processes Batch Processes Student Processes Lowest priority Highest priority
  • 16. Scheduling Algorithms • Multi-level Feedback Queues • Implement multiple ready queues – Different queues may be scheduled using different algorithms – Just like multilevel queue scheduling, but assignments are not static • Jobs move from queue to queue based on feedback – Feedback = The behavior of the job, • e.g. does it require the full quantum for computation, or • does it perform frequent I/O ? • Very general algorithm • Need to select parameters for: – Number of queues – Scheduling algorithm within each queue – When to upgrade and downgrade a job
  • 17. Multilevel Feedback Queues Quantum = 2 Quantum = 4 Quantum = 8 FCFS Lowest priority Highest priority
  • 19. Thread Scheduling Since all threads share code & data segments • Option 1: Ignore this fact • Option 2: Gang scheduling – run all threads belonging to a process together (multiprocessor only) – if a thread needs to synchronize with another thread • the other one is available and active • Option 3: Two-level scheduling: – Medium level scheduler – schedule processes, and within each process, schedule threads – reduce context switching overhead and improve cache hit ratio • Option 4: Space-based affinity: – assign threads to processors (multiprocessor only) – improve cache hit ratio, but can bite under low-load condition
  • 20. Real-time Scheduling • Real-time processes have timing constraints – Expressed as deadlines or rate requirements • Common RT scheduling policies – Rate monotonic • Just one scalar priority related to the periodicity of the job • Priority = 1/rate • Static – Earliest deadline first (EDF) • Dynamic but more complex • Priority = deadline • Both require admission control to provide guarantees
  • 21. Postscript • The best schemes are adaptive. • To do absolutely best we’d have to predict the future. – Most current algorithms give highest priority to those that need the least! • Scheduling become increasingly ad hoc over the years. – 1960s papers very math heavy, now mostly “tweak and see”
  • 22. Problem • What are metrics that schedulers should optimize for ? – There are many, the right choice depends on the context • Suppose: – You own an airline, have one expensive plane, and passengers waiting all around the globe – You own a sweatshop, and need to evaluate workers – You are at a restaurant, and are waiting for food – You are an efficiency expert, and are evaluating government procedures at the DMV – You are trying to find a project partner or a co-author – You own a software company that would like to deliver a product by a deadline