BCA 4th sem
9. What is CPU Scheduling? Write does the criteria for CPU scheduling? Consider the following set of processes, with the length of the CPU burst given in millisecond , draw Gant chart illustrating their execution and calculate average waiting time using:
a) First come First serve
b) Shortest Job first
c) None-preemptive priority (smaller number implies higher priority)
d) Round robin (quantum=1)
Process | Burst Time | Priority |
P0 | 10 | 3 |
P1 | 1 | 1 |
P2 | 2 | 5 |
P3 | 1 | 4 |
P4 | 5 | 2 |
BCA 4th semester long question solution 2078
a) First Come First Serve
Solution
Process | Arrival Time (AT) | Burst Time (BT) | Completion time (CT) | Turned around Time (TAT) | Waiting Time (WT) |
P0 | 0 | 10 | 10 | 10 | 0 |
P1 | 0 | 1 | 11 | 11 | 10 |
P2 | 0 | 2 | 13 | 13 | 11 |
P3 | 0 | 1 | 14 | 14 | 13 |
P4 | 0 | 5 | 19 | 19 Total=67 | 14 Total= 48 |
Note:- CT=From Gantt chart
TAT= CT-AT
WT=TAT-BT
P0=This process come first so we start at first AT=0 here in BT= 10
P1= P0 को BT लाई P1मा जोडनु पार्ने हुन्छ । Eg, [ P0 Burst time (BT)=10+P1(1)=11]
Gantt chart
P0 | P1 | P2 | P3 | P4 |
Total Waiting Time= 0+10+11+13+14
=48
Average waiting time=Total waiting time/ process
48/6
=9.6
Total turn around Time= 10+11+13+14+19
=67
Average turn around time= Total turn around time/ Process
= 67/5
= 13.4
b) Short job first
Solution
Process | Burst Time (BT) | Priority | Completion time (CT) | Turned around Time (TAT) | Waiting Time (WT) |
P0 | 10 | 3 | 10 | 10 | 0 |
P1 | 1 | 1 | 11 | 11 | 10 |
P2 | 2 | 5 | 14 | 14 | 12 |
P3 | 1 | 4 | 12 | 12 | 11 |
P4 | 5 | 2 | 15 | 15 Total=62 | 10 Total= 43 |
P0 | P1 | P2 | P3 | P4 |
Total waiting Time=0+10+12+11+10
=43
Average waiting time= Total waiting time/process
=43/5
=8.6
Total turnaround time= 10+11+14+12+15
=62
Average turn around time= total trunaround time/Process
=62/5
=12.4
C) Non-preemptive priority (small number implies higher)
Process | Burst Time (BT) | Priority | Completion time (CT) | Turned around Time (TAT) | Waiting Time (WT) |
P0 | 10 | 3 | 10 | 10 | 0 |
P1 | 1 | 1 | 11 | 11 | 10 |
P2 | 2 | 5 | 19 | 19 | 17 |
P3 | 1 | 4 | 17 | 17 | 16 |
P4 | 5 | 2 | 16 | 16 Total=73 | 11 Total= 54 |
P0 | P1 | P2 | P3 | P4 |
Total waiting Time=0+10+17+16+11
=54
Average waiting time= Total waiting time/process
=54/5
=10.8
Total turnaround time= 10+11+19+17+16
=73
Total turn around time= total trunaround time/Process
=73/5
=14.6
d) Round Robin (quantum = 1)
Process | Burst Time (BT) | Completion time (CT) | Turned around Time (TAT) | Waiting Time (WT) |
P0 | 10 | 10 | 10 | 0 |
P1 | 1 | 11 | 11 | 10 |
P2 | 2 | 15 | 15 | 13 |
P3 | 1 | 13 | 13 | 12 |
P4 | 5 | 19 | 19 Total=68 | 15 Total= 50 |
P0 | P1 | P2 | P3 | P4 | P2 | P4 |
Total waiting Time=0+10+13+12+15
=50
Average waiting time= Total waiting time/process
=50/5
=10
Total turnaround time= 10+11+15+13+19
=68
Total turn around time= total trunaround time/Process
=68/5
=13.6
BCA 4th semester long question solution 2078
BCA 4th sem BCA 4th sem BCA 4th sem