0% found this document useful (0 votes)
10 views17 pages

TranQuocVietAnh HW2

The document outlines exercises related to CPU scheduling algorithms including FCFS, non-preemptive STF, SRTF, and Round-Robin with specified time quantums. It provides detailed scheduling results for various process queues, including start and end times for each process. Additionally, it includes calculations for throughput, turnaround time, waiting time, and response time for the different scheduling methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views17 pages

TranQuocVietAnh HW2

The document outlines exercises related to CPU scheduling algorithms including FCFS, non-preemptive STF, SRTF, and Round-Robin with specified time quantums. It provides detailed scheduling results for various process queues, including start and end times for each process. Additionally, it includes calculations for throughput, turnaround time, waiting time, and response time for the different scheduling methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Chapter 2 – Exercises

Full name: Tran Quoc Viet Anh


MSSV: 23021471

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)
 FCFS Scheduling:
Process Start Time End Time
0 P1 0 45
1 P2 45 68
2 P3 68 78
3 P4 78 81
4 P5 81 98

 non-preemptive STF
Process Start Time End Time
0 P4 0 3
1 P3 3 13
2 P5 13 30
3 P2 30 53
4 P5 53 98
 SRTF (preemptive STF)
Process Start Time End Time
0 P4 0 3
1 P3 3 13
2 P5 13 30
3 P2 30 53
4 P5 53 98
 Round-Robin (with time quantum=12)
Process Start Time End Time
0 P1 0 12 (P1 – 33)
1 P2 12 24 (P2 – 11)
2 P3 24 34 (P3 – done)
3 P4 34 37 (P4 – done)
4 P5 37 49 (P5 – 5)
5 P1 49 61 (P1 – 21)
6 P2 61 72 (P2 – done)
7 P5 72 77 (P5 – done)
8 P1 77 89 (P1 – 9)
9 P1 89 98 (P1 – done)

[Date] 2
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)
 FCFS Scheduling:
Process Start Time End Time
0 P1 0 4
1 P2 4 49
2 P3 49 54
3 P4 54 87
4 P5 87 158
 non-preemptive STF
Process Start Time End Time
0 P1 0 4
1 P3 4 9
2 P4 9 42
3 P2 42 87
4 P5 87 158
 SRTF (preemptive STF)
Process Start Time End Time
0 P1 0 4
1 P3 4 9
2 P4 9 42
3 P2 42 87
4 P5 87 158
 Round-Robin (with time quantum=12)
Process Start Time End Time
0 P1 0 4 (P1 – done)
1 P2 4 16 (P2 – 33)
2 P3 16 21 (P3 – done)
3 P4 21 33 (P4 – 21)
4 P5 33 45 (P5 – 59)

[Date] 3
6 P2 45 57 (P2 – 21)
7 P4 57 69 (P4 – 9)
8 P5 69 81 (P5 – 47)
9 P2 81 93 (P2 – 9)
10 P4 93 102 (P4 – done)
11 P5 102 114 (P5 – 35)
12 P2 114 123 (P2 – done)
13 P5 123 135 (P5 – 23)
14 P5 135 147 (P5 – 11)
15 P5 147 158 (P5 – done)

[Date] 4
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)
 FCFS Scheduling:
Process Start Time End Time
0 P1 0 49
1 P2 49 94
2 P3 94 109
3 P4 109 182
 non-preemptive STF
Process Start Time End Time
0 P3 0 15
1 P2 15 60
2 P1 60 109
3 P4 109 182
 SRTF (preemptive STF)
Process Start Time End Time
0 P3 0 15
1 P2 15 60
2 P1 60 109
3 P4 109 182
 Round-Robin (with time quantum=12)
Process Start Time End Time
0 P1 0 12 (P1 – 37)
1 P2 12 24 (P2 – 33)
2 P3 24 36 (P3 – 12)
3 P4 36 48 (P4 – 61)
4 P1 48 60 (P1 – 25)
6 P2 60 72 (P2 – 21)
7 P3 72 84 (P3 – done)
8 P4 84 96 (P4 – 49)

[Date] 5
9 P1 96 108 (P1 – 13)
10 P2 108 120 (P2 – 9)
11 P4 120 132 (P4 – 37)
12 P1 132 144 (P1 – 1)
13 P2 144 153 (P2 – done)
14 P4 153 165 (P4 – 25)
15 P1 165 166 (P1 – DONE)
16 P4 166 178 (P4 – 13)
17 P4 178 190 (P4 – 1)
18 P4 190 191 (P4 – done)

[Date] 6
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)
 FCFS Scheduling:
Process Start Time End Time
0 P1 0 45
1 P2 45 68
2 P3 68 78
3 P4 78 81
4 P5 81 98
- Throughput: 5/98 = 0.051
- Turnaround time:
o P1: 45 – 0 = 45
o P2: 68 – 3 = 65
o P3: 78 – 8 = 70
o P4: 81- 12 = 69
o P5: 98 – 40 = 58
- Waiting time:
o P1: 0
o P2: 45 -3 = 42
o P3: 68 – 8 = 60
o P4: 78 – 12 = 66
o P5: 81 – 40 = 41
- Response time:
o P1: 0
o P2: 45 -3 = 42
o P3: 68 – 8 = 60
o P4: 78 – 12 = 66

[Date] 7
o P5: 81 – 40 = 41

 non-preemptive STF
Process Start Time End Time
0 P1 0 45
1 P4 45 48
2 P3 48 58
3 P5 58 75
4 P2 75 98
- Throughput: 5/98 = 0.051
- Turnaround time:
o P1: 45 – 0 = 45
o P2: 98 – 3 = 95
o P3: 58 – 8 = 50
o P4: 48 – 12 = 36
o P5: 75 – 40 = 35
- Waiting time:
o P1: 0 – 0 = 0
o P2: 75 – 3 = 72
o P3: 48 – 8 = 40
o P4: 45 – 12 = 33
o P5: 58 – 40 = 18
- Response time:
o P1: 0 – 0 = 0
o P2: 75 – 3 = 72
o P3: 48 – 8 = 40
o P4: 45 – 12 = 33
o P5: 58 – 40 = 18

 SRTF (preemptive STF)


Process Start Time End Time
0 P1 0 3 (P1 – 42)

[Date] 8
1 P2 3 8 (P2 – 18)
2 P3 8 12 (P3 – 4)
3 P4 12 15 (P4 – done)
4 P3 15 19 (P3 – done)
5 P2 19 37 (P2 – done)
6 P1 37 40 (P1 – 39)
7 P5 40 57 (P5 – done)
8 P1 57 96 (P1 – done)

- Throughput: 5/96
- Turnaround time:
o P1: 96 – 0 = 96
o P2: 37 – 3 = 34
o P3: 19 – 8 = 11
o P4: 15 – 12 = 3
o P5: 57 – 40 = 17
- Waiting time:
o P1: 0 – 0 + 34 – 3 + 57 – 40 = 48
o P2: 3 – 3 + 16 – 8 = 8
o P3: 8 – 8 + 16 - 12 = 4
o P4: 12 – 12 = 0
o P5: 40 – 40 = 0
- Response time:
o P1: 0
o P2: 0
o P3: 0
o P4: 0
o P5: 0

 Round-Robin (with time quantum=15)


Process Start Time End Time

[Date] 9
0 P1 0 15
1 P1 15 30
2 P2 30 45
3 P3 45 55
4 P4 55 58
5 P1 58 73
6 P2 73 81
7 P5 81 96
8 P5 96 98

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)
 FCFS Scheduling:

[Date] 10
 non-preemptive STF

[Date] 11
 SRTF (preemptive STF)
Process Start Time End Time
0 P1 0 4 (P1 – done)
1 P2 5 8 (P2 – 42)
2 P3 8 13 (P3 – done)
3 P4 13 46 (P4 – done)
4 P2 46 88 (P2 – done)
5 P5 86 159 (P5 – done)

[Date] 12
 Round-Robin (with time quantum=15)

[Date] 13
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)
 FCFS Scheduling:

[Date] 14
 non-preemptive STF

[Date] 15
 SRTF (preemptive STF)
Process Start Time End Time
0 P1 0 20 (P1 – 29)
1 P3 20 35 (P3 – done)
2 P1 35 64 (P1 – done)
3 P2 64 109 (P2 – done)
4 P4 109 182 (P4 – done)

[Date] 16
 Round-Robin (with time quantum=15)

[Date] 17

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