You are on page 1of 7

10/11/2023

CPU
SCHEDULING
SIMULATION
BADRUS ZAMAN

Example
Process Arrival Time Activities
• Notes:
P1 0 P(6) – O(10) – P(2)
• P(x) : CPU Burst Time (time unit)
P2 1 P(3) – O(7) – P(3) • O(x) : Output Device Time (time unit)
P3 2 P(2) – I(6) – P(2) • I(x) : Input Device Time (time unit)

• What is Average Waiting Time (AWT), Average Respond Time (ART), Average Turn
Around Time (ATAT), and CPU Utilization?

For CPU Scheduling Algorithm:


• FCFS
• Non-preemptive Shortest Job First
• Preemptive Shortest Job First (Shortest Remaining Time First)
• Round Robin with Quantum=3
• Round Robin with Quantum=2

1
10/11/2023

Process Arrival Time Activities


P1 0 P(6) – O(10) – P(2)

First Come First Serve P2


P3
1
2
P(3) – O(7) – P(3)
P(2) – I(6) – P(2)

CPU P1 P2 P3 idle P1 P3 idle P2


RQ 0 1 2 6 9 11 16 17 18 20 23 26
P1(6) P2(3) P2(3) P2(3) P3(2) P1(2) P3(2) P3(2) P2(3)
P3(2) P3(2)

P1 P2
OQ
6 9 16 23
P1(10) P2(7) P2(7)
P3
IQ
11 17
P3(6)

AWT = WtP1 + WtP2 + WtP3 ART = RtP1 + RtP2 + RtP3 CPU Util = 26 – (5+3) x 100% Avg TAT = TAtP1 + TAtP2 + TAtP3
3 3 26 3
= (0+0) + (5+0) + (7+1) =0+5+7 = 18 x 100% = 69.23% = 18 + 25 + 18
3 3 26 3
= 13/3 = 4.33 time unit = 12/3 = 4.00 time unit = 61 = 20.33 time unit
3

Process Arrival Time Activities

Non-preemptive
P1 0 P(6) – O(10) – P(2)
P2 1 P(3) – O(7) – P(3)
Shortest Job First P3 2 P(2) – I(6) – P(2)

CPU P1 P3 P2 idle P3 P1 idle P2


RQ 0 1 2 6 8 11 14 16 18 23 26
P1(6) P2(3) P2(3) P2(3) P2(3) P3(2) P1(2) P2(3)
P3(2) P3(2)

P1 P2
OQ
6 11 16 23
P1(10) P2(7) P2(7)

P3
IQ
8 14
P3(6)

AWT = WtP1 + WtP2 + WtP3 ART = RtP1 + RtP2 + RtP3 CPU Util = 26 – (3+5) x 100% Avg TAT = TAtP1 + TAtP2 + TAtP3
3 3 26 3
= (0+0) + (7+0) + (4+0) =0+7+4 = 18 x 100% = 69.23% = 18 + 25 + 14
3 3 26 3
= 11/3 = 3.67 time unit = 11/3 = 3.67 time unit = 59 = 19.67 time unit
3

2
10/11/2023

Process Arrival Time Activities

Preemptive Shortest Job First


P1 0 P(6) – O(10) – P(2)
P2 1 P(3) – O(7) – P(3)
(Shortest Remaining Time First) P3 2 P(2) – I(6) – P(2)

CPU P1 P2 P3 P1 P2 P3 idle P1
RQ 0 1 2 4 6 11 12 14 16 21 23
P1(6) P2(3) P1(5) P1(5) P1(5) P2(3) P3(2) P3(2) P1(2)
P1(5) P3(2) P3(2)

P2 P1
OQ
4 11 21
P2(7) P1(10)
P3
IQ
6 12
P3(6)

AWT = WtP1 + WtP2 + WtP3 ART = RtP1 + RtP2 + RtP3 CPU Util = 23 – 5 x 100% Avg TAT = TAtP1 + TAtP2 + TAtP3
3 3 23 3
= (0+5+0) + (0+0) + (2+2) =0+0+2 = 18 x 100% = 78.26% = 23 + 13 + 14
3 3 23 3
= 9/3 = 3.00 time unit = 2/3 = 0.67 time unit = 40 = 13.33 time unit
3

Process Arrival Time Activities


P1 0 P(6) – O(10) – P(2)

Round Robin with Quantum=2 P2


P3
1
2
P(3) – O(7) – P(3)
P(2) – I(6) – P(2)

CPU P1 P2 P3 P1 P2 P1 idle P3 idle P2 idle P1


RQ 0 1 2 4 6 8 9 11 12 14 16 18 19 26 28
P1(6) P2(3) P2(3) P3(2) P1(4) P2(1) P1(2) P3(2) P2(3) P1(2)
P3(2) P1(4) P2(1) P1(2)
P1(4) P2(1)
P2 P1
OQ
9 11 16 26
P2(7) P1(10) P1(10)
P3
IQ
6 12
P3(6)

AWT = WtP1 + WtP2 + WtP3 ART = RtP1 + RtP2 + RtP3 CPU Util = 28 – (1+2+7) x 100% Avg TAT = TAtP1 + TAtP2 + TAtP3
3 3 28 3
= (0+4+1+0) + (1+4+0) + (2+0) =0+1+2 = 18 x 100% = 64.29% = 28 + 18 + 12
3 3 28 3
= 12/3 = 4.00 time unit = 3/3 = 1.00 time unit = 58 = 19.33 time unit
3

3
10/11/2023

Process Arrival Time Activities


P1 0 P(6) – O(10) – P(2)

Round Robin with Quantum=3 P2


P3
1
2
P(3) – O(7) – P(3)
P(2) – I(6) – P(2)

CPU P1 P2 P3 P1 idle P2 P3 idle P1


RQ 0 1 2 3 6 8 11 13 14 16 18 23 25
P1(6) P2(3) P2(3) P2(3) P3(2) P1(3) P2(3) P3(2) P3(2) P1(2)
P3(2) P3(2) P1(3)
P1(3)
P2 P1
OQ
6 11 13 23
P2(7) P1(10) P1(10)

P3
IQ
8 14
P3(6)

AWT = WtP1 + WtP2 + WtP3 ART = RtP1 + RtP2 + RtP3 CPU Util = 25 – (2+5) x 100% Avg TAT = TAtP1 + TAtP2 + TAtP3
3 3 25 3
= (0+5+0) + (2+0) + (4+2) =0+2+4 = 18 x 100% = 72.00% = 25 + 15 + 16
3 3 25 3
= 13/3 = 4.33 time unit = 6/3 = 2.00 time unit = 56 = 18.67 time unit
3

Resume CPU Scheduling Algorithm

Average Average Average Turn CPU


Waiting Time Respond Around Time Utilization
(AWT) Time (ATAT)
(ART)

FCFS 4.33 4.00 20.33 69.23%


SJF Non-preemptive 3.67 3.67 19.67 69.23%
SJF Preemptive (SRTF) 3.00 0.67 13.33 78.26%
Round Robin (Q=2) 4.00 1.00 19.33 64.29%
Round Robin (Q=3) 4.33 2.00 18.67 72.00%

4
10/11/2023

Any Question?

Task
Process Arrival Time Activities
P1 0 P(3) – I(10) – P(6)
P2 1 P(10) – O(7) – P(2)
P3 2 P(4) – I(6) – P(6)

• What is AWT, ART, ATAT, and CPU Utilization? For CPU Scheduling
Algorithm:
1. FCFS
2. Non-preemptive Shortest Job First
3. Preemptive Shortest Job First (Shortest Remaining Time First)

10

5
10/11/2023

Task D3
Process Arrival Time Activities
P1 0 P(3) – I(10) – P(6)
P2 1 P(10) – O(7) – P(2)
P3 2 P(4) – I(6) – P(6)

• What is AWT, ART, ATAT, and CPU Utilization? For CPU Scheduling
Algorithm:
1. FCFS
2. Non-preemptive Shortest Job First
3. Preemptive Shortest Job First (Shortest Remaining Time First)
1. Masing-masing mahasiswa mengerjakan 1 soal, sesuai dengan formula:
3_digit_akhir_NIM MODULO 3 + 1

11

Tugas Senin, 26 September 2022


Process Arrival Time Activities Integer
P1 0 P(4) – I(10) – P(8) 2
P2 1 P(8) – O(5) – P(5) 1
P3 2 P(6) – I(8) – P(7) 3

• What is AWT, ART, ATAT, and CPU Utilization? For CPU Scheduling
Algorithm:
1. Preemptive Priority
2. Round Robin (Q=3)
3. Round Robin (Q=4)
Masing-masing mahasiswa mengerjakan 1 soal, sesuai dengan formula:
3_digit_akhir_NIM MODULO 3 + 1
Tugas dikumpulkan via elearning pada 26 September 2022, Pukul 19.00
WIB

12

6
10/11/2023

Tugas Selasa, 27 September 2022


Process Arrival Time Activities Integer
P1 0 P(4) – I(10) – P(8) 2
P2 1 P(8) – O(5) – P(5) 1
P3 2 P(6) – I(8) – P(7) 3

• What is AWT, ART, ATAT, and CPU Utilization? For CPU Scheduling
Algorithm:
1. Preemptive Priority
2. Round Robin (Q=3)
3. Round Robin (Q=4)
Masing-masing mahasiswa mengerjakan 1 soal, sesuai dengan formula:
(3_digit_akhir_NIM MODULO 3) + 1
Tugas dikumpulkan via elearning pada 28 September 2022, Pukul 07.00
WIB

13

KUIS
• Kamis, 29 September 2022, Pukul 19.00 s.d. Selesai
• Platform: Elearning
• Bentuk soal Essay

14

You might also like