SlideShare una empresa de Scribd logo
1 de 5
Descargar para leer sin conexión
Preemptive vs. Non-preemptive
    Chapter 6: CPU Scheduling
                                                                          Scheduling
• Always want to have CPU working                               • Non-preemptive scheduling
• Usually many processes in ready queue                            – A new process is selected to run either
   – Ready to run on CPU                                                • when a process terminates or
   – Consider a single CPU here                                         • when an explicit system request causes a wait state
                                                                          (e.g., I/O or wait for child)
• Need strategies
                                                                • Preemptive scheduling
   – Selecting next process to run
   – For allocating CPU time                                       – New process selected to run also when
   – What happens after a process does a system call?                   • An interrupt occurs
• Short-term scheduling                                                 • When new processes become ready
   – Must not take much CPU time




           Performance Criteria                                           Scheduling Algorithms
• CPU utilization                                               • First-come, First-Served (FCFS)
   – Percentage of time that CPU is busy (and not idle), over      – Complete the jobs in order of arrival
     some period of time
                                                                • Shortest Job First (SJF)
• Throughput
                                                                   – Complete the job with shortest next CPU requirement
   – Number of jobs completed per unit time                          (e.g., burst)
• Turnaround time                                                  – Provably optimal w.r.t. average waiting time
   – Time interval from submission of a process until           • Priority
     completion of the process
                                                                   – Processes have a priority number
• Waiting time                                                     – Allocate CPU to process with highest priority
   – Sum of the time periods spent in the ready queue
                                                                • Round-Robin (RR)
• Response time                                                    – Each process gets a small unit of time on CPU (time
   – Time from submission until first output/input                   quantum or time slice)
   – May approximate by time from submission until first           – For now, assume a FIFO queue of processes
     access to CPU




 FCFS: First-Come First-Served                                     Solution: Gantt Chart Method
                                                                         P1          P2    P3     P4     P5
• Implement with a FIFO ready queue
                                                                                20        32 40        56 60
• Major disadvantage can be long wait times
• Example                                                           •   Waiting times:
                                                                    •   P1: 0
   – Draw Gantt chart
                                                                    •   P2: 20
   – Compute the average wait time for processes
                                                                    •   P3: 32
     with the following burst times and queue order:
                                                                    •   P4: 40
      • P1: 20, P2: 12, P3: 8, P4: 16, P5: 4
                                                                    •   P5: 56
                                                                    •   Average wait time: 29.6




                                                                                                                                1
SJF: Shortest Job First                                                           SJF Solution
                                                                             P5 P3         P2         P4        P1
• The job with the shortest next CPU burst
                                                                              4       12        24      40            60
  time is selected
• Example (from before):                                                      •   Waiting times:
   – CPU job burst times:                                                     •   P1: 40
      • P1: 20, P2: 12, P3: 8, P4: 16, P5: 4                                  •   P2: 12
   – Draw Gantt chart and compute the average                                 •   P3: 4
     waiting time given SJF CPU scheduling                                    •   P4: 24
                                                                              •   P5: 0
                                                                              •   Average wait time: 16




                             SJF                                                      Example Estimate
• Provably shortest average wait time
                                                                            Say, α = 0.5
• However, requires future knowledge                                    •
                                                                            τ0 = 10
• May have an estimate, to predict next CPU burst                       •
   – E.g., base on last CPU burst and a number summarizing
                                                                        •   CPU burst, t = 6
     history of CPU bursts
     τn+1 = α * t + (1 - α) * τn                                        •   What is estimate of next CPU burst?
   – Where t is the last CPU burst value, α is a constant                   τ1 = 0.5 * 6 + 0.5 * 10 = 8
     indicating how much to base estimate on last CPU
     burst, and τn is the last estimate




                                                                            Which Scheduling Algorithms
            Priority Scheduling
                                                                                Can be Preemptive?
• Have to decide on a numbering scheme
   – 0 can be highest or lowest
                                                                        • FCFS (First-come, First-Served)
• FCFS as priority: all have equal priorities
                                                                            – Non-preemptive
• SJF as priority: priority is reciprocal of predicted
                                                                        • SJF (Shortest Job First)
  CPU burst
                                                                            – Can be either
• Priorities can be
                                                                            – Choice when a new job arrives
   – Internal
                                                                            – Can preempt or not
      • according to O/S factors (e.g., memory requirements)
   – External: e.g., User importance                                    • Priority
   – Static: fixed for the duration of the process                          – Can be either
   – Dynamic                                                                – Choice when a processes priority changes or when a
                                                                              higher priority process arrives
      • Changing during processing
      • E.g., as a function of amount of CPU usage, or length of time
        waiting (a solution to indefinite blocking or starvation)




                                                                                                                                   2
RR (Round Robin) Scheduling                                                                                             Solution
                                                                                                                                               completes
                                                                                                              completes      completes      completes            completes

• Give each process a unit of time (time slice,
  quantum) of execution on CPU                                                               P1 P2 P3 P4 P5 P1 P2 P3 P4 P1 P2 P4 P1 P4 P1

• Then move to next process                                                                    4     8   12   16   20   24   28   32   36    40   44   48   52   56   60

                                                                                              •     Waiting times:
• Continue until all processes completed
                                                                                              •     P1: 16 + 12 + 8 + 4 = 40
• Example
                                                                                              •     P2: 4 + 16 + 12 = 32
   – CPU job burst times & order in queue
                                                                                              •     P3: 8 + 16 = 24
        • P1: 20, P2: 12, P3: 8, P4: 16, P5: 4
                                                                                              •     P4: 12 + 16 + 8 = 36
   – Draw Gantt chart, and compute average wait time
                                                                                              •     P5: 16
                                                                                              •     Average wait time: 29.6




 Calculate Other Measurements
                                                                                              Response Time Calculations
• Response time
   – Estimate by time from job submission to time to first
     CPU dispatch                                                                             Job                  FCFS                SJF                  RR
   – Assume all jobs submitted at same time, in order given
                                                                                              P1                   0                   40                   0
• Turnaround time
   – Time interval from submission of a process until
                                                                                              P2                   20                  12                   4
     completion of the process
 FCFS                                                                                         P3                   32                  4                    8
                P1                   P2             P3           P4             P5
                               20              32         40               56        60
                                                                                              P4                   40                  24                   12
 SJF       P5 P3               P2                    P4                   P1
                                                                                              P5                   56                  0                    16
            4         12                 24               40                         60
                                                                                              Average 29.6                             16                   8
 RR        P1 P2 P3 P4 P5 P1 P2 P3 P4 P1 P2 P4 P1 P4 P1
            4   8    12   16   20   24    28   32    36    40   44   48    52   56   60




                                                                                            Performance Characterstics of
  Turnaround Time Calculations
                                                                                               Scheduling Algorithms
      Job            FCFS                 SJF                   RR
      P1             20                   60                    60                        • Different algorithms will have different
                                                                                            performance characteristics
      P2             32                   24                    44
                                                                                          • RR (Round Robin)
      P3             40                   12                    32                           – Good average response time
                                                                                                   • Important for interactive or timesharing systems
      P4             56                   40                    48
                                                                                          • SJF
      P5             60                   4                     20                           – Best average waiting time
                                                                                             – Some overhead w.r.t. estimates of CPU burst length
      Average 41.6                        28                    40.8

 Assume processes submitted at same time




                                                                                                                                                                             3
Context Switching Issues                                                                                    Example
• These calculations have not taken context switch                                        • Calculate average wait time for RR (round
  duration into account
                                                                                            robin) scheduling, for
   – In general, the context switch will take time
                                                                                             – Processes: P1: 24, P2: 4, P3: 4
   – Just like the CPU burst of a process takes time
                                                                                             – Assume this arrival order
   – Response time, wait time etc. will be affected by
     context switch time
                                                                                             – Quantum = 4; context switch time = 1
• RR (Round Robin) & quantum duration
   – The smaller the time quantum, the better the average
     response time, but the more system overhead
   – Want the quantum large compared to context switch
     time




   Solution: Average Wait Time
                                                                                                Multi-level Ready Queues
    With Context Switch Time
                                                                                          • Multiple ready queues
        P1         P2        P3          P1       P1       P1          P1       P1           – For different types of processes (e.g., system, vs. user
                                                                                               processes)
              45        9   10   14 15        19 20    24 25   29 30        34 35    39

                                                                                             – For different priority processes (e.g., Mach)
          •    P1: 0 + 11 + 4 = 15
                                                                                          • Each queue can
          •    P2: 5
                                                                                             – Have a different scheduling algorithm
          •    P3:10
                                                                                             – Receive a different amount of CPU time
          •    Average: 10                                                                   – Have movement of processes to another queue
                                                                                               (feedback);
                                                                                                • e.g., if a process uses too much CPU time, put in a lower
    (This is a case for dynamically varying the                                                   priority queue
    time quantum, as in Mach.)                                                                  • If a process is getting too little CPU time, put it in a higher
                                                                                                  priority queue




                                                                                                   Synchronization Issues
     Multiprocessor Scheduling
                                                                                          • Symmetric multiprocessing
• When a computer has more than one processor,                                            • Involves synchronization of access to global ready
  need a method of dispatching processes                                                    queue
• Types of ready queues                                                                      – E.g., only one processor must execute a job at one time
   – Local: dispatch to a specific processor
                                                                                          • Processors: CPU1, CPU2, CPU3, …
   – Global: dispatch to any processor (“load sharing”)
                                                                                          • When a processor (e.g., CPU1) accesses the ready
• Processor/process relationship                                                            queue
   – Run on only a specific processor (e.g., if it must use a                                – All other processors (CPU2, CPU3, …) must wait, and
     device on that processor’s private bus)                                                   be denied access to the ready queue
   – Run on any processor                                                                    – The accessing processor (e.g., CPU1) will remove a
• Symmetric: Each processor does own scheduling                                                process from the ready, and dispatch it on itself
                                                                                             – Then that processor will make the ready queue
• Master/slave:
                                                                                               available for use by the other CPU’s (CPU2, CPU3, …)
   – Master processor dispatches processes to slaves




                                                                                                                                                                    4
Pre-emptive Scheduling &
     Operating System Design
• With pre-emptive CPU scheduling, a new process
  can run when interrupt occurs
• What if thread A was in the middle of updating
  data structures, and was put back in ready queue
   – Either on disk or in shared memory
• If thread B also accesses same data structures
   – May access data structures in an inconsistent state
• Need mechanisms for cooperative data access
   – Both in Kernel
      •   Kernel, in general, needs to handle interrupts
      •   Don’t want to loose interrupts
      •   Real-time & multi-processor issues
      •   May need preemption in the kernel itself
   – And by multiple processes/threads




                                                           5

Más contenido relacionado

La actualidad más candente

cpu scheduling by shivam singh
cpu scheduling by shivam singhcpu scheduling by shivam singh
cpu scheduling by shivam singhshivam71291
 
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
 
Cpu scheduling(suresh)
Cpu scheduling(suresh)Cpu scheduling(suresh)
Cpu scheduling(suresh)Nagarajan
 
Ch6 CPU Scheduling galvin
Ch6 CPU Scheduling galvinCh6 CPU Scheduling galvin
Ch6 CPU Scheduling galvinShubham Singh
 
Processor / CPU Scheduling
Processor / CPU SchedulingProcessor / CPU Scheduling
Processor / CPU SchedulingIzaz Roghani
 
Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Shreya Kumar
 
CPU Scheduling Algorithm (SJF, Round-Robin, Priority)
CPU Scheduling Algorithm (SJF, Round-Robin, Priority)CPU Scheduling Algorithm (SJF, Round-Robin, Priority)
CPU Scheduling Algorithm (SJF, Round-Robin, Priority)Solaiman Hridoy
 

La actualidad más candente (20)

Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
cpu scheduling by shivam singh
cpu scheduling by shivam singhcpu scheduling by shivam singh
cpu scheduling by shivam singh
 
Process and CPU scheduler
Process and CPU schedulerProcess and CPU scheduler
Process and CPU scheduler
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Sa by shekhar
Sa by shekharSa by shekhar
Sa by shekhar
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
OSCh6
OSCh6OSCh6
OSCh6
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
 
Scheduling Algorithms
Scheduling AlgorithmsScheduling Algorithms
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
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
Cpu scheduling(suresh)
Cpu scheduling(suresh)Cpu scheduling(suresh)
Cpu scheduling(suresh)
 
Ch6 CPU Scheduling galvin
Ch6 CPU Scheduling galvinCh6 CPU Scheduling galvin
Ch6 CPU Scheduling galvin
 
9 cm402.19
9 cm402.199 cm402.19
9 cm402.19
 
Processor / CPU Scheduling
Processor / CPU SchedulingProcessor / CPU Scheduling
Processor / CPU Scheduling
 
PPT CPU
PPT CPUPPT CPU
PPT CPU
 
Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.
 
Ch05
Ch05Ch05
Ch05
 
CPU Scheduling Algorithm (SJF, Round-Robin, Priority)
CPU Scheduling Algorithm (SJF, Round-Robin, Priority)CPU Scheduling Algorithm (SJF, Round-Robin, Priority)
CPU Scheduling Algorithm (SJF, Round-Robin, Priority)
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 

Destacado

Operating system
Operating systemOperating system
Operating systemLovly Angel
 
IMPORTED VIRUS - FROM MEXICO TO FRESH MARKETS
IMPORTED VIRUS - FROM MEXICO TO FRESH MARKETSIMPORTED VIRUS - FROM MEXICO TO FRESH MARKETS
IMPORTED VIRUS - FROM MEXICO TO FRESH MARKETSNSTDA THAILAND
 
09 koshkin-optimization2010 хорошо про аудит сайта
09 koshkin-optimization2010 хорошо про аудит сайта09 koshkin-optimization2010 хорошо про аудит сайта
09 koshkin-optimization2010 хорошо про аудит сайтаТарасов Константин
 
РИФ 2016, Открытый доступ к культуре и знаниям. Создание инфраструктуры научн...
РИФ 2016, Открытый доступ к культуре и знаниям. Создание инфраструктуры научн...РИФ 2016, Открытый доступ к культуре и знаниям. Создание инфраструктуры научн...
РИФ 2016, Открытый доступ к культуре и знаниям. Создание инфраструктуры научн...Тарасов Константин
 
עקרונות לבניית תקציב הדרכה
עקרונות לבניית תקציב הדרכהעקרונות לבניית תקציב הדרכה
עקרונות לבניית תקציב הדרכהyossi koren
 
Соціальний маркетинг
Соціальний маркетингСоціальний маркетинг
Соціальний маркетингFormulaS
 
Wellness Pp Nov08.Doc
Wellness Pp Nov08.DocWellness Pp Nov08.Doc
Wellness Pp Nov08.Docdrewgrdina
 

Destacado (20)

Presentation php
Presentation phpPresentation php
Presentation php
 
Operating system
Operating systemOperating system
Operating system
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
IMPORTED VIRUS - FROM MEXICO TO FRESH MARKETS
IMPORTED VIRUS - FROM MEXICO TO FRESH MARKETSIMPORTED VIRUS - FROM MEXICO TO FRESH MARKETS
IMPORTED VIRUS - FROM MEXICO TO FRESH MARKETS
 
09 koshkin-optimization2010 хорошо про аудит сайта
09 koshkin-optimization2010 хорошо про аудит сайта09 koshkin-optimization2010 хорошо про аудит сайта
09 koshkin-optimization2010 хорошо про аудит сайта
 
РИФ 2016, Открытый доступ к культуре и знаниям. Создание инфраструктуры научн...
РИФ 2016, Открытый доступ к культуре и знаниям. Создание инфраструктуры научн...РИФ 2016, Открытый доступ к культуре и знаниям. Создание инфраструктуры научн...
РИФ 2016, Открытый доступ к культуре и знаниям. Создание инфраструктуры научн...
 
Projektijuhtimine
ProjektijuhtimineProjektijuhtimine
Projektijuhtimine
 
עקרונות לבניית תקציב הדרכה
עקרונות לבניית תקציב הדרכהעקרונות לבניית תקציב הדרכה
עקרונות לבניית תקציב הדרכה
 
ο δρόμος
ο δρόμοςο δρόμος
ο δρόμος
 
Linear equations 2-3
Linear equations   2-3Linear equations   2-3
Linear equations 2-3
 
Соціальний маркетинг
Соціальний маркетингСоціальний маркетинг
Соціальний маркетинг
 
Animal Law Talk - Maike Dorn
Animal Law Talk - Maike DornAnimal Law Talk - Maike Dorn
Animal Law Talk - Maike Dorn
 
Finding the future_online_rus
Finding the future_online_rusFinding the future_online_rus
Finding the future_online_rus
 
Clip asie sud est
Clip asie sud estClip asie sud est
Clip asie sud est
 
Uma webinar 2014 03-20
Uma webinar 2014 03-20Uma webinar 2014 03-20
Uma webinar 2014 03-20
 
Full mooningreeceh
Full mooningreecehFull mooningreeceh
Full mooningreeceh
 
MS2 Max and Min Points
MS2 Max and Min PointsMS2 Max and Min Points
MS2 Max and Min Points
 
Wellness Pp Nov08.Doc
Wellness Pp Nov08.DocWellness Pp Nov08.Doc
Wellness Pp Nov08.Doc
 
Meital 2012
Meital 2012Meital 2012
Meital 2012
 

Similar a Chapter6

Tips on High Performance Server Programming
Tips on High Performance Server ProgrammingTips on High Performance Server Programming
Tips on High Performance Server ProgrammingJoshua Zhu
 
Hardware Assisted Latency Investigations
Hardware Assisted Latency InvestigationsHardware Assisted Latency Investigations
Hardware Assisted Latency InvestigationsScyllaDB
 
OS - CPU Scheduling
OS - CPU SchedulingOS - CPU Scheduling
OS - CPU Schedulingvinay arora
 
Cpu Schedule Algorithm
Cpu Schedule AlgorithmCpu Schedule Algorithm
Cpu Schedule AlgorithmArchit Jain
 
Implementing Lightweight Networking
Implementing Lightweight NetworkingImplementing Lightweight Networking
Implementing Lightweight Networkingguest6972eaf
 
BUD17-309: IRQ prediction
BUD17-309: IRQ prediction BUD17-309: IRQ prediction
BUD17-309: IRQ prediction Linaro
 
dataprocess using different technology.ppt
dataprocess using different technology.pptdataprocess using different technology.ppt
dataprocess using different technology.pptssuserf6eb9b
 
Galvin-operating System(Ch6)
Galvin-operating System(Ch6)Galvin-operating System(Ch6)
Galvin-operating System(Ch6)dsuyal1
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdfKp Sharma
 
Scheduling Algorithms-Examples.pptx
Scheduling Algorithms-Examples.pptxScheduling Algorithms-Examples.pptx
Scheduling Algorithms-Examples.pptxRevathi Kmp
 
3 process scheduling
3 process scheduling3 process scheduling
3 process schedulingahad alam
 
Round-ribon algorithm presntation
Round-ribon algorithm presntationRound-ribon algorithm presntation
Round-ribon algorithm presntationJamsheed Ali
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithmssathish sak
 
cpu schduling ppt.pdf
cpu schduling ppt.pdfcpu schduling ppt.pdf
cpu schduling ppt.pdfSangeethaBS4
 

Similar a Chapter6 (20)

Tips on High Performance Server Programming
Tips on High Performance Server ProgrammingTips on High Performance Server Programming
Tips on High Performance Server Programming
 
Hardware Assisted Latency Investigations
Hardware Assisted Latency InvestigationsHardware Assisted Latency Investigations
Hardware Assisted Latency Investigations
 
OS - CPU Scheduling
OS - CPU SchedulingOS - CPU Scheduling
OS - CPU Scheduling
 
ch5_EN_CPUSched.pdf
ch5_EN_CPUSched.pdfch5_EN_CPUSched.pdf
ch5_EN_CPUSched.pdf
 
CPU Scheduling.pdf
CPU Scheduling.pdfCPU Scheduling.pdf
CPU Scheduling.pdf
 
Cpu Schedule Algorithm
Cpu Schedule AlgorithmCpu Schedule Algorithm
Cpu Schedule Algorithm
 
Implementing Lightweight Networking
Implementing Lightweight NetworkingImplementing Lightweight Networking
Implementing Lightweight Networking
 
Implementing Lightweight Networking
Implementing Lightweight NetworkingImplementing Lightweight Networking
Implementing Lightweight Networking
 
Extlect02
Extlect02Extlect02
Extlect02
 
BUD17-309: IRQ prediction
BUD17-309: IRQ prediction BUD17-309: IRQ prediction
BUD17-309: IRQ prediction
 
dataprocess using different technology.ppt
dataprocess using different technology.pptdataprocess using different technology.ppt
dataprocess using different technology.ppt
 
Galvin-operating System(Ch6)
Galvin-operating System(Ch6)Galvin-operating System(Ch6)
Galvin-operating System(Ch6)
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
 
Scheduling Algorithms-Examples.pptx
Scheduling Algorithms-Examples.pptxScheduling Algorithms-Examples.pptx
Scheduling Algorithms-Examples.pptx
 
3 process scheduling
3 process scheduling3 process scheduling
3 process scheduling
 
Round-ribon algorithm presntation
Round-ribon algorithm presntationRound-ribon algorithm presntation
Round-ribon algorithm presntation
 
U2-LP2.ppt
U2-LP2.pptU2-LP2.ppt
U2-LP2.ppt
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
cpu schduling ppt.pdf
cpu schduling ppt.pdfcpu schduling ppt.pdf
cpu schduling ppt.pdf
 
Presentation by adeel
Presentation by adeelPresentation by adeel
Presentation by adeel
 

Último

Lessons from Shanavas M.P. (AKA SHAN) For The Mastering in Entrepreneurship
Lessons from Shanavas M.P. (AKA SHAN) For The Mastering in EntrepreneurshipLessons from Shanavas M.P. (AKA SHAN) For The Mastering in Entrepreneurship
Lessons from Shanavas M.P. (AKA SHAN) For The Mastering in EntrepreneurshipDoge Mining Website
 
Data Analytics Strategy Toolkit and Templates
Data Analytics Strategy Toolkit and TemplatesData Analytics Strategy Toolkit and Templates
Data Analytics Strategy Toolkit and TemplatesAurelien Domont, MBA
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfJamesConcepcion7
 
Jewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreJewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreNZSG
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024Adnet Communications
 
Unveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesUnveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesDoe Paoro
 
EUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exportersEUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exportersPeter Horsten
 
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdfChris Skinner
 
Technical Leaders - Working with the Management Team
Technical Leaders - Working with the Management TeamTechnical Leaders - Working with the Management Team
Technical Leaders - Working with the Management TeamArik Fletcher
 
Psychic Reading | Spiritual Guidance – Astro Ganesh Ji
Psychic Reading | Spiritual Guidance – Astro Ganesh JiPsychic Reading | Spiritual Guidance – Astro Ganesh Ji
Psychic Reading | Spiritual Guidance – Astro Ganesh Jiastral oracle
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdfShaun Heinrichs
 
Send Files | Sendbig.comSend Files | Sendbig.com
Send Files | Sendbig.comSend Files | Sendbig.comSend Files | Sendbig.comSend Files | Sendbig.com
Send Files | Sendbig.comSend Files | Sendbig.comSendBig4
 
Strategic Project Finance Essentials: A Project Manager’s Guide to Financial ...
Strategic Project Finance Essentials: A Project Manager’s Guide to Financial ...Strategic Project Finance Essentials: A Project Manager’s Guide to Financial ...
Strategic Project Finance Essentials: A Project Manager’s Guide to Financial ...Aggregage
 
WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfJamesConcepcion7
 
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdfGUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdfDanny Diep To
 
Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Peter Ward
 
Driving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon HarmerDriving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon HarmerAggregage
 
digital marketing , introduction of digital marketing
digital marketing , introduction of digital marketingdigital marketing , introduction of digital marketing
digital marketing , introduction of digital marketingrajputmeenakshi733
 
Onemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring CapabilitiesOnemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring CapabilitiesOne Monitar
 
Environmental Impact Of Rotary Screw Compressors
Environmental Impact Of Rotary Screw CompressorsEnvironmental Impact Of Rotary Screw Compressors
Environmental Impact Of Rotary Screw Compressorselgieurope
 

Último (20)

Lessons from Shanavas M.P. (AKA SHAN) For The Mastering in Entrepreneurship
Lessons from Shanavas M.P. (AKA SHAN) For The Mastering in EntrepreneurshipLessons from Shanavas M.P. (AKA SHAN) For The Mastering in Entrepreneurship
Lessons from Shanavas M.P. (AKA SHAN) For The Mastering in Entrepreneurship
 
Data Analytics Strategy Toolkit and Templates
Data Analytics Strategy Toolkit and TemplatesData Analytics Strategy Toolkit and Templates
Data Analytics Strategy Toolkit and Templates
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdf
 
Jewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreJewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource Centre
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024
 
Unveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesUnveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic Experiences
 
EUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exportersEUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exporters
 
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
20220816-EthicsGrade_Scorecard-JP_Morgan_Chase-Q2-63_57.pdf
 
Technical Leaders - Working with the Management Team
Technical Leaders - Working with the Management TeamTechnical Leaders - Working with the Management Team
Technical Leaders - Working with the Management Team
 
Psychic Reading | Spiritual Guidance – Astro Ganesh Ji
Psychic Reading | Spiritual Guidance – Astro Ganesh JiPsychic Reading | Spiritual Guidance – Astro Ganesh Ji
Psychic Reading | Spiritual Guidance – Astro Ganesh Ji
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf
 
Send Files | Sendbig.comSend Files | Sendbig.com
Send Files | Sendbig.comSend Files | Sendbig.comSend Files | Sendbig.comSend Files | Sendbig.com
Send Files | Sendbig.comSend Files | Sendbig.com
 
Strategic Project Finance Essentials: A Project Manager’s Guide to Financial ...
Strategic Project Finance Essentials: A Project Manager’s Guide to Financial ...Strategic Project Finance Essentials: A Project Manager’s Guide to Financial ...
Strategic Project Finance Essentials: A Project Manager’s Guide to Financial ...
 
WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdf
 
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdfGUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
 
Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...
 
Driving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon HarmerDriving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon Harmer
 
digital marketing , introduction of digital marketing
digital marketing , introduction of digital marketingdigital marketing , introduction of digital marketing
digital marketing , introduction of digital marketing
 
Onemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring CapabilitiesOnemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
Onemonitar Android Spy App Features: Explore Advanced Monitoring Capabilities
 
Environmental Impact Of Rotary Screw Compressors
Environmental Impact Of Rotary Screw CompressorsEnvironmental Impact Of Rotary Screw Compressors
Environmental Impact Of Rotary Screw Compressors
 

Chapter6

  • 1. Preemptive vs. Non-preemptive Chapter 6: CPU Scheduling Scheduling • Always want to have CPU working • Non-preemptive scheduling • Usually many processes in ready queue – A new process is selected to run either – Ready to run on CPU • when a process terminates or – Consider a single CPU here • when an explicit system request causes a wait state (e.g., I/O or wait for child) • Need strategies • Preemptive scheduling – Selecting next process to run – For allocating CPU time – New process selected to run also when – What happens after a process does a system call? • An interrupt occurs • Short-term scheduling • When new processes become ready – Must not take much CPU time Performance Criteria Scheduling Algorithms • CPU utilization • First-come, First-Served (FCFS) – Percentage of time that CPU is busy (and not idle), over – Complete the jobs in order of arrival some period of time • Shortest Job First (SJF) • Throughput – Complete the job with shortest next CPU requirement – Number of jobs completed per unit time (e.g., burst) • Turnaround time – Provably optimal w.r.t. average waiting time – Time interval from submission of a process until • Priority completion of the process – Processes have a priority number • Waiting time – Allocate CPU to process with highest priority – Sum of the time periods spent in the ready queue • Round-Robin (RR) • Response time – Each process gets a small unit of time on CPU (time – Time from submission until first output/input quantum or time slice) – May approximate by time from submission until first – For now, assume a FIFO queue of processes access to CPU FCFS: First-Come First-Served Solution: Gantt Chart Method P1 P2 P3 P4 P5 • Implement with a FIFO ready queue 20 32 40 56 60 • Major disadvantage can be long wait times • Example • Waiting times: • P1: 0 – Draw Gantt chart • P2: 20 – Compute the average wait time for processes • P3: 32 with the following burst times and queue order: • P4: 40 • P1: 20, P2: 12, P3: 8, P4: 16, P5: 4 • P5: 56 • Average wait time: 29.6 1
  • 2. SJF: Shortest Job First SJF Solution P5 P3 P2 P4 P1 • The job with the shortest next CPU burst 4 12 24 40 60 time is selected • Example (from before): • Waiting times: – CPU job burst times: • P1: 40 • P1: 20, P2: 12, P3: 8, P4: 16, P5: 4 • P2: 12 – Draw Gantt chart and compute the average • P3: 4 waiting time given SJF CPU scheduling • P4: 24 • P5: 0 • Average wait time: 16 SJF Example Estimate • Provably shortest average wait time Say, α = 0.5 • However, requires future knowledge • τ0 = 10 • May have an estimate, to predict next CPU burst • – E.g., base on last CPU burst and a number summarizing • CPU burst, t = 6 history of CPU bursts τn+1 = α * t + (1 - α) * τn • What is estimate of next CPU burst? – Where t is the last CPU burst value, α is a constant τ1 = 0.5 * 6 + 0.5 * 10 = 8 indicating how much to base estimate on last CPU burst, and τn is the last estimate Which Scheduling Algorithms Priority Scheduling Can be Preemptive? • Have to decide on a numbering scheme – 0 can be highest or lowest • FCFS (First-come, First-Served) • FCFS as priority: all have equal priorities – Non-preemptive • SJF as priority: priority is reciprocal of predicted • SJF (Shortest Job First) CPU burst – Can be either • Priorities can be – Choice when a new job arrives – Internal – Can preempt or not • according to O/S factors (e.g., memory requirements) – External: e.g., User importance • Priority – Static: fixed for the duration of the process – Can be either – Dynamic – Choice when a processes priority changes or when a higher priority process arrives • Changing during processing • E.g., as a function of amount of CPU usage, or length of time waiting (a solution to indefinite blocking or starvation) 2
  • 3. RR (Round Robin) Scheduling Solution completes completes completes completes completes • Give each process a unit of time (time slice, quantum) of execution on CPU P1 P2 P3 P4 P5 P1 P2 P3 P4 P1 P2 P4 P1 P4 P1 • Then move to next process 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 • Waiting times: • Continue until all processes completed • P1: 16 + 12 + 8 + 4 = 40 • Example • P2: 4 + 16 + 12 = 32 – CPU job burst times & order in queue • P3: 8 + 16 = 24 • P1: 20, P2: 12, P3: 8, P4: 16, P5: 4 • P4: 12 + 16 + 8 = 36 – Draw Gantt chart, and compute average wait time • P5: 16 • Average wait time: 29.6 Calculate Other Measurements Response Time Calculations • Response time – Estimate by time from job submission to time to first CPU dispatch Job FCFS SJF RR – Assume all jobs submitted at same time, in order given P1 0 40 0 • Turnaround time – Time interval from submission of a process until P2 20 12 4 completion of the process FCFS P3 32 4 8 P1 P2 P3 P4 P5 20 32 40 56 60 P4 40 24 12 SJF P5 P3 P2 P4 P1 P5 56 0 16 4 12 24 40 60 Average 29.6 16 8 RR P1 P2 P3 P4 P5 P1 P2 P3 P4 P1 P2 P4 P1 P4 P1 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 Performance Characterstics of Turnaround Time Calculations Scheduling Algorithms Job FCFS SJF RR P1 20 60 60 • Different algorithms will have different performance characteristics P2 32 24 44 • RR (Round Robin) P3 40 12 32 – Good average response time • Important for interactive or timesharing systems P4 56 40 48 • SJF P5 60 4 20 – Best average waiting time – Some overhead w.r.t. estimates of CPU burst length Average 41.6 28 40.8 Assume processes submitted at same time 3
  • 4. Context Switching Issues Example • These calculations have not taken context switch • Calculate average wait time for RR (round duration into account robin) scheduling, for – In general, the context switch will take time – Processes: P1: 24, P2: 4, P3: 4 – Just like the CPU burst of a process takes time – Assume this arrival order – Response time, wait time etc. will be affected by context switch time – Quantum = 4; context switch time = 1 • RR (Round Robin) & quantum duration – The smaller the time quantum, the better the average response time, but the more system overhead – Want the quantum large compared to context switch time Solution: Average Wait Time Multi-level Ready Queues With Context Switch Time • Multiple ready queues P1 P2 P3 P1 P1 P1 P1 P1 – For different types of processes (e.g., system, vs. user processes) 45 9 10 14 15 19 20 24 25 29 30 34 35 39 – For different priority processes (e.g., Mach) • P1: 0 + 11 + 4 = 15 • Each queue can • P2: 5 – Have a different scheduling algorithm • P3:10 – Receive a different amount of CPU time • Average: 10 – Have movement of processes to another queue (feedback); • e.g., if a process uses too much CPU time, put in a lower (This is a case for dynamically varying the priority queue time quantum, as in Mach.) • If a process is getting too little CPU time, put it in a higher priority queue Synchronization Issues Multiprocessor Scheduling • Symmetric multiprocessing • When a computer has more than one processor, • Involves synchronization of access to global ready need a method of dispatching processes queue • Types of ready queues – E.g., only one processor must execute a job at one time – Local: dispatch to a specific processor • Processors: CPU1, CPU2, CPU3, … – Global: dispatch to any processor (“load sharing”) • When a processor (e.g., CPU1) accesses the ready • Processor/process relationship queue – Run on only a specific processor (e.g., if it must use a – All other processors (CPU2, CPU3, …) must wait, and device on that processor’s private bus) be denied access to the ready queue – Run on any processor – The accessing processor (e.g., CPU1) will remove a • Symmetric: Each processor does own scheduling process from the ready, and dispatch it on itself – Then that processor will make the ready queue • Master/slave: available for use by the other CPU’s (CPU2, CPU3, …) – Master processor dispatches processes to slaves 4
  • 5. Pre-emptive Scheduling & Operating System Design • With pre-emptive CPU scheduling, a new process can run when interrupt occurs • What if thread A was in the middle of updating data structures, and was put back in ready queue – Either on disk or in shared memory • If thread B also accesses same data structures – May access data structures in an inconsistent state • Need mechanisms for cooperative data access – Both in Kernel • Kernel, in general, needs to handle interrupts • Don’t want to loose interrupts • Real-time & multi-processor issues • May need preemption in the kernel itself – And by multiple processes/threads 5