SlideShare une entreprise Scribd logo
1  sur  22
Nov 2nd 2012




                     Julian Ilham
    Dept. of Electronic Engineering
      Pukyong National University
    Email: ilham.julian@gmail.com

1
 Introduction
 Preemptive vs Non-Preemptive

 First Come First Served (FCFS)
 Shortest Job First (SJF)
 Priority Based Scheduling
 Round Robin (RR)




                                   2
What is scheduling?

       Choosing which task to run and for how long




                     Why do we need it?


- Improve the system performance
- Support multitasking




                            3
Running task can be forced to release even
  Preemptive
                        though it is neither completed


                   Each running task keeps processing until it
Non - Preemptive
                                  completed




                                4
 Only available in Non-Preemptive mode
 Example:
                 Tasks           Arrival Times (ms)    Burst Time (ms)
                  P2                    0.0                  12
                  P3                    3.0                  8
                  P4                    5.0                  4
                  P1                   10.0                  10
                  P5                   12.0                  6


 Gantt chart
                 P2              P3         P4        P1          P5
         0                            20         24          34          40   (ms)
                3 5      10 12

                                        5
 Time Calculation
      P1 : 24 – 10 = 12 ms
      P2 : 0 ms
      P3 : 12 – 3 = 9 ms
      P4 : 20 – 5 = 15 ms
      P5 : 34 – 12 = 22 ms

Total waiting time : P1 + P2 + P3 + P4 + P5 = 58 ms
Average waiting time : 58 ms / 5 = 11.6 ms



                               6
 Advantage: Very simple code and structure

 Disadvantage: Large average waiting time




                             7
 Available in Preemptive and Non-Preemptive mode
 Example (Preemptive)
                     Tasks                Arrival Times (ms)     Burst Time (ms)
                         P2                         0.0                12
                         P3                         3.0                   8
                         P4                         5.0                   4
                         P1                         10.0               10
                         P5                         12.0                  6


 Gantt chart
           P2       P3        P4         P3           P5        P2            P1
       0                           9           15          21        30            40   (ms)
                3        5             10 12


                                                8
 Time Calculation (Preemptive)
      P1 : 30 – 10 = 20 ms
      P2 : 0 + (21 – 3) = 18 ms
      P3 : (3 – 3) + (9 – 5) = 4 ms
      P4 : 5 – 5 = 0 ms
      P5 : 15 – 12 = 3 ms

Total waiting time : P1 + P2 + P3 + P4 + P5 = 45 ms
Average waiting time : 45 ms / 5 = 9 ms



                                9
 Example (Non-Preemptive)
                Tasks           Arrival Times (ms)         Burst Time (ms)
                 P2                        0.0                   12
                 P3                        3.0                   8
                 P4                        5.0                   4
                 P1                       10.0                   10
                 P5                       12.0                   6

 Gantt chart
                 P2             P4         P5         P3              P1
       0                             16          22         30               40   (ms)
            3    5      10 12



                                          10
 Time Calculation (Non-Preemptive)
      P1 : 30 – 10 = 20 ms
      P2 : 0 ms
      P3 : 22 – 3 = 19 ms
      P4 : 12 – 5 = 7 ms
      P5 : 16 – 12 = 4 ms

Total waiting time : P1 + P2 + P3 + P4 + P5 = 50 ms
Average waiting time : 50 ms / 5 = 10 ms



                               11
 Advantage: Minimum average waiting time for a given set of
  process

 Disadvantage: Difficult to estimate burst time, starvation
  (indefinite blocking)




                               12
 Available in Preemptive and Non-Preemptive mode
 Example (Preemptive)
           Tasks        Arrival Times (ms)        Burst Time (ms)    Priority
            P2                  0.0                     12              2
            P3                  3.0                     8               5
            P4                  5.0                     4               1
            P1                  10.0                    10              4
            P5                  12.0                    6               3

 Gantt chart
           P2          P4       P2           P5          P1            P3
       0                  9            16         22            32              40   (ms)
            3      5    10 12

                                            13
 Time Calculation (Preemptive)
      P1 : 22 – 10 = 12 ms
      P2 : 9 – 5 = 4 ms
      P3 : 32 – 3 = 29 ms
      P4 : 5 – 5 = 0 ms
      P5 : 16 – 12 = 4 ms

Total waiting time : P1 + P2 + P3 + P4 + P5 = 49 ms
Average waiting time : 49 ms / 5 = 9.8 ms



                               14
 Example (Non-Preemptive)

           Tasks       Arrival Times (ms)      Burst Time (ms)    Priority
            P2                 0.0                   12              2
            P3                 3.0                   8               5
            P4                 5.0                   4               1
            P1                 10.0                  10              4
            P5                 12.0                  6               3

 Gantt chart
                 P2            P4         P5          P1            P3
                                     16        22            32              40   (ms)
            3      5   10 12


                                          15
 Time Calculation (Non-Preemptive)
      P1 : 22 – 10 = 12 ms
      P2 : 0 ms
      P3 : 32 – 3 = 29 ms
      P4 : 12 – 5 = 7 ms
      P5 : 16 – 12 = 4 ms

Total waiting time : P1 + P2 + P3 + P4 + P5 = 52 ms
Average waiting time : 52 ms / 5 = 10.4 ms



                               16
 Advantage: Easier than SJF

 Disadvantage: Can cause indefinite blocking




                               17
 Only available in Non-Preemptive mode
 FCFS is used in sequencing policy
 Need to determine time slice/ quantum as a unit of time for
  each process
 Then continue to the next process after reaching maximum of
  quantum


  - Too small time quantum -> too many tasks switched
  - Too large time quantum -> inherits the problem of FCFS




                             18
 Example (assuming quantum is 5 ms):

                  Tasks            Arrival Times (ms)        Burst Time (ms)
                   P2                        0.0                       12
                   P3                        3.0                       8
                   P4                        5.0                       4
                   P1                       10.0                       10
                   P5                       12.0                       6

 Gantt chart
0        5        10         14        19          24        29        32        37 38   40
    P2       P3         P4        P1         P5         P2        P3        P1     P5 P2


    3    5        10 12


                                            19
 Time Calculation
      P1 : (14 – 10) + (32 – 19) = 17 ms
      P2 : 0 + (24 – 5) + (38 – 29) = 28 ms
      P3 : (5 – 3) + (29 – 10) = 21 ms
      P4 : 10 – 5 = 5 ms
      P5 : (19 – 12) + (37 – 24) = 20 ms

Total waiting time : P1 + P2 + P3 + P4 + P5 = 91 ms
Average waiting time : 91 ms / 5 = 18.2 ms



                               20
 Advantage: Guarantee fairness (bounded waiting time and no
  starvation)

 Disadvantage: Average waiting time is long




                              21
Q n A




 22

Contenu connexe

Tendances

Nyquist criterion for zero ISI
Nyquist criterion for zero ISINyquist criterion for zero ISI
Nyquist criterion for zero ISIGunasekara Reddy
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.Ravi Kumar Patel
 
IF Statement
IF StatementIF Statement
IF StatementYunis20
 
Serial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceSerial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceKUET
 
Round Robin Scheduling Algorithm
Round Robin Scheduling AlgorithmRound Robin Scheduling Algorithm
Round Robin Scheduling AlgorithmAdeel Rasheed
 
CPU scheduling
CPU schedulingCPU scheduling
CPU schedulingAmir Khan
 
Fault tolerance techniques for real time operating system
Fault tolerance techniques for real time operating systemFault tolerance techniques for real time operating system
Fault tolerance techniques for real time operating systemanujos25
 
Overview of sampling
Overview of samplingOverview of sampling
Overview of samplingSagar Kumar
 
Nyquist criterion for distortion less baseband binary channel
Nyquist criterion for distortion less baseband binary channelNyquist criterion for distortion less baseband binary channel
Nyquist criterion for distortion less baseband binary channelPriyangaKR1
 
Field Programmable Gate Array: Building Blocks and Interconnections
Field Programmable Gate Array: Building Blocks and InterconnectionsField Programmable Gate Array: Building Blocks and Interconnections
Field Programmable Gate Array: Building Blocks and InterconnectionsDr. Saravanakumar Umathurai
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's typesNishant Joshi
 
Chapter 10 Operating Systems silberschatz
Chapter 10 Operating Systems silberschatzChapter 10 Operating Systems silberschatz
Chapter 10 Operating Systems silberschatzGiulianoRanauro
 
Round robin scheduling
Round robin schedulingRound robin scheduling
Round robin schedulingRaghav S
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)ritu98
 
Adaline madaline
Adaline madalineAdaline madaline
Adaline madalineNagarajan
 

Tendances (20)

Nyquist criterion for zero ISI
Nyquist criterion for zero ISINyquist criterion for zero ISI
Nyquist criterion for zero ISI
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
IF Statement
IF StatementIF Statement
IF Statement
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Sudoku solve rmain
Sudoku solve rmainSudoku solve rmain
Sudoku solve rmain
 
Serial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceSerial Communication & Embedded System Interface
Serial Communication & Embedded System Interface
 
Round Robin Scheduling Algorithm
Round Robin Scheduling AlgorithmRound Robin Scheduling Algorithm
Round Robin Scheduling Algorithm
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Fault tolerance techniques for real time operating system
Fault tolerance techniques for real time operating systemFault tolerance techniques for real time operating system
Fault tolerance techniques for real time operating system
 
Overview of sampling
Overview of samplingOverview of sampling
Overview of sampling
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Arduino IDE
Arduino IDE Arduino IDE
Arduino IDE
 
Nyquist criterion for distortion less baseband binary channel
Nyquist criterion for distortion less baseband binary channelNyquist criterion for distortion less baseband binary channel
Nyquist criterion for distortion less baseband binary channel
 
Field Programmable Gate Array: Building Blocks and Interconnections
Field Programmable Gate Array: Building Blocks and InterconnectionsField Programmable Gate Array: Building Blocks and Interconnections
Field Programmable Gate Array: Building Blocks and Interconnections
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
 
Chapter 10 Operating Systems silberschatz
Chapter 10 Operating Systems silberschatzChapter 10 Operating Systems silberschatz
Chapter 10 Operating Systems silberschatz
 
Round robin scheduling
Round robin schedulingRound robin scheduling
Round robin scheduling
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)
 
Adaline madaline
Adaline madalineAdaline madaline
Adaline madaline
 

Dernier

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Dernier (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Scheduling Algorithms

  • 1. Nov 2nd 2012 Julian Ilham Dept. of Electronic Engineering Pukyong National University Email: ilham.julian@gmail.com 1
  • 2.  Introduction  Preemptive vs Non-Preemptive  First Come First Served (FCFS)  Shortest Job First (SJF)  Priority Based Scheduling  Round Robin (RR) 2
  • 3. What is scheduling? Choosing which task to run and for how long Why do we need it? - Improve the system performance - Support multitasking 3
  • 4. Running task can be forced to release even Preemptive though it is neither completed Each running task keeps processing until it Non - Preemptive completed 4
  • 5.  Only available in Non-Preemptive mode  Example: Tasks Arrival Times (ms) Burst Time (ms) P2 0.0 12 P3 3.0 8 P4 5.0 4 P1 10.0 10 P5 12.0 6  Gantt chart P2 P3 P4 P1 P5 0 20 24 34 40 (ms) 3 5 10 12 5
  • 6.  Time Calculation P1 : 24 – 10 = 12 ms P2 : 0 ms P3 : 12 – 3 = 9 ms P4 : 20 – 5 = 15 ms P5 : 34 – 12 = 22 ms Total waiting time : P1 + P2 + P3 + P4 + P5 = 58 ms Average waiting time : 58 ms / 5 = 11.6 ms 6
  • 7.  Advantage: Very simple code and structure  Disadvantage: Large average waiting time 7
  • 8.  Available in Preemptive and Non-Preemptive mode  Example (Preemptive) Tasks Arrival Times (ms) Burst Time (ms) P2 0.0 12 P3 3.0 8 P4 5.0 4 P1 10.0 10 P5 12.0 6  Gantt chart P2 P3 P4 P3 P5 P2 P1 0 9 15 21 30 40 (ms) 3 5 10 12 8
  • 9.  Time Calculation (Preemptive) P1 : 30 – 10 = 20 ms P2 : 0 + (21 – 3) = 18 ms P3 : (3 – 3) + (9 – 5) = 4 ms P4 : 5 – 5 = 0 ms P5 : 15 – 12 = 3 ms Total waiting time : P1 + P2 + P3 + P4 + P5 = 45 ms Average waiting time : 45 ms / 5 = 9 ms 9
  • 10.  Example (Non-Preemptive) Tasks Arrival Times (ms) Burst Time (ms) P2 0.0 12 P3 3.0 8 P4 5.0 4 P1 10.0 10 P5 12.0 6  Gantt chart P2 P4 P5 P3 P1 0 16 22 30 40 (ms) 3 5 10 12 10
  • 11.  Time Calculation (Non-Preemptive) P1 : 30 – 10 = 20 ms P2 : 0 ms P3 : 22 – 3 = 19 ms P4 : 12 – 5 = 7 ms P5 : 16 – 12 = 4 ms Total waiting time : P1 + P2 + P3 + P4 + P5 = 50 ms Average waiting time : 50 ms / 5 = 10 ms 11
  • 12.  Advantage: Minimum average waiting time for a given set of process  Disadvantage: Difficult to estimate burst time, starvation (indefinite blocking) 12
  • 13.  Available in Preemptive and Non-Preemptive mode  Example (Preemptive) Tasks Arrival Times (ms) Burst Time (ms) Priority P2 0.0 12 2 P3 3.0 8 5 P4 5.0 4 1 P1 10.0 10 4 P5 12.0 6 3  Gantt chart P2 P4 P2 P5 P1 P3 0 9 16 22 32 40 (ms) 3 5 10 12 13
  • 14.  Time Calculation (Preemptive) P1 : 22 – 10 = 12 ms P2 : 9 – 5 = 4 ms P3 : 32 – 3 = 29 ms P4 : 5 – 5 = 0 ms P5 : 16 – 12 = 4 ms Total waiting time : P1 + P2 + P3 + P4 + P5 = 49 ms Average waiting time : 49 ms / 5 = 9.8 ms 14
  • 15.  Example (Non-Preemptive) Tasks Arrival Times (ms) Burst Time (ms) Priority P2 0.0 12 2 P3 3.0 8 5 P4 5.0 4 1 P1 10.0 10 4 P5 12.0 6 3  Gantt chart P2 P4 P5 P1 P3 16 22 32 40 (ms) 3 5 10 12 15
  • 16.  Time Calculation (Non-Preemptive) P1 : 22 – 10 = 12 ms P2 : 0 ms P3 : 32 – 3 = 29 ms P4 : 12 – 5 = 7 ms P5 : 16 – 12 = 4 ms Total waiting time : P1 + P2 + P3 + P4 + P5 = 52 ms Average waiting time : 52 ms / 5 = 10.4 ms 16
  • 17.  Advantage: Easier than SJF  Disadvantage: Can cause indefinite blocking 17
  • 18.  Only available in Non-Preemptive mode  FCFS is used in sequencing policy  Need to determine time slice/ quantum as a unit of time for each process  Then continue to the next process after reaching maximum of quantum - Too small time quantum -> too many tasks switched - Too large time quantum -> inherits the problem of FCFS 18
  • 19.  Example (assuming quantum is 5 ms): Tasks Arrival Times (ms) Burst Time (ms) P2 0.0 12 P3 3.0 8 P4 5.0 4 P1 10.0 10 P5 12.0 6  Gantt chart 0 5 10 14 19 24 29 32 37 38 40 P2 P3 P4 P1 P5 P2 P3 P1 P5 P2 3 5 10 12 19
  • 20.  Time Calculation P1 : (14 – 10) + (32 – 19) = 17 ms P2 : 0 + (24 – 5) + (38 – 29) = 28 ms P3 : (5 – 3) + (29 – 10) = 21 ms P4 : 10 – 5 = 5 ms P5 : (19 – 12) + (37 – 24) = 20 ms Total waiting time : P1 + P2 + P3 + P4 + P5 = 91 ms Average waiting time : 91 ms / 5 = 18.2 ms 20
  • 21.  Advantage: Guarantee fairness (bounded waiting time and no starvation)  Disadvantage: Average waiting time is long 21
  • 22. Q n A 22

Notes de l'éditeur

  1. Today, I am going to present about scheduling algoritmScheduling algorithm is method inside the operating system in order to manage many tasks
  2. There are two types of scheduling methodPreemptive = can be interruptedNon-Preemptive = New task can be run after the current task is finished (can not be interrupted)
  3. Also well known as First in First out (FIFO)