SlideShare uma empresa Scribd logo
1 de 5
Baixar para ler offline
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

Mais conteúdo relacionado

Destaque

Representacíon en complemento
Representacíon en complementoRepresentacíon en complemento
Representacíon en complementosixtoverduga
 
РИФ 2016, Big data. Скрытые возможности для площадок.
РИФ 2016, Big data. Скрытые возможности для площадок.РИФ 2016, Big data. Скрытые возможности для площадок.
РИФ 2016, Big data. Скрытые возможности для площадок.Тарасов Константин
 
Say Hello 2 Bdd
Say Hello 2 BddSay Hello 2 Bdd
Say Hello 2 Bddmh_azad
 
Zambia Capital Ask - draft
Zambia Capital Ask - draftZambia Capital Ask - draft
Zambia Capital Ask - draftAndy Lehman
 
Presentatie huisstijl en website
Presentatie huisstijl en websitePresentatie huisstijl en website
Presentatie huisstijl en websiteMuziekgebouw
 
Комплаенс — новое направление для Нового поколения
Комплаенс — новое направление для Нового поколенияКомплаенс — новое направление для Нового поколения
Комплаенс — новое направление для Нового поколенияFormulaS
 
Hotel SocialBooker Facebook
Hotel SocialBooker FacebookHotel SocialBooker Facebook
Hotel SocialBooker Facebooklolagrace
 
C Documents And Settings Pmartin1 Local Settings Temporary Internet Files Co...
C  Documents And Settings Pmartin1 Local Settings Temporary Internet Files Co...C  Documents And Settings Pmartin1 Local Settings Temporary Internet Files Co...
C Documents And Settings Pmartin1 Local Settings Temporary Internet Files Co...guestc9655c
 
Closet & Storage Concepts Franchise Dealer Model 2011
Closet & Storage Concepts   Franchise Dealer Model 2011Closet & Storage Concepts   Franchise Dealer Model 2011
Closet & Storage Concepts Franchise Dealer Model 2011BobLewis
 
РИФ 2016, Курс на эффективность рекламных кампаний: опыт фарм-студии
РИФ 2016, Курс на эффективность рекламных кампаний: опыт фарм-студииРИФ 2016, Курс на эффективность рекламных кампаний: опыт фарм-студии
РИФ 2016, Курс на эффективность рекламных кампаний: опыт фарм-студииТарасов Константин
 
Do Donts Samenwerking
Do Donts SamenwerkingDo Donts Samenwerking
Do Donts SamenwerkingJGB de Groot
 
Copywriting for the reluctant
Copywriting for the reluctantCopywriting for the reluctant
Copywriting for the reluctantRellyAB
 
Salida Desde Roma 1
Salida  Desde Roma 1Salida  Desde Roma 1
Salida Desde Roma 1corrycor
 

Destaque (20)

Representacíon en complemento
Representacíon en complementoRepresentacíon en complemento
Representacíon en complemento
 
РИФ 2016, Big data. Скрытые возможности для площадок.
РИФ 2016, Big data. Скрытые возможности для площадок.РИФ 2016, Big data. Скрытые возможности для площадок.
РИФ 2016, Big data. Скрытые возможности для площадок.
 
Doc 122-1304426774-110504025944-phpapp01
Doc 122-1304426774-110504025944-phpapp01Doc 122-1304426774-110504025944-phpapp01
Doc 122-1304426774-110504025944-phpapp01
 
Say Hello 2 Bdd
Say Hello 2 BddSay Hello 2 Bdd
Say Hello 2 Bdd
 
Philosophy foroldage
Philosophy foroldagePhilosophy foroldage
Philosophy foroldage
 
Zambia Capital Ask - draft
Zambia Capital Ask - draftZambia Capital Ask - draft
Zambia Capital Ask - draft
 
Et dieu crea_la_mer
Et dieu crea_la_merEt dieu crea_la_mer
Et dieu crea_la_mer
 
Presentatie huisstijl en website
Presentatie huisstijl en websitePresentatie huisstijl en website
Presentatie huisstijl en website
 
Комплаенс — новое направление для Нового поколения
Комплаенс — новое направление для Нового поколенияКомплаенс — новое направление для Нового поколения
Комплаенс — новое направление для Нового поколения
 
Hotel SocialBooker Facebook
Hotel SocialBooker FacebookHotel SocialBooker Facebook
Hotel SocialBooker Facebook
 
23
2323
23
 
Garden Spot Village Tour
Garden Spot Village TourGarden Spot Village Tour
Garden Spot Village Tour
 
C Documents And Settings Pmartin1 Local Settings Temporary Internet Files Co...
C  Documents And Settings Pmartin1 Local Settings Temporary Internet Files Co...C  Documents And Settings Pmartin1 Local Settings Temporary Internet Files Co...
C Documents And Settings Pmartin1 Local Settings Temporary Internet Files Co...
 
Closet & Storage Concepts Franchise Dealer Model 2011
Closet & Storage Concepts   Franchise Dealer Model 2011Closet & Storage Concepts   Franchise Dealer Model 2011
Closet & Storage Concepts Franchise Dealer Model 2011
 
Heb je dat_gezien._._1
Heb je dat_gezien._._1Heb je dat_gezien._._1
Heb je dat_gezien._._1
 
РИФ 2016, Курс на эффективность рекламных кампаний: опыт фарм-студии
РИФ 2016, Курс на эффективность рекламных кампаний: опыт фарм-студииРИФ 2016, Курс на эффективность рекламных кампаний: опыт фарм-студии
РИФ 2016, Курс на эффективность рекламных кампаний: опыт фарм-студии
 
Do Donts Samenwerking
Do Donts SamenwerkingDo Donts Samenwerking
Do Donts Samenwerking
 
Copywriting for the reluctant
Copywriting for the reluctantCopywriting for the reluctant
Copywriting for the reluctant
 
Link Analysis
Link AnalysisLink Analysis
Link Analysis
 
Salida Desde Roma 1
Salida  Desde Roma 1Salida  Desde Roma 1
Salida Desde Roma 1
 

Semelhante 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
 

Semelhante a Chapter6 (20)

CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
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
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
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
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
dataprocess using different technology.ppt
dataprocess using different technology.pptdataprocess using different technology.ppt
dataprocess using different technology.ppt
 
Algorithm o.s.
Algorithm o.s.Algorithm o.s.
Algorithm o.s.
 
Scheduling
SchedulingScheduling
Scheduling
 
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
 

Último

B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxpriyanshujha201
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876dlhescort
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...lizamodels9
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptxnandhinijagan9867
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentationuneakwhite
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...allensay1
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLkapoorjyoti4444
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfAmzadHosen3
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityEric T. Tung
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Serviceritikaroy0888
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...amitlee9823
 
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperityhemanthkumar470700
 

Último (20)

B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Falcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in indiaFalcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in india
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investors
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptx
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentation
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdf
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
 
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperity
 

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