0% found this document useful (0 votes)
132 views8 pages

A CPU: FCFS, - STF, SRTF (STF), R - R ( 12)

The document provides examples of applying four CPU scheduling algorithms (FCFS, non-preemptive SJF, preemptive SJF, and round-robin) to different job queues. It shows the Gantt charts produced by each algorithm on three sample job queues with different process arrival times and durations. The examples illustrate how the different scheduling algorithms prioritize and order the processes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views8 pages

A CPU: FCFS, - STF, SRTF (STF), R - R ( 12)

The document provides examples of applying four CPU scheduling algorithms (FCFS, non-preemptive SJF, preemptive SJF, and round-robin) to different job queues. It shows the Gantt charts produced by each algorithm on three sample job queues with different process arrival times and durations. The examples illustrate how the different scheduling algorithms prioritize and order the processes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1

Phùng Thị Khánh Linh


18020763

1. APPLY THE CPU SCHEDULING ALGORITHMS: FCFS,


NON-PREEMPTIVE STF, SRTF (PREEMPTIVE STF),
ROUND-ROBIN (WITH TIME QUANTUM=12) FOR
FOLLOWING QUEUES.

1.1. GIVEN THE LIST OF THE PROCESSES IN THE FOLLOWING QUEUE IN THE
FORM OF DURATION P1 (45), P2(23), P3(10), P4(3), P5(17)

Process Arrival Time Duration


P1 0 45
P2 0 23
P3 0 10
P4 0 3
P5 0 17

• FCFS

P1 P2 P3 P4 P5
0 45 68 78 81 98

• NON-PREEMPTIVE STF

P4 P3 P5 P2 P1
0 3 13 30 53 98

• SRTF

P4 P3 P5 P2 P1
0 3 13 30 53 98

• ROUND-ROBIN (quantum=12)

P1 P2 P3 P4 P5 P1 P2 P5 P1 P1
0 12 24 34 37 49 61 72 77 89 98
2
Phùng Thị Khánh Linh
18020763

1.2. GIVEN THE LIST OF THE PROCESSES IN THE FOLLOWING QUEUE IN THE FORM OF
DURATION P1 (4), P2(45), P3(5), P4(33), P5(71)

Process Arrival Time Duration


P1 0 4
P2 0 45
P3 0 5
P4 0 33
P5 0 71

• FCFS

P1 P2 P3 P4 P5
0 4 49 54 87 158

• NON-PREEMPTIVE STF
P1 P3 P4 P2 P5
0 4 9 42 87 158

• SRTF
P1 P3 P4 P2 P5
0 4 9 42 87 158

• ROUND-ROBIN (quantum=12)

P1 P2 P3 P4 P5 P2 P4 P5 P2 P4 P5 P2 P5 P5 P5
0 4 16 21 33 45 57 69 81 93 102 114 123 135 147 158
3
Phùng Thị Khánh Linh
18020763

1.3. GIVEN THE LIST OF THE PROCESSES IN THE FOLLOWING QUEUE IN THE FORM OF
DURATION P1 (49), P2(45), P3(15), P4(73)

Process Arrival Time Duration


P1 0 49
P2 0 45
P3 0 15
P4 0 73

• FCFS

P1 P2 P3 P4
0 49 94 109 182

• NON-PREEMPTIVE STF
P3 P2 P1 P4
0 15 60 109 182

• SRTF

P3 P2 P1 P4
0 15 60 109 182

• ROUND-ROBIN (quantum=12)

P1 P2 P3 P4 P1 P2 P3 P4 P1 P2 P4 P1 P2 P4 P1 P4 P4 P4
0 12 24 36 48 60 72 75 87 99 111 123 135 144 156 157 169 181 182
4
Phùng Thị Khánh Linh
18020763

2. APPLY THE CPU SCHEDULING ALGORITHMS: FCFS,


NON-PREEMPTIVE STF, SRTF (PREEMPTIVE STF),
ROUND-ROBIN (WITH TIME QUANTUM=15) FOR
FOLLOWING QUEUES.

2.1 GIVEN THE LIST OF THE PROCESSES IN THE FOLLOWING QUEUE IN THE
FORM OF (ARRIVAL TIME, DURATION) P1 (0, 45), P2(3, 23), P3(8, 10),
P4(12, 3), P5(40, 17)

Process Arrival Time Duration


P1 0 45
P2 3 23
P3 8 10
P4 12 3
P5 40 17

• FCFS

P1 P2 P3 P4 P5
0 45 68 78 81 98

• NON-PREEMPTIVE STF
P1 P4 P3 P5 P2
0 45 48 58 75 98

• SRTF
P1 P2 P3 P4 P3 P2 P1 P5 P1
0 3 8 12 15 21 39 40 57 98

• ROUND-ROBIN (quantum=15)

P1 P2 P3 P4 P5 P1 P2 P5 P1
0 15 30 40 43 58 73 81 83 98
5
Phùng Thị Khánh Linh
18020763

2.2 GIVEN THE LIST OF THE PROCESSES IN THE FOLLOWING QUEUE IN THE FORM OF
(ARRIVAL TIME, DURATION) P1 (0, 4), P2(5, 45), P3(8, 5), P4(10, 33), P5(15,
71)

Process Arrival Time Duration


P1 0 4
P2 5 45
P3 8 5
P4 10 33
P5 15 71

• FCFS
P1 P2 P3 P4 P5
0 4 5 50 55 88 159

• NON-PREEMPTIVE STF
P1 P2 P3 P4 P5
0 4 5 50 55 88 159

• SRTF

P1 P2 P3 P4 P2 P5
0 4 5 8 13 46 88 159

• ROUND-ROBIN (quantum = 15)


P1 P2 P3 P4 P5 P2 P4 P5 P2 P4 P5 P5 P5
0 4 5 20 25 40 55 70 85 100 115 118 133 148 159
6
Phùng Thị Khánh Linh
18020763

2.3 GIVEN THE LIST OF THE PROCESSES IN THE FOLLOWING QUEUE IN THE FORM OF
(ARRIVAL TIME, DURATION) P1 (0, 49), P2(17, 45), P3(20, 15), P4(31, 73)

Process Arrival Time Duration


P1 0 49
P2 17 45
P3 20 15
P4 31 73

• FCFS

P1 P2 P3 P4
0 49 94 109 182

• NON-PREEMPTIVE STF

P1 P3 P2 P4
0 49 64 109 182

• SRTF
P1 P3 P1 P2 P5
0 20 35 64 109 182

• ROUND-ROBIN (quantum = 15)


P1 P1 P2 P3 P1 P4 P2 P1 P4 P2 P4 P4 P4
0 15 30 45 60 75 90 105 109 124 139 154 169 182
7
Phùng Thị Khánh Linh
18020763

3 EVALUATE THE ABOVE ALGORITHMS WITH THE METRICS:


THROUGHPUT, TURNAROUND TIME, RESPONSE TIME,
WAITING TIME AS WELL AS THEIR AVERAGE VALUES

First, let's use the example in exercise 2.1 to consider:


Process Arrival Time Duration
P1 0 45
P2 3 23
P3 8 10
P4 12 3
P5 40 17

• FCFS

P1 P2 P3 P4 P5
0 45 68 78 81 98

• NON-PREEMPTIVE STF

P1 P4 P3 P5 P2
0 45 48 58 75 98

• SRTF
P1 P2 P3 P4 P3 P2 P1 P5 P1
0 3 8 12 15 21 39 40 57 98

• ROUND-ROBIN (quantum=15)

P1 P2 P3 P4 P1 P2 P5 P1 P1
0 15 30 40 43 58 66 81 96 98
8
Phùng Thị Khánh Linh
18020763

We have the following table:

THROUGHPUT TURNAROUNF REPONSE TIME WAITING TIME


TIME = Time at which = Turnaround
= Completion the process gets time - Burst
Time - Arrival the CPU for the Time(Duration)
Time first time -
Arrival time
FCFS (45+23+10+3+17)/5 [(45-0) + (68-3) + [(0-0) + (45-3) + [(45-0-45) + (68-
(78-8) + (81-12) + (68-8) + (78-12) 3-23) + (78-8-10)
(98-40)] / 5 + (81-40)] / 5 + (81-12-3) + (98-
40-17)] / 5

= 19.6 (s) = 61.4 (s) = 41.8 (s) = 41.8 (s)


STF (45+23+10+3+17)/5 [(45-0) + (48-12) [(0-0) + (45-12) + [(45-0-45) + (48-
+ (58-8) + (75-40) (48-8) + (58-40) 12-3) + (58-8-10)
+ (98-3)] / 5 + (75-3)] / 5 + (75-40-17) +
(98-3-23)] / 5
= 19.6 (s) = 52.2 (s) = 32.6 (s) = 32.6 (s)
SRTF (45+23+10+3+17)/5 [(98-0) + (39-3) + [(0-0) + (3-3) + [(98-0-45) + (39-
(21-8) + (15-12) + (8-8) + (12-12) + 3-23) + (21-8-10)
(57-40)] / 5 (40-40)] / 5 + (15-12-3) + (57-
40-17)] / 5
= 19.6 (s) = 33.4 (s) = 0 (s) = 13.8 (s)
ROUND-ROBIN (45+23+10+3+17)/5 [(96-0) + (66-3) + [(0-0) + (15-3) + [(96-0-45) + (66-
(40-8) + (43-12) + (30-8) + (40-12) 3-23) + (40-8-10)
(98-40)] / 5 + (66-40)] / 5 + (43-12-3) + (98-
40-17)] / 5
= 19.6 (s) = 56 (s) = 17.6 (s) = 36.4 (s)

Conclude:
- THROUGHPUT: All 4 algorithms have the same value (19.6s)
- TURNAROUNF TIME: SRTF algorithm is the smallest (33.4s), FCFS algorithm is the
biggest (61.4s)
- REPONSE TIME: SRTF algorithm is the smallest (0s), FCFS algorithm is the biggest
(41.8s)
- WAITING TIME: SRTF algorithm is the smallest (13.8s), FCFS algorithm is the biggest
(41.8s)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy