Professional Documents
Culture Documents
a) Draw Gantt charts illustrating the execution of these processes using the following
scheduling algorithm:
(1) FCFS
ANSWER:
P1 P2 P3 P4 P5 P6
0 10 18 30 34 49 57
(2) Non-preemptive SJF
ANSWER:
P4 P2 P6 P1 P3 P5
0 4 12 20 30 42 57
2. NON-PREEMPTIVE SJR
Waiting Time
P4 = 0
P2 = 4 = (0+4+12+20+30+46) /6
P6 = 12 = 108 /6
P1 = 20 = 18
P3 = 30
P5 = 42
3. PREEMPTIVE SJF
Waiting Time
P1 = 0 10 9 8
P2 = 4 8 7 = (8+7+11+3+14+7) /6
P3 = 7 12 11 = 50 /6
P4 = 8 4 3 = 8.3
P5 = 12 15 14
P6 = 14 8 7
4. NON-PREEMPTIVE PRIORITY
Waiting Time
WT = TT – CPU BURST
P1 = 10 – 10 = 0
P2 = 18 – 8 = 10 AWT = (0+10+38+2+10+23) /6
P3 = 50 – 12 = 38 = 13.8
P4 = 6 – 4 = 2
P5 = 25 – 15 = 10
P6 = 31 – 8 = 23
5. PREEMPTIVE PRIORITY
Waiting Time
WT = TT – CPU BURST
P1 = 40 – 10 = 30
P2 = 30 – 8 = 22 AWT = (30+22+40+2+2+26) /6
P3 = 52 – 12 = 40 = 122/6
P4 = 6 – 4 = 2 = 20.3
P5 = 17 – 15 = 2
P6 = 34 – 8 = 26
Republic of the Philippines
Region IV-A CALABARZON
Laguna State Polytechnic University
Santa Cruz, Campus
Province of Laguna
c) Calculate the average turnaround time when using each of the above scheduling
algorithms.
ANSWERS:
1. FCFS
Turn Around Time
P1 = 10
P2 = 18 ATAT = (10+18+30+34+49+57) /6
P3 = 30 = 198 /6
P4 = 34 = 33
P5 = 49
P6 = 57
2. NON-PREEMPTIVE SJF
Turn Around Time
P4 = 4
P2 = 12 ATAT = (4+12+20+30+42+57) /6
P6 = 20 = 165 /6
P1 = 30 = 27.5
P3 = 42
P5 = 57
3. PREEMPTIVE SJF
Turn Around Time
P1 = 0 10 9 8
P2 = 4 8 7 = (8+7+11+3+14+7) /6
P3 = 7 12 11 = 50 /6
P4 = 8 4 3 = 8.3
P5 = 12 15 14
P6 = 14 8 7
4. NON-PREEMPTIVE SJF
Turn Around Time
P1 = 10 – 0 = 10
P2 = 22 – 4 = 18 ATAT = (10+18+50+6+25+31) /6
P3 = 57 – 7 = 50 = 140 /6
P4 = 14 – 8 = 6 = 23.3
P5 = 37 – 12 = 25
P6 = 45 – 14 = 31
Republic of the Philippines
Region IV-A CALABARZON
Laguna State Polytechnic University
Santa Cruz, Campus
Province of Laguna
2. Which of the following scheduling algorithms could result in starvation, and why?
a. First‐come, first‐served
b. Shortest job first
c. Round robin
d. Priority
ANSWER
FCFS (first-come, first-served) scheduling is the simplest scheduling method, however it can cause short cycles to
stick around for unusually lengthy periods of time. Starvation may have negative consequences for both need and
SJF scheduling.