0% found this document useful (0 votes)
7 views6 pages

1Q. First Come First Served (FCFS)

Os

Uploaded by

yoniman1352
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)
7 views6 pages

1Q. First Come First Served (FCFS)

Os

Uploaded by

yoniman1352
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/ 6

1Q.

First Come First Served (FCFS)

Given Data:

Process Arrival Time Burst Time


P1 0 10
P2 3 6
P3 7 1
P4 8 3
P5 10 4

(a) FCFS Calculations:

Start Time and Completion Time:

Process Arrival Time Burst Time Start Time Completion Time


P1 0 10 0 10
P2 3 6 10 16
P3 7 1 16 17
P4 8 3 17 20
P5 10 4 20 24

(i) Turnaround Time (TAT) and Waiting Time:

o TAT = Completion Time - Arrival Time


o Waiting Time = TAT - Burst Time

Process Arrival Time Burst Time Turnaround Time (TAT) Waiting Time
P1 0 10 10 0
P2 3 6 13 7
P3 7 1 10 9
P4 8 3 12 9
P5 10 4 14 10

(ii) Average Waiting Time and Average Turnaround Time:

o Average Waiting Time = (0 + 7 + 9 + 9 + 10) / 5 = 35 / 5 = 7


o Average Turnaround Time = (10 + 13 + 10 + 12 + 14) / 5 = 59 / 5 = 11.8

(b) Shortest Job First (SJF) - Non-Pre-emptive

Given Data:
Process Arrival Time Burst Time
P1 0 10
P2 3 6
P3 7 1
P4 8 3
P5 10 4

SJF Calculations:

Order of Execution (based on SJF):

o Initially available: P1 (0, 10)


o After P1 finishes (at time 10), the next shortest job is P3 (7, 1)
o Next available: P2 (3, 6), P4 (8, 3), P5 (10, 4)

Start Time and Completion Time:

Process Arrival Time Burst Time Start Time Completion Time


P1 0 10 0 10
P3 7 1 10 11
P2 3 6 11 17
P4 8 3 17 20
P5 10 4 20 24

Turnaround Time (TAT) and Waiting Time:

Process Arrival Time Burst Time Turnaround Time (TAT) Waiting Time
P1 0 10 10 0
P3 7 1 4 3
P2 3 6 14 8
P4 8 3 12 9
P5 10 4 14 10

Average Waiting Time and Average Turnaround Time:

i. Average Waiting Time = (0 + 3 + 8 + 9 + 10) / 5 = 30 / 5 = 6


ii. Average Turnaround Time = (10 + 4 + 14 + 12 + 14) / 5 = 54 / 5 = 10.8

2Q.

Initialization:

o Quantum time: 1 ms Quantum time


o Keep track of the remaining burst time for each process.
o Use a queue to manage the order of process execution.
Simulation:

We'll simulate each time unit and switch processes as per the Round Robin rules.

Time Process Execution Remaining Burst Times (P1, P2, P3, P4, P5)
0 P1 P1 (1ms) 9, 6, 1, 3, 4
1 P1 P1 (1ms) 8, 6, 1, 3, 4
2 P1 P1 (1ms) 7, 6, 1, 3, 4
3 P2 P2 (1ms) 7, 5, 1, 3, 4
4 P1 P1 (1ms) 6, 5, 1, 3, 4
5 P2 P2 (1ms) 6, 4, 1, 3, 4
6 P1 P1 (1ms) 5, 4, 1, 3, 4
7 P3 P3 (1ms) 5, 4, 0, 3, 4
8 P1 P1 (1ms) 4, 4, 0, 3, 4
9 P4 P4 (1ms) 4, 4, 0, 2, 4
10 P5 P5 (1ms) 4, 4, 0, 2, 3
11 P1 P1 (1ms) 3, 4, 0, 2, 3
12 P2 P2 (1ms) 3, 3, 0, 2, 3
13 P1 P1 (1ms) 2, 3, 0, 2, 3
14 P2 P2 (1ms) 2, 2, 0, 2, 3
15 P1 P1 (1ms) 1, 2, 0, 2, 3
16 P2 P2 (1ms) 1, 1, 0, 2, 3
17 P1 P1 (1ms) 0, 1, 0, 2, 3
18 P2 P2 (1ms) 0, 0, 0, 2, 3
19 P4 P4 (1ms) 0, 0, 0, 1, 3
20 P4 P4 (1ms) 0, 0, 0, 0, 3
21 P5 P5 (1ms) 0, 0, 0, 0, 2
22 P5 P5 (1ms) 0, 0, 0, 0, 1
23 P5 P5 (1ms) 0, 0, 0, 0, 0

Completion Times:

 P1: 17
 P2: 18
 P3: 7
 P4: 20
 P5: 23

Turnaround Times (TAT) and Waiting Times:

i. TAT = Completion Time - Arrival Time


ii. Waiting Time = TAT - Burst Time
Process Arrival Time Burst Time Completion Time TAT Waiting Time
P1 0 10 17 17 7
P2 3 6 18 15 9
P3 7 1 7 1 0
P4 8 3 20 12 9
P5 10 4 23 13 9

Average Waiting Time and Average Turnaround Time:

i. Average Waiting Time: (7+9+0+9+9)/5=34/5=6.8(7 + 9 + 0 + 9 + 9) / 5 = 34 / 5 =


6.8(7+9+0+9+9)/5=34/5=6.8
ii. Average Turnaround Time: (17+15+1+12+13)/5=58/5=11.6(17 + 15 + 1 + 12 + 13)
/ 5 = 58 / 5 = 11.6(17+15+1+12+13)/5=58/5=11.6
3Q Given Data:

Process Burst Time Priority


P1 8 4
P2 6 1
P3 1 2
P4 9 2
P5 3 3

a) Non-Preemptive Priority Scheduling:

Order the processes by their priority:

1. P2 (Priority 1)
2. P3 (Priority 2)
3. P4 (Priority 2)
4. P5 (Priority 3)
5. P1 (Priority 4)

Calculate Start Time and Completion Time:

Process Arrival Time Burst Time Start Time Completion Time


P2 0 6 0 6
P3 0 1 6 7
P4 0 9 7 16
P5 0 3 16 19
P1 0 8 19 27

Turnaround Time (TAT) and Waiting Time:

i. TAT = Completion Time - Arrival Time


ii. Waiting Time = TAT - Burst Time

Process Arrival Time Burst Time Completion Time TAT Waiting Time
P2 0 6 6 6 0
Process Arrival Time Burst Time Completion Time TAT Waiting Time
P3 0 1 7 7 6
P4 0 9 16 16 7
P5 0 3 19 19 16
P1 0 8 27 27 19

Average Waiting Time and Average Turnaround Time:

i. Average Waiting Time: (0+6+7+16+19)/5=48/5=9.6(0 + 6 + 7 + 16 + 19) / 5


= 48 / 5 = 9.6(0+6+7+16+19)/5=48/5=9.6
ii. Average Turnaround Time: (6+7+16+19+27)/5=75/5=15(6 + 7 + 16 + 19 +
27) / 5 = 75 / 5 = 15(6+7+16+19+27)/5=75/5=15

You might also like