Enviar pesquisa
Carregar
OS_Ch05.pdf
•
0 gostou
•
11 visualizações
I
ismailsaleh63
Seguir
good windwos server
Leia menos
Leia mais
Tecnologia
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 179
Baixar agora
Baixar para ler offline
Recomendados
ch5_EN_CPUSched.pdf
ch5_EN_CPUSched.pdf
HoNguyn746501
U2-LP2.ppt
U2-LP2.ppt
AJAYVISHALRP
ch5_EN_CPUSched_2022.pdf
ch5_EN_CPUSched_2022.pdf
CuracaoJTR
Operating System Scheduling
Operating System Scheduling
Vishnu Prasad
cpu scheduling
cpu scheduling
hashim102
Scheduling
Scheduling
Mustafa Ugur Oduncu
Cpu scheduling
Cpu scheduling
mohsinalilarik1
OS-CPU-Scheduling-chap5.pptx
OS-CPU-Scheduling-chap5.pptx
DrAmarNathDhebla
Recomendados
ch5_EN_CPUSched.pdf
ch5_EN_CPUSched.pdf
HoNguyn746501
U2-LP2.ppt
U2-LP2.ppt
AJAYVISHALRP
ch5_EN_CPUSched_2022.pdf
ch5_EN_CPUSched_2022.pdf
CuracaoJTR
Operating System Scheduling
Operating System Scheduling
Vishnu Prasad
cpu scheduling
cpu scheduling
hashim102
Scheduling
Scheduling
Mustafa Ugur Oduncu
Cpu scheduling
Cpu scheduling
mohsinalilarik1
OS-CPU-Scheduling-chap5.pptx
OS-CPU-Scheduling-chap5.pptx
DrAmarNathDhebla
Operating systems chapter 5 silberschatz
Operating systems chapter 5 silberschatz
GiulianoRanauro
Operating System - CPU Scheduling Introduction
Operating System - CPU Scheduling Introduction
JimmyWilson26
ch6.ppt
ch6.ppt
Mohammad Fahim Abrar
CPU Scheduling
CPU Scheduling
M. Abdullah Wasif
CPU scheduling ppt file
CPU scheduling ppt file
Dwight Sabio
CPU scheduling
CPU scheduling
Amir Khan
ch_scheduling (1).ppt
ch_scheduling (1).ppt
Farhanahmad540205
Chapter4
Chapter4
poi01poi10
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
donny101
SCHEDULING.ppt
SCHEDULING.ppt
AkashJ55
Unit 2 process Management
Unit 2 process Management
zahid7578
CPU Scheduling algorithms
CPU Scheduling algorithms
Shanu Kumar
Galvin-operating System(Ch6)
Galvin-operating System(Ch6)
dsuyal1
chapter 5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
KeyreSebre
6 cpu scheduling
6 cpu scheduling
BaliThorat1
OS Process Chapter 3.pdf
OS Process Chapter 3.pdf
Kp Sharma
Round-ribon algorithm presntation
Round-ribon algorithm presntation
Jamsheed Ali
Ch6
Ch6
C.U
ch6.ppt
ch6.ppt
Umesh Hengaju
ch6.ppt
ch6.ppt
HeshmatMati
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Principled Technologies
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
UK Journal
Mais conteúdo relacionado
Semelhante a OS_Ch05.pdf
Operating systems chapter 5 silberschatz
Operating systems chapter 5 silberschatz
GiulianoRanauro
Operating System - CPU Scheduling Introduction
Operating System - CPU Scheduling Introduction
JimmyWilson26
ch6.ppt
ch6.ppt
Mohammad Fahim Abrar
CPU Scheduling
CPU Scheduling
M. Abdullah Wasif
CPU scheduling ppt file
CPU scheduling ppt file
Dwight Sabio
CPU scheduling
CPU scheduling
Amir Khan
ch_scheduling (1).ppt
ch_scheduling (1).ppt
Farhanahmad540205
Chapter4
Chapter4
poi01poi10
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
donny101
SCHEDULING.ppt
SCHEDULING.ppt
AkashJ55
Unit 2 process Management
Unit 2 process Management
zahid7578
CPU Scheduling algorithms
CPU Scheduling algorithms
Shanu Kumar
Galvin-operating System(Ch6)
Galvin-operating System(Ch6)
dsuyal1
chapter 5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
KeyreSebre
6 cpu scheduling
6 cpu scheduling
BaliThorat1
OS Process Chapter 3.pdf
OS Process Chapter 3.pdf
Kp Sharma
Round-ribon algorithm presntation
Round-ribon algorithm presntation
Jamsheed Ali
Ch6
Ch6
C.U
ch6.ppt
ch6.ppt
Umesh Hengaju
ch6.ppt
ch6.ppt
HeshmatMati
Semelhante a OS_Ch05.pdf
(20)
Operating systems chapter 5 silberschatz
Operating systems chapter 5 silberschatz
Operating System - CPU Scheduling Introduction
Operating System - CPU Scheduling Introduction
ch6.ppt
ch6.ppt
CPU Scheduling
CPU Scheduling
CPU scheduling ppt file
CPU scheduling ppt file
CPU scheduling
CPU scheduling
ch_scheduling (1).ppt
ch_scheduling (1).ppt
Chapter4
Chapter4
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
SCHEDULING.ppt
SCHEDULING.ppt
Unit 2 process Management
Unit 2 process Management
CPU Scheduling algorithms
CPU Scheduling algorithms
Galvin-operating System(Ch6)
Galvin-operating System(Ch6)
chapter 5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
6 cpu scheduling
6 cpu scheduling
OS Process Chapter 3.pdf
OS Process Chapter 3.pdf
Round-ribon algorithm presntation
Round-ribon algorithm presntation
Ch6
Ch6
ch6.ppt
ch6.ppt
ch6.ppt
ch6.ppt
Último
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Principled Technologies
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
UK Journal
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
naman860154
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Delhi Call girls
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Enterprise Knowledge
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
The Digital Insurer
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Antenna Manufacturer Coco
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
The Digital Insurer
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Gabriella Davis
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
Pixlogix Infotech
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
HampshireHUG
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
hans926745
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Igalia
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Maria Levchenko
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
wesley chun
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
Último
(20)
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
OS_Ch05.pdf
1.
Operating Systems Chapter 5:
CPU Scheduling Dr. Ahmed Hagag Scientific Computing Department, Faculty of Computers and Artificial Intelligence Benha University 2019
2.
Chapter 5: CPU
Scheduling • Basic Concepts • Scheduling Criteria • Scheduling Algorithms 2 ©Ahmed Hagag Operating Systems
3.
• CPU scheduling
is the central in multi-programming system. • Maximum CPU utilization obtained with multiprogramming (prevent CPU from being idle). • Processes residing in the main memory is selected by the Scheduler that is: ➢ Concerned with deciding a policy about which process is to be selected. ➢ Process selection based on a scheduling algorithm. 3 ©Ahmed Hagag Operating Systems Basic Concepts (1/11)
4.
4 ©Ahmed Hagag Operating
Systems Basic Concepts (2/11)
5.
5 ©Ahmed Hagag Operating
Systems Basic Concepts (2/11)
6.
• Process execution
consists of a cycle of CPU execution and I/O wait. • Processes alternate between these two states. Process execution begins with a CPU burst. That is followed by an I/O burst, which is followed by another CPU burst, then another I/O burst, and so on. • CPU bursts vary greatly from process to process and from computer to computer. 6 ©Ahmed Hagag Operating Systems Basic Concepts (3/11)
7.
Schedulers • Long-term scheduler
chooses some of them to go to memory (ready queue). • Then, short-term scheduler (or CPU scheduler) chooses from ready queue a job to run on CPU. • Medium-term scheduler may move (swap) some partially-executed jobs from memory to disk (to enhance performance). 7 ©Ahmed Hagag Operating Systems Basic Concepts (4/11)
8.
CPU Scheduler • Whenever
the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The selection process is carried out by the short-term scheduler, or CPU scheduler. 8 ©Ahmed Hagag Operating Systems Basic Concepts (5/11)
9.
CPU scheduling decisions
may take place when a process: 1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready 4. Terminates 9 ©Ahmed Hagag Operating Systems Basic Concepts (6/11)
10.
Scheduling can be •
Non-preemptive ➢ Once a process is allocated the CPU, it does not leave until terminate. • Preemptive ➢ OS can force (preempt) a process from CPU at anytime. ✓ Say, to allocate CPU to another higher-priority process. 10 ©Ahmed Hagag Operating Systems Basic Concepts (7/11)
11.
Non-preemptive and Preemptive Which
is harder to implement? and why? 11 ©Ahmed Hagag Operating Systems Basic Concepts (8/11)
12.
Non-preemptive and Preemptive •
Preemptive is harder: Need to maintain consistency of data shared between processes, and more importantly, kernel data structures (e.g., I/O queues). 12 ©Ahmed Hagag Operating Systems Basic Concepts (9/11)
13.
Dispatcher • Dispatcher module
gives control of the CPU to the process selected by the short-term scheduler; this involves: ➢ Switching context. ➢ Switching to user mode. ➢ Jumping to the proper location in the user program to restart that program. • Dispatch latency – time it takes for the dispatcher to stop one process and start another running. 13 ©Ahmed Hagag Operating Systems Basic Concepts (10/11)
14.
Dispatcher 14 ©Ahmed Hagag Operating
Systems Basic Concepts (11/11)
15.
Dispatcher 15 ©Ahmed Hagag Operating
Systems Basic Concepts (11/11)
16.
Dispatcher 16 ©Ahmed Hagag Operating
Systems Basic Concepts (11/11)
17.
Dispatcher 17 ©Ahmed Hagag Operating
Systems Basic Concepts (11/11)
18.
• CPU utilization
– keep the CPU as busy as possible. • Throughput – #of processes that complete their execution per time unit. • Turnaround time – amount of time to execute a particular process. (time from submission to termination) • Waiting time – amount of time a process has been waiting in the ready queue. • Response time – amount of time it takes from when a request was submitted until the first response is produced, not output. 18 ©Ahmed Hagag Operating Systems Scheduling Criteria (1/2)
19.
Scheduling Algorithm Optimization
Criteria • Max CPU utilization. • Max throughput. • Min turnaround time. • Min waiting time. • Min response time. 19 ©Ahmed Hagag Operating Systems Scheduling Criteria (2/2)
20.
• There are
many different CPU-scheduling algorithms: 1. First Come, First Served (FCFS). 2. Shortest Job First (SJF). ➢ Preemptive SJF. ➢ Non-Preemptive SJF. 3. Priority. 4. Round Robin. 5. Multilevel queues. 20 ©Ahmed Hagag Operating Systems Scheduling Algorithms (1/30)
21.
1. First-Come, First-Served
(FCFS) Scheduling 21 ©Ahmed Hagag Operating Systems Scheduling Algorithms (2/30) 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: Note: A process may have many CPU bursts, but in the following examples we show only one for simplicity.
22.
1. First-Come, First-Served
(FCFS) Scheduling 22 ©Ahmed Hagag Operating Systems Scheduling Algorithms (3/30) 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: P P P 1 2 3 0 24 30 27
23.
1. First-Come, First-Served
(FCFS) Scheduling 23 ©Ahmed Hagag Operating Systems Scheduling Algorithms (3/30) 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: P P P 1 2 3 0 24 30 27
24.
1. First-Come, First-Served
(FCFS) Scheduling 24 ©Ahmed Hagag Operating Systems Scheduling Algorithms (3/30) 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: P P P 1 2 3 0 24 30 27
25.
1. First-Come, First-Served
(FCFS) Scheduling 25 ©Ahmed Hagag Operating Systems Scheduling Algorithms (4/30) 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: P P P 1 2 3 0 24 30 27 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑
26.
1. First-Come, First-Served
(FCFS) Scheduling 26 ©Ahmed Hagag Operating Systems Scheduling Algorithms (4/30) 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: P P P 1 2 3 0 24 30 27 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 0 24 27 Average waiting time: (0 + 24 + 27)/3 = 17
27.
1. First-Come, First-Served
(FCFS) Scheduling 27 ©Ahmed Hagag Operating Systems Scheduling Algorithms (5/30) 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: P P P 1 2 3 0 24 30 27 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑
28.
1. First-Come, First-Served
(FCFS) Scheduling 28 ©Ahmed Hagag Operating Systems Scheduling Algorithms (5/30) 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: P P P 1 2 3 0 24 30 27 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 24 27 30 Average turnaround time: (24 + 27 + 30)/3 = 27
29.
1. First-Come, First-Served
(FCFS) Scheduling 29 ©Ahmed Hagag Operating Systems Scheduling Algorithms (6/30) 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: P P P 1 2 3 0 24 30 27 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑
30.
1. First-Come, First-Served
(FCFS) Scheduling 30 ©Ahmed Hagag Operating Systems Scheduling Algorithms (6/30) 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: P P P 1 2 3 0 24 30 27 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 0 24 27 Average response time: (0 + 24 + 27)/3 = 17
31.
1. First-Come, First-Served
(FCFS) Scheduling 31 ©Ahmed Hagag Operating Systems Scheduling Algorithms (7/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is:
32.
1. First-Come, First-Served
(FCFS) Scheduling 32 ©Ahmed Hagag Operating Systems Scheduling Algorithms (8/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is: P1 0 3 6 30 P2 P3
33.
1. First-Come, First-Served
(FCFS) Scheduling 33 ©Ahmed Hagag Operating Systems Scheduling Algorithms (8/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is: P1 0 3 6 30 P2 P3
34.
1. First-Come, First-Served
(FCFS) Scheduling 34 ©Ahmed Hagag Operating Systems Scheduling Algorithms (8/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is: P1 0 3 6 30 P2 P3
35.
1. First-Come, First-Served
(FCFS) Scheduling 35 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is: P1 0 3 6 30 P2 P3 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑
36.
1. First-Come, First-Served
(FCFS) Scheduling 36 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is: P1 0 3 6 30 P2 P3 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 6 0 3 Average waiting time: (6 + 0 + 3)/3 = 3
37.
1. First-Come, First-Served
(FCFS) Scheduling 37 ©Ahmed Hagag Operating Systems Scheduling Algorithms (10/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is: P1 0 3 6 30 P2 P3 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑
38.
1. First-Come, First-Served
(FCFS) Scheduling 38 ©Ahmed Hagag Operating Systems Scheduling Algorithms (10/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is: P1 0 3 6 30 P2 P3 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 30 3 6 Average turnaround time: (30 + 3 + 6)/3 = 13
39.
1. First-Come, First-Served
(FCFS) Scheduling 39 ©Ahmed Hagag Operating Systems Scheduling Algorithms (11/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is: P1 0 3 6 30 P2 P3 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑
40.
1. First-Come, First-Served
(FCFS) Scheduling 40 ©Ahmed Hagag Operating Systems Scheduling Algorithms (11/30) Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 The Gantt Chart for the schedule is: P1 0 3 6 30 P2 P3 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 6 0 3 Average response time: (6 + 0 + 3)/3 = 3
41.
• FCFS is
fair in the formal sense or human sense of fairness. • but it is unfair in the sense that long jobs take priority over short jobs and unimportant jobs make important jobs wait. • One of the major drawbacks of this scheme is that the waiting time and the average turnaround time is often quite long. 41 ©Ahmed Hagag Operating Systems Scheduling Algorithms (12/30) 1. First-Come, First-Served (FCFS) Scheduling
42.
• Associate with
each process the length of its next CPU burst. ➢ Use these lengths to schedule the process with the shortest time. • SJF is optimal – gives minimum average waiting time for a given set of processes. ➢ The difficulty is knowing the length of the next CPU request. ➢ Could ask the user. 42 ©Ahmed Hagag Operating Systems Scheduling Algorithms (13/30) 2. Shortest-Job-First (SJF) Scheduling
43.
2.1 Shortest-Job-First (SJF)
Scheduling 43 ©Ahmed Hagag Operating Systems Scheduling Algorithms (14/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart
44.
2.1 Shortest-Job-First (SJF)
Scheduling 44 ©Ahmed Hagag Operating Systems Scheduling Algorithms (15/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2
45.
2.1 Shortest-Job-First (SJF)
Scheduling 45 ©Ahmed Hagag Operating Systems Scheduling Algorithms (15/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2
46.
2.1 Shortest-Job-First (SJF)
Scheduling 46 ©Ahmed Hagag Operating Systems Scheduling Algorithms (15/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2
47.
2.1 Shortest-Job-First (SJF)
Scheduling 47 ©Ahmed Hagag Operating Systems Scheduling Algorithms (15/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2
48.
2.1 Shortest-Job-First (SJF)
Scheduling 48 ©Ahmed Hagag Operating Systems Scheduling Algorithms (16/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
49.
2.1 Shortest-Job-First (SJF)
Scheduling 49 ©Ahmed Hagag Operating Systems Scheduling Algorithms (16/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 3 16 9 0 Average waiting time: (3 + 16 + 9 + 0)/4 = 7
50.
2.1 Shortest-Job-First (SJF)
Scheduling 50 ©Ahmed Hagag Operating Systems Scheduling Algorithms (17/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
51.
2.1 Shortest-Job-First (SJF)
Scheduling 51 ©Ahmed Hagag Operating Systems Scheduling Algorithms (17/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 9 24 16 3 Average Turnaround time: (9 + 24 + 16 + 3)/4 = 13
52.
2.1 Shortest-Job-First (SJF)
Scheduling 52 ©Ahmed Hagag Operating Systems Scheduling Algorithms (18/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
53.
2.1 Shortest-Job-First (SJF)
Scheduling 53 ©Ahmed Hagag Operating Systems Scheduling Algorithms (18/30) ProcessArrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 SJF scheduling chart P3 0 3 24 P4 P1 16 9 P2 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 3 16 9 0 Average Response time: (3 + 16 + 9 + 0)/4 = 7
54.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 54 ©Ahmed Hagag Operating Systems Scheduling Algorithms (19/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart
55.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 55 ©Ahmed Hagag Operating Systems Scheduling Algorithms (20/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17
56.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 56 ©Ahmed Hagag Operating Systems Scheduling Algorithms (20/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17
57.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 57 ©Ahmed Hagag Operating Systems Scheduling Algorithms (20/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17
58.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 58 ©Ahmed Hagag Operating Systems Scheduling Algorithms (20/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart
59.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 59 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
60.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 60 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 (0 − 0) (1 − 1) (10 − 2) (5 − 3) Average waiting time: (0 + 0 + 8 + 2)/4 = 2.5 msec
61.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 61 ©Ahmed Hagag Operating Systems Scheduling Algorithms (22/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
62.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 62 ©Ahmed Hagag Operating Systems Scheduling Algorithms (22/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 (1 − 0) (5 − 1) (17 − 2) (10 − 3) Average Turnaround time: (1 + 4 + 15 + 7)/4 = 6.75 msec
63.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 63 ©Ahmed Hagag Operating Systems Scheduling Algorithms (23/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
64.
2.1 Shortest-Job-First (SJF)
(Non-Preemptive SJF ) 64 ©Ahmed Hagag Operating Systems Scheduling Algorithms (23/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 1 P2 1 4 P3 2 7 P4 3 5 Non-Preemptive SJF Gantt Chart Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 (0 − 0) (1 − 1) (10 − 2) (5 − 3) Average Response time: (0 + 0 + 8 + 2)/4 = 2.5 msec
65.
65 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (24/30) Determining Length of Next CPU Burst Can only estimate the length – should be similar to the previous one Then pick process with shortest predicted next CPU burst Can be done by using the length of previous CPU bursts, using exponential averaging Commonly, set to ½ Preemptive version called shortest-remaining-time-first : Define 4. 1 0 , 3. burst CPU next for the value predicted 2. burst CPU of length actual 1. 1 = = + n th n n t ( ) . 1 1 n n n t − + = =
66.
66 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (25/30) Prediction of the Length of the Next CPU Burst
67.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 67 ©Ahmed Hagag Operating Systems Scheduling Algorithms (26/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart
68.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 68 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart 0 ms
69.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 69 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart 0 ms P4 0 1 26 P1 P2 10 P3 P1 5 17
70.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 70 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 7 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart 1 ms P4 0 1 26 P1 P2 10 P3 P1 5 17
71.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 71 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 7 P2 1 4 3 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart 2 ms P4 0 1 26 P1 P2 10 P3 P1 5 17 2 3
72.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 72 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 7 P2 1 4 3 2 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart 3 ms P4 0 1 26 P1 P2 10 P3 P1 5 17 2 3
73.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 73 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 7 P2 1 4 3 2 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart 3 ms P4 0 1 26 P1 P2 10 P3 P1 5 17 2 3
74.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 74 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 7 P2 1 4 3 2 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17 5 ms
75.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 75 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 7 P2 1 4 3 2 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart 10 ms P4 0 1 26 P1 P2 10 P3 P1 5 17
76.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 76 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 7 P2 1 4 3 2 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart 17 ms P4 0 1 26 P1 P2 10 P3 P1 5 17
77.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 77 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/30) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 8 7 P2 1 4 3 2 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart 26 ms P4 0 1 26 P1 P2 10 P3 P1 5 17
78.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 78 ©Ahmed Hagag Operating Systems Scheduling Algorithms (28/30) ProcessAarri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
79.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 79 ©Ahmed Hagag Operating Systems Scheduling Algorithms (28/30) ProcessAarri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 10 − 1 1 − 1 17 − 2 5 − 3 = 𝟗 = 𝟎 = 𝟏𝟓 = 𝟐 Average waiting time = [9+0+15+2]/4 = 26/4 = 6.5 msec
80.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 80 ©Ahmed Hagag Operating Systems Scheduling Algorithms (29/30) ProcessAarri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
81.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 81 ©Ahmed Hagag Operating Systems Scheduling Algorithms (29/30) ProcessAarri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 17 − 0 5 − 1 26 − 2 10 − 3 = 𝟏𝟕 = 𝟒 = 𝟐𝟒 = 𝟕 Average turnaround time = [17+4+24+7]/4 = 52/4 = 13 msec
82.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 82 ©Ahmed Hagag Operating Systems Scheduling Algorithms (30/30) ProcessAarri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
83.
2.2 Shortest-remaining-time-first (Preemptive
SJF ) 83 ©Ahmed Hagag Operating Systems Scheduling Algorithms (30/30) ProcessAarri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart P4 0 1 26 P1 P2 10 P3 P1 5 17 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 − 0 1 − 1 17 − 2 5 − 3 = 𝟎 = 𝟎 = 𝟏𝟓 = 𝟐 Average response time = [0+0+15+2]/4 = 17/4 = 4.25 msec
84.
• CPU utilization
– keep the CPU as busy as possible. • Throughput – #of processes that complete their execution per time unit. • Turnaround time – amount of time to execute a particular process. (time from submission to termination) • Waiting time – amount of time a process has been waiting in the ready queue. • Response time – amount of time it takes from when a request was submitted until the first response is produced, not output. 84 ©Ahmed Hagag Operating Systems Scheduling Criteria (1/2)
85.
Scheduling Algorithm Optimization
Criteria • Max CPU utilization. • Max throughput. • Min turnaround time. • Min waiting time. • Min response time. 85 ©Ahmed Hagag Operating Systems Scheduling Criteria (2/2)
86.
• There are
many different CPU-scheduling algorithms: 1. First Come, First Served (FCFS). 2. Shortest Job First (SJF). ➢ Preemptive SJF. ➢ Non-Preemptive SJF. 3. Priority. 4. Round Robin. 5. Multilevel queues. 86 ©Ahmed Hagag Operating Systems Scheduling Algorithms (1/25)
87.
87 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (1/25) 3. Priority Scheduling A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer highest priority) Preemptive Nonpreemptive SJF is priority scheduling where priority is the inverse of predicted next CPU burst time Problem Starvation – low priority processes may never execute Solution Aging – as time progresses increase the priority of the process
88.
3. Priority Scheduling 88 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (2/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart
89.
3. Priority Scheduling 89 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (2/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart Highest priority
90.
3. Priority Scheduling 90 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (3/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart
91.
3. Priority Scheduling 91 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (3/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart
92.
3. Priority Scheduling 92 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (3/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart
93.
3. Priority Scheduling 93 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (3/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart
94.
3. Priority Scheduling 94 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (3/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart
95.
3. Priority Scheduling 95 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (4/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 𝑷𝟓
96.
3. Priority Scheduling 96 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (4/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 𝑷𝟓 6 0 16 18 1 Average Waiting time = [6+0+16+18+1]/5 = 8.2 msec
97.
3. Priority Scheduling 97 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (5/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 𝑷𝟓
98.
3. Priority Scheduling 98 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (5/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 𝑷𝟓 16 1 18 19 6 Average Turnaround time = [16+1+18+19+6]/5 = 12 msec
99.
3. Priority Scheduling 99 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (6/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 𝑷𝟓
100.
3. Priority Scheduling 100 ©Ahmed
Hagag Operating Systems Scheduling Algorithms (6/25) ProcessAarri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 𝑷𝟓 6 0 16 18 1 Average Response time = [6+0+16+18+1]/5 = 8.2 msec
101.
101 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (7/25) 4. Round Robin (RR) Scheduling Each process gets a small unit of CPU time (time quantum q), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are 𝑛 processes in the ready queue and the time quantum is 𝑞, then each process gets 1/𝑛 of the CPU time in chunks of at most 𝑞 time units at once. No process waits more than (𝑛 − 1)𝑞 time units.
102.
102 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (7/25) 4. Round Robin (RR) Scheduling
103.
4. Round Robin
(RR) Scheduling 103 ©Ahmed Hagag Operating Systems Scheduling Algorithms (8/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms
104.
4. Round Robin
(RR) Scheduling 104 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
105.
4. Round Robin
(RR) Scheduling 105 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
106.
4. Round Robin
(RR) Scheduling 106 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
107.
4. Round Robin
(RR) Scheduling 107 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
108.
4. Round Robin
(RR) Scheduling 108 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
109.
4. Round Robin
(RR) Scheduling 109 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
110.
4. Round Robin
(RR) Scheduling 110 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
111.
4. Round Robin
(RR) Scheduling 111 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
112.
4. Round Robin
(RR) Scheduling 112 ©Ahmed Hagag Operating Systems Scheduling Algorithms (9/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
113.
4. Round Robin
(RR) Scheduling 113 ©Ahmed Hagag Operating Systems Scheduling Algorithms (10/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms # of context switches = ?? P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
114.
4. Round Robin
(RR) Scheduling 114 ©Ahmed Hagag Operating Systems Scheduling Algorithms (10/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms # of context switches = 7 P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1
115.
4. Round Robin
(RR) Scheduling 115 ©Ahmed Hagag Operating Systems Scheduling Algorithms (11/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑
116.
4. Round Robin
(RR) Scheduling 116 ©Ahmed Hagag Operating Systems Scheduling Algorithms (11/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1 Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 0 + (10 − 4) 4 7 Average waiting time: (6 + 4 + 7)/3 = 5.667 ms
117.
4. Round Robin
(RR) Scheduling 117 ©Ahmed Hagag Operating Systems Scheduling Algorithms (12/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑
118.
4. Round Robin
(RR) Scheduling 118 ©Ahmed Hagag Operating Systems Scheduling Algorithms (12/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1 Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 30 7 10 Average Turnaround time: (30 + 7 + 10)/3 = 15.667 ms
119.
4. Round Robin
(RR) Scheduling 119 ©Ahmed Hagag Operating Systems Scheduling Algorithms (13/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑
120.
4. Round Robin
(RR) Scheduling 120 ©Ahmed Hagag Operating Systems Scheduling Algorithms (13/25) ProcessA arri Burst TimeT P1 24 P2 3 P3 3 All the processes arrive at the same time 0. Round Robin (RR) scheduling of quantum: 4 ms P P P 1 1 1 0 18 30 26 14 4 7 10 22 P2 P3 P1 P1 P1 Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 0 4 7 Average Response time: (0 + 4 + 7)/3 = 3.667 ms
121.
• There are
many different CPU-scheduling algorithms: 1. First Come, First Served (FCFS). 2. Shortest Job First (SJF). ➢ Preemptive SJF. ➢ Non-Preemptive SJF. 3. Priority. 4. Round Robin. 5. Multilevel queues. 121 ©Ahmed Hagag Operating Systems Scheduling Algorithms (14/25)
122.
122 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (15/25) 5. Multilevel Queue Scheduling Ready queue is partitioned into separate queues, eg: foreground (interactive) background (batch) Process permanently in a given queue Each queue has its own scheduling algorithm: foreground – RR. background – FCFS.
123.
123 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (16/25) 5. Multilevel Queue Scheduling Scheduling must be done between the queues: Fixed priority scheduling; (i.e., serve all from foreground then from background). Possibility of starvation. Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e., 80% to foreground in RR. 20% to background in FCFS.
124.
124 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (17/25) 5. Multilevel Queue Scheduling
125.
125 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (18/25) 5. Multilevel Queue Scheduling Three queues: Q0 – RR with time quantum 8 milliseconds Q1 – RR time quantum 16 milliseconds Q2 – FCFS
126.
126 ©Ahmed Hagag Operating
Systems Scheduling Algorithms (19/32) 5. Multilevel Queue Scheduling Scheduling A new job enters queue 𝑄0 which is served FCFS When it gains CPU, job receives 8 milliseconds. If it does not finish in 8 milliseconds, job is moved to queue 𝑄1. At 𝑄1 job is again served FCFS and receives 16 additional milliseconds If it still does not complete, it is preempted and moved to queue 𝑄2.
127.
5. Multilevel Queue
Scheduling 127 ©Ahmed Hagag Operating Systems Scheduling Algorithms (20/32) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 P3 2 20 P4 3 40 Multilevel Queue Fixed priority non-preemptive Using multi-processors or multi-core processor
128.
5. Multilevel Queue
Scheduling 128 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 P3 2 20 P4 3 40 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2
129.
5. Multilevel Queue
Scheduling 129 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 P3 2 20 P4 3 40 𝑃1 𝑄0 𝑄1 𝑄2 7ms 𝑄0 𝑄1 𝑄2 7ms
130.
5. Multilevel Queue
Scheduling 130 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 P3 2 20 P4 3 40 𝑃1 𝑄0 𝑄1 𝑄2 7ms 𝑄0 𝑄1 𝑄2 7ms 𝑃2 8ms
131.
5. Multilevel Queue
Scheduling 131 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 P3 2 20 P4 3 40 𝑃1 𝑃2 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 15ms 7ms 8ms
132.
5. Multilevel Queue
Scheduling 132 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 P3 2 20 P4 3 40 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 15ms 7ms 8ms 8ms
133.
5. Multilevel Queue
Scheduling 133 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 P3 2 20 12 P4 3 40 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 23ms 7ms 8ms 8ms
134.
5. Multilevel Queue
Scheduling 134 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 P3 2 20 12 P4 3 40 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 23ms 𝑃4 7ms 8ms 8ms 8ms
135.
5. Multilevel Queue
Scheduling 135 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 P3 2 20 12 P4 3 40 32 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 31ms 𝑃4 7ms 8ms 8ms 8ms 16ms
136.
5. Multilevel Queue
Scheduling 136 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 P3 2 20 12 P4 3 40 32 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 31ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 12ms 36ms
137.
5. Multilevel Queue
Scheduling 137 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 P3 2 20 12 P4 3 40 32 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 43ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 12ms 36ms
138.
5. Multilevel Queue
Scheduling 138 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 P3 2 20 12 P4 3 40 32 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 43ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms
139.
5. Multilevel Queue
Scheduling 139 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 59ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms
140.
5. Multilevel Queue
Scheduling 140 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 67ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms
141.
5. Multilevel Queue
Scheduling 141 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 67ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms
142.
5. Multilevel Queue
Scheduling 142 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms
143.
5. Multilevel Queue
Scheduling 143 ©Ahmed Hagag Operating Systems Scheduling Algorithms (21/32) ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms
144.
5. Multilevel Queue
Scheduling 144 ©Ahmed Hagag Operating Systems Scheduling Algorithms (22/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
145.
5. Multilevel Queue
Scheduling 145 ©Ahmed Hagag Operating Systems Scheduling Algorithms (22/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 = 𝟎
146.
5. Multilevel Queue
Scheduling 146 ©Ahmed Hagag Operating Systems Scheduling Algorithms (22/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 7 − 1 = 𝟎 = 𝟔
147.
5. Multilevel Queue
Scheduling 147 ©Ahmed Hagag Operating Systems Scheduling Algorithms (22/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 7 − 1 15 + 8 − 2 = 𝟎 = 𝟔 = 𝟐𝟏
148.
5. Multilevel Queue
Scheduling 148 ©Ahmed Hagag Operating Systems Scheduling Algorithms (22/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 7 − 1 15 + 8 − 2 23 + 12 + 8 − 3 = 𝟎 = 𝟔 = 𝟐𝟏 = 𝟒𝟎
149.
5. Multilevel Queue
Scheduling 149 ©Ahmed Hagag Operating Systems Scheduling Algorithms (23/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
150.
5. Multilevel Queue
Scheduling 150 ©Ahmed Hagag Operating Systems Scheduling Algorithms (23/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 7 − 0 = 𝟕
151.
5. Multilevel Queue
Scheduling 151 ©Ahmed Hagag Operating Systems Scheduling Algorithms (23/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 7 − 0 67 − 1 = 𝟕 = 𝟔𝟔
152.
5. Multilevel Queue
Scheduling 152 ©Ahmed Hagag Operating Systems Scheduling Algorithms (23/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 7 − 0 67 − 1 43 − 2 = 𝟕 = 𝟔𝟔 = 𝟒𝟏
153.
5. Multilevel Queue
Scheduling 153 ©Ahmed Hagag Operating Systems Scheduling Algorithms (23/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 7 − 0 67 − 1 43 − 2 83 − 3 = 𝟕 = 𝟔𝟔 = 𝟒𝟏 = 𝟖𝟎
154.
5. Multilevel Queue
Scheduling 154 ©Ahmed Hagag Operating Systems Scheduling Algorithms (24/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒
155.
5. Multilevel Queue
Scheduling 155 ©Ahmed Hagag Operating Systems Scheduling Algorithms (24/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 − 0 = 𝟎
156.
5. Multilevel Queue
Scheduling 156 ©Ahmed Hagag Operating Systems Scheduling Algorithms (24/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 − 0 7 − 1 = 𝟎 = 𝟔
157.
5. Multilevel Queue
Scheduling 157 ©Ahmed Hagag Operating Systems Scheduling Algorithms (24/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 − 0 7 − 1 15 − 2 = 𝟎 = 𝟔 = 𝟏𝟑
158.
5. Multilevel Queue
Scheduling 158 ©Ahmed Hagag Operating Systems Scheduling Algorithms (24/32) ProcessAarri Arrival TimeT P1 0 P2 1 P3 2 P4 3 𝑃1 𝑃2 𝑃2 𝑃3 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 83ms 𝑃4 7ms 8ms 8ms 𝑃2 𝑃3 8ms 16ms 𝑃4 12ms 16ms 36ms 𝑃4 16ms 7ms 67ms 59ms 43ms 31ms 15ms 23ms Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 − 0 7 − 1 15 − 2 23 − 3 = 𝟎 = 𝟔 = 𝟏𝟑 = 𝟐𝟎
159.
5. Multilevel Queue
Scheduling 159 ©Ahmed Hagag Operating Systems Scheduling Algorithms (25/32) Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 P3 2 20 P4 3 40 Multilevel Queue Fixed priority non-preemptive Using single-core processor
160.
5. Multilevel Queue
Scheduling 160 ©Ahmed Hagag Operating Systems Scheduling Algorithms (26/32) 𝑄0 𝑄1 𝑄2 𝑄0 𝑄1 𝑄2 ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 P3 2 20 P4 3 40
161.
5. Multilevel Queue
Scheduling 161 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑄0 𝑄1 𝑄2 𝑃1 𝑄0 𝑄1 𝑄2 7ms 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 P3 2 20 P4 3 40
162.
5. Multilevel Queue
Scheduling 162 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑄0 𝑄1 𝑄2 𝑃1 𝑄0 𝑄1 𝑄2 7ms 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 P3 2 20 P4 3 40
163.
5. Multilevel Queue
Scheduling 163 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms
164.
5. Multilevel Queue
Scheduling 164 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms
165.
5. Multilevel Queue
Scheduling 165 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 44 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms
166.
5. Multilevel Queue
Scheduling 166 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 36 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms
167.
5. Multilevel Queue
Scheduling 167 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 36 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms
168.
5. Multilevel Queue
Scheduling 168 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 36 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms
169.
5. Multilevel Queue
Scheduling 169 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 36 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms 𝑃4 16ms 75ms
170.
5. Multilevel Queue
Scheduling 170 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 36 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms 𝑃4 16ms 75ms 𝑃2 36ms 111ms
171.
5. Multilevel Queue
Scheduling 171 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 36 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms 𝑃4 16ms 75ms 𝑃2 36ms 111ms
172.
5. Multilevel Queue
Scheduling 172 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 36 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms 𝑃4 16ms 75ms 𝑃2 36ms 111ms127ms 𝑃4 16ms
173.
5. Multilevel Queue
Scheduling 173 ©Ahmed Hagag Operating Systems Scheduling Algorithms (27/32) 𝑃1 𝑄0 𝑄1 𝑄2 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 36 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms 𝑃4 16ms 75ms 𝑃2 36ms 111ms127ms 𝑃4 16ms
174.
5. Multilevel Queue
Scheduling 174 ©Ahmed Hagag Operating Systems Scheduling Algorithms (28/32) 𝑃1 7ms ProcessAarri Arrival TimeT Burst Time P1 0 7 P2 1 60 52 36 36 24 8 P3 2 20 12 P4 3 40 32 16 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms 𝑃4 16ms 75ms 𝑃2 36ms 111ms127ms 𝑃4 16ms
175.
5. Multilevel Queue
Scheduling 175 ©Ahmed Hagag Operating Systems Scheduling Algorithms (29/32) 𝑃1 7ms ProcessAarri Arrival TimeT P1 0 P2 1 36 24 8 P3 2 P4 3 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms 𝑃4 16ms 75ms 𝑃2 36ms 111ms127ms 𝑃4 16ms Waiting Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 6 + 16 + 28 13 + 24 20 + 28 + 36 = 𝟎 = 𝟓𝟎 = 𝟑𝟕 = 𝟖𝟒
176.
5. Multilevel Queue
Scheduling 176 ©Ahmed Hagag Operating Systems Scheduling Algorithms (30/32) 𝑃1 7ms ProcessAarri Arrival TimeT P1 0 P2 1 36 24 8 P3 2 P4 3 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms 𝑃4 16ms 75ms 𝑃2 36ms 111ms127ms 𝑃4 16ms Turnaround Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 7 − 0 111 − 1 59 − 2 127 − 3 = 𝟕 = 𝟏𝟏𝟎 = 𝟓𝟕 = 𝟏𝟐𝟒
177.
5. Multilevel Queue
Scheduling 177 ©Ahmed Hagag Operating Systems Scheduling Algorithms (31/32) 𝑃1 7ms ProcessAarri Arrival TimeT P1 0 P2 1 36 24 8 P3 2 P4 3 𝑃2 8ms 7ms 15ms 𝑃3 23ms 𝑃4 8ms 31ms 8ms 𝑃2 16ms 47ms 𝑃3 12ms 59ms 𝑃4 16ms 75ms 𝑃2 36ms 111ms127ms 𝑃4 16ms Response Time 𝑷𝟏 𝑷𝟐 𝑷𝟑 𝑷𝟒 0 − 0 7 − 1 15 − 2 23 − 3 = 𝟎 = 𝟔 = 𝟏𝟑 = 𝟐𝟎
178.
Student Example: 178 ©Ahmed Hagag
Operating Systems Scheduling Algorithms (32/32) Using a Multilevel Queue Scheduling algorithm in Fig.1. Consider the following processes with the relative CPU bursts. ProcessAarri Arrival TimeT Burst Time P1 0 20 P2 1 60 P3 2 5 P4 2 40 Multilevel Queue Fixed priority non-preemptive Fig.1
179.
Dr. Ahmed Hagag ahagag@fci.bu.edu.eg https://www.youtube.com/channel/UCzYgAyyZTLfnLFjQexOKxbQ https://www.facebook.com/ahmed.hagag.71/
Baixar agora