SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithmssathish sak
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)Vaibhav Bajaj
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating SystemTech_MX
 
Round Robin Scheduling Algorithm
Round Robin Scheduling AlgorithmRound Robin Scheduling Algorithm
Round Robin Scheduling AlgorithmAdeel Rasheed
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.Ravi Kumar Patel
 
Processes Control Block (Operating System)
Processes Control Block (Operating System)Processes Control Block (Operating System)
Processes Control Block (Operating System)Imdad Ullah
 
Real-Time Scheduling
Real-Time SchedulingReal-Time Scheduling
Real-Time Schedulingsathish sak
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithmsPaurav Shah
 
Harvard vs Von Neumann Architecture
Harvard vs Von Neumann ArchitectureHarvard vs Von Neumann Architecture
Harvard vs Von Neumann ArchitectureProject Student
 
Presentation on flynn’s classification
Presentation on flynn’s classificationPresentation on flynn’s classification
Presentation on flynn’s classificationvani gupta
 
FCFS scheduling OS
FCFS scheduling OSFCFS scheduling OS
FCFS scheduling OSTotan Banik
 
Real Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systemsReal Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systemsHariharan Ganesan
 

What's hot (20)

Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Round Robin Scheduling Algorithm
Round Robin Scheduling AlgorithmRound Robin Scheduling Algorithm
Round Robin Scheduling Algorithm
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
Processes Control Block (Operating System)
Processes Control Block (Operating System)Processes Control Block (Operating System)
Processes Control Block (Operating System)
 
Interrupts
InterruptsInterrupts
Interrupts
 
Real-Time Scheduling
Real-Time SchedulingReal-Time Scheduling
Real-Time Scheduling
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
Cuda
CudaCuda
Cuda
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Harvard vs Von Neumann Architecture
Harvard vs Von Neumann ArchitectureHarvard vs Von Neumann Architecture
Harvard vs Von Neumann Architecture
 
Presentation on flynn’s classification
Presentation on flynn’s classificationPresentation on flynn’s classification
Presentation on flynn’s classification
 
FCFS scheduling OS
FCFS scheduling OSFCFS scheduling OS
FCFS scheduling OS
 
Real Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systemsReal Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systems
 
Cuda tutorial
Cuda tutorialCuda tutorial
Cuda tutorial
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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...
 
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)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

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

Editor's Notes

  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)