SlideShare a Scribd company logo
1 of 22
Download to read offline
CPU
Scheduling
Algorithms
1
Group No. 2
Overview
 Basic Concepts
 Scheduling Criteria
 Scheduling Algorithms
 Implementation in C++
 Demonstration
 Involvement of Operating System
2
CPU Scheduling Algorithms
CPU Scheduling Algorithms 3
Basic Concepts
 Main objective of multiprogramming is to keep on
running processes all the time for maximum CPU
utilization.
 Scheduling is fundamental function of OS.
 The task of selecting the processes in memory that
are ready to execute, and allocating them to the
CPU is performed by the CPU Scheduler.
4
CPU Scheduler
 CPU scheduling decisions may take place when a
process:
o 1. Switches from running to waiting state
o 2. Switches from running to ready state
o 3. Switches from waiting to ready
o 4. Terminates
 Scheduling under 1 and 4 is non preemptive.
 All other scheduling is preemptive.
CPU Scheduling Algorithms
5
 Nonpreemptive
Once a process is allocated the CPU, it does not
leave unless:
o it has to wait, e.g., for I/O request
o it terminates
 Preemptive
o OS can force (preempt) a process from CPU at
anytime
o E.g., to allocate CPU to another higher-priority
process
CONT…
CPU Scheduling Algorithms
CPU Scheduler
6
Scheduling Criteria
 CPU utilization: keep the CPU as busy as possible
◦ Maximize
 Throughput: No of processes that complete their
execution per time unit
◦ Maximize
 Turnaround time: amount of time to execute a
particular process (time from submission to
termination)
◦ Minimize
CPU Scheduling Algorithms
7
CONT…
CPU Scheduling Algorithms
 Waiting time: amount of time a process has been
waiting in the ready queue (sum of time waiting in
ready queue)
o Minimize
 Response time – amount of time it takes from when
a request was submitted until the first response is
produced, not output (for time-sharing
environment)
o Minimize
Scheduling Criteria
8
Scheduling Algorithms
 First Come, First Served
 Shortest Job First
 Priority
 Round Robin
CPU Scheduling Algorithms
9
CPU Scheduling Algorithms
Implementation in C++
 Class: cpuschedule
 Attributes:
o n – number of processes
o Bu[ ] – Array to store Burst Time
o A[ ] – Array to store Arrival Time
o Wt[ ] – Array to store Waiting Time
o Twt – Total Waiting Time
o Awt – Average Waiting Time
10
CPU Scheduling Algorithms
Implementation in C++
o Getdata() – To get number of processes and
Burst Times from the user
o Fcfs() – First Come, First Served Algorithm
o Sjf() – Shortest Job First (normal) Algorithm
o SjfP() – Shortest Job First (Preemption)
Algorithm
o SjfNp() – Shortest Job First (non
preemption) Algorithm
o Priority() – Priority Algorithm
o RoundRobin() – Round Robin Algorithm
CONT…
 Operations:
11
Process Burst Time
P1 24
P2 3
P3 3
 Suppose that the processes arrive in the order:
P1 , P2 , P3
 The Gantt Chart for the schedule is:
 Waiting time for P1 = 0; P2 = 24; P3 = 27
 Average waiting time: (0 + 24 + 27)/3 = 17
CPU Scheduling Algorithms
First Come, First Served
P1 P2 P3
24 27 30
0
12
 Suppose that the processes arrive in the order :
P2 , P3 , P1 (P1:24,P2:3,P3:3)
 The Gantt chart for the schedule is:
 Waiting time for P1 = 6;P2 = 0; P3 = 3
 Average waiting time: (6 + 0 + 3)/3 = 3
 Much better than previous case
 Convoy effect - short process behind long process
CONT…
CPU Scheduling Algorithms
First Come First
Served
P1
P3
P2
6
3 30
0
13
CPU Scheduling Algorithms
Shortest Job First
Normal SJF
Process Burst Time
P1 7
P2 3
P3 4
 The Gantt Chart for SJF (Normal) is:
 Average waiting time = (0 + 3 + 7)/3 = 3.33
P2 P3 P1
7
3
0 14
14
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
 The Gantt Chart for SJF (non-preemptive) is:
 Average waiting time = (0 + 6 + 3 + 7)/4 = 4
Non-Preemptive SJF
CPU Scheduling Algorithms
Shortest Job First
CONT…
P1 P3 P2
7
2 16
0
P4
8 12
4 5
15
CONT…
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
 The Gantt Chart for SJF (preemptive) is:
 Average waiting time = (9 + 1 + 0 +2)/4 = 3
P1 P3
P2
4
2 11
0
P4
5 7
P2 P1
16
CPU Scheduling Algorithms
Preemptive SJF
Shortest Job First
 Associate with each process the length of its next CPU
burst.
 Use these lengths to schedule the process with the
shortest time.
 Two schemes:
o Non-Preemptive: once CPU given to the process it
cannot be preempted until completes its CPU burst.
o Preemptive: if a new process arrives with CPU burst
length less than remaining time of current executing
process, preempt. This scheme is know as the
Shortest-Remaining-Time-First (SRTF).
 SJF is optimal: gives minimum average waiting time for a
given set of processes.
Shortest Job First
CONT…
CPU Scheduling Algorithms 16
17
CPU Scheduling Algorithms
Priority
Process Burst Time Priority
P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2
 Gantt Chart
 Average waiting time = (6 + 0 + 16 + 18 + 1)/5 = 8.2
P2 P1
P5
6
1 16
0
P3
18
P4
19
 A priority number (integer) is associated with each
process.
 Lager the CPU burst lower the priority.
 The CPU is allocated to the process with the highest
priority (smallest integer ≡ highest priority)
 Starvation (Infinity blocking): low priority processes
may never execute.
 Aging: as time progresses increase the priority of the
process.
Priority
CONT…
CPU Scheduling Algorithms 18
19
CPU Scheduling Algorithms
Round Robin
Process Burst Time
P1 24
P2 3
P3 3
 Quantum time = 4 milliseconds
 The Gantt chart is:
 Average waiting time = {[0+(10-4)]+4+7}/3 = 5.6
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
 Typically, higher average turnaround than SJF, but
better response
 Each process gets a small unit of CPU time (time
quantum), usually 10-100 milliseconds. After this
time has elapsed, the process is preempted and
added to the end of the ready queue.
 Performance
o q large ⇒ FCFS
o q small ⇒ q must be large with respect to
context switch, otherwise overhead is too high
CPU Scheduling Algorithms 20
Round Robin
CONT…
CPU Scheduling Algorithms 21
Involvement of OS
Source Code (.c)
Conversion
Executable (.exe)
Compiler
Microsoft
Windows
Micro-kernel
(.i , .o)
Memory
CPU
(load executable
directly to memory)
Execut
e
Scheduling
Algorithms
CPU
Scheduling
Algorithms
Group No. 2 22
Group No. 2

More Related Content

Similar to cpu schduling ppt.pdf (20)

Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
 
Priority scheduling algorithms
Priority scheduling algorithmsPriority scheduling algorithms
Priority scheduling algorithms
 
CH06.pdf
CH06.pdfCH06.pdf
CH06.pdf
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Fcfs and sjf
Fcfs and sjfFcfs and sjf
Fcfs and sjf
 
CPU Scheduling.pdf
CPU Scheduling.pdfCPU Scheduling.pdf
CPU Scheduling.pdf
 
Sa by shekhar
Sa by shekharSa by shekhar
Sa by shekhar
 
Ch6
Ch6Ch6
Ch6
 
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
 
OSCh6
OSCh6OSCh6
OSCh6
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Ch5
Ch5Ch5
Ch5
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Ch05
Ch05Ch05
Ch05
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

cpu schduling ppt.pdf

  • 2. Overview  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Implementation in C++  Demonstration  Involvement of Operating System 2 CPU Scheduling Algorithms
  • 3. CPU Scheduling Algorithms 3 Basic Concepts  Main objective of multiprogramming is to keep on running processes all the time for maximum CPU utilization.  Scheduling is fundamental function of OS.  The task of selecting the processes in memory that are ready to execute, and allocating them to the CPU is performed by the CPU Scheduler.
  • 4. 4 CPU Scheduler  CPU scheduling decisions may take place when a process: o 1. Switches from running to waiting state o 2. Switches from running to ready state o 3. Switches from waiting to ready o 4. Terminates  Scheduling under 1 and 4 is non preemptive.  All other scheduling is preemptive. CPU Scheduling Algorithms
  • 5. 5  Nonpreemptive Once a process is allocated the CPU, it does not leave unless: o it has to wait, e.g., for I/O request o it terminates  Preemptive o OS can force (preempt) a process from CPU at anytime o E.g., to allocate CPU to another higher-priority process CONT… CPU Scheduling Algorithms CPU Scheduler
  • 6. 6 Scheduling Criteria  CPU utilization: keep the CPU as busy as possible ◦ Maximize  Throughput: No of processes that complete their execution per time unit ◦ Maximize  Turnaround time: amount of time to execute a particular process (time from submission to termination) ◦ Minimize CPU Scheduling Algorithms
  • 7. 7 CONT… CPU Scheduling Algorithms  Waiting time: amount of time a process has been waiting in the ready queue (sum of time waiting in ready queue) o Minimize  Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment) o Minimize Scheduling Criteria
  • 8. 8 Scheduling Algorithms  First Come, First Served  Shortest Job First  Priority  Round Robin CPU Scheduling Algorithms
  • 9. 9 CPU Scheduling Algorithms Implementation in C++  Class: cpuschedule  Attributes: o n – number of processes o Bu[ ] – Array to store Burst Time o A[ ] – Array to store Arrival Time o Wt[ ] – Array to store Waiting Time o Twt – Total Waiting Time o Awt – Average Waiting Time
  • 10. 10 CPU Scheduling Algorithms Implementation in C++ o Getdata() – To get number of processes and Burst Times from the user o Fcfs() – First Come, First Served Algorithm o Sjf() – Shortest Job First (normal) Algorithm o SjfP() – Shortest Job First (Preemption) Algorithm o SjfNp() – Shortest Job First (non preemption) Algorithm o Priority() – Priority Algorithm o RoundRobin() – Round Robin Algorithm CONT…  Operations:
  • 11. 11 Process Burst Time P1 24 P2 3 P3 3  Suppose that the processes arrive in the order: P1 , P2 , P3  The Gantt Chart for the schedule is:  Waiting time for P1 = 0; P2 = 24; P3 = 27  Average waiting time: (0 + 24 + 27)/3 = 17 CPU Scheduling Algorithms First Come, First Served P1 P2 P3 24 27 30 0
  • 12. 12  Suppose that the processes arrive in the order : P2 , P3 , P1 (P1:24,P2:3,P3:3)  The Gantt chart for the schedule is:  Waiting time for P1 = 6;P2 = 0; P3 = 3  Average waiting time: (6 + 0 + 3)/3 = 3  Much better than previous case  Convoy effect - short process behind long process CONT… CPU Scheduling Algorithms First Come First Served P1 P3 P2 6 3 30 0
  • 13. 13 CPU Scheduling Algorithms Shortest Job First Normal SJF Process Burst Time P1 7 P2 3 P3 4  The Gantt Chart for SJF (Normal) is:  Average waiting time = (0 + 3 + 7)/3 = 3.33 P2 P3 P1 7 3 0 14
  • 14. 14 Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4  The Gantt Chart for SJF (non-preemptive) is:  Average waiting time = (0 + 6 + 3 + 7)/4 = 4 Non-Preemptive SJF CPU Scheduling Algorithms Shortest Job First CONT… P1 P3 P2 7 2 16 0 P4 8 12 4 5
  • 15. 15 CONT… Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4  The Gantt Chart for SJF (preemptive) is:  Average waiting time = (9 + 1 + 0 +2)/4 = 3 P1 P3 P2 4 2 11 0 P4 5 7 P2 P1 16 CPU Scheduling Algorithms Preemptive SJF Shortest Job First
  • 16.  Associate with each process the length of its next CPU burst.  Use these lengths to schedule the process with the shortest time.  Two schemes: o Non-Preemptive: once CPU given to the process it cannot be preempted until completes its CPU burst. o Preemptive: if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF).  SJF is optimal: gives minimum average waiting time for a given set of processes. Shortest Job First CONT… CPU Scheduling Algorithms 16
  • 17. 17 CPU Scheduling Algorithms Priority Process Burst Time Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2  Gantt Chart  Average waiting time = (6 + 0 + 16 + 18 + 1)/5 = 8.2 P2 P1 P5 6 1 16 0 P3 18 P4 19
  • 18.  A priority number (integer) is associated with each process.  Lager the CPU burst lower the priority.  The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority)  Starvation (Infinity blocking): low priority processes may never execute.  Aging: as time progresses increase the priority of the process. Priority CONT… CPU Scheduling Algorithms 18
  • 19. 19 CPU Scheduling Algorithms Round Robin Process Burst Time P1 24 P2 3 P3 3  Quantum time = 4 milliseconds  The Gantt chart is:  Average waiting time = {[0+(10-4)]+4+7}/3 = 5.6 P1 P2 P3 P1 P1 P1 P1 P1 0 4 7 10 14 18 22 26 30
  • 20.  Typically, higher average turnaround than SJF, but better response  Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue.  Performance o q large ⇒ FCFS o q small ⇒ q must be large with respect to context switch, otherwise overhead is too high CPU Scheduling Algorithms 20 Round Robin CONT…
  • 21. CPU Scheduling Algorithms 21 Involvement of OS Source Code (.c) Conversion Executable (.exe) Compiler Microsoft Windows Micro-kernel (.i , .o) Memory CPU (load executable directly to memory) Execut e Scheduling Algorithms