0% found this document useful (0 votes)
4 views

Document

Uploaded by

maha24743
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)
4 views

Document

Uploaded by

maha24743
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/ 5

BADAR FIAZ (70138276)

QUESTION 1:
A CPU scheduling system receives five processes with the following
arrival and burst times:

PART A:

FCFS Scheduling Gantt Chart:

• The processes are executed in the order they arrive.


• Completion time is calculated sequentially.

SO:

| P1 | P2 | P3 | P4 | P5 |
0 8 12 21 26 28
PART B:
Calculate the average waiting time (AWT) and average
turnaround time (TAT) for FCFS.
As we know to calculate AWT and TAT, we use this formula:
➢ Turnaround Time (TAT) = Completion Time - Arrival
Time
➢ Waiting Time (WT) = Turnaround Time - Burst Time

Arrival Burst Completion Turnaround Waiting Time


Process
Time Time Time Time (TAT) (WT)
P1 0 8 8 8-0=8 8-8=0
P2 1 4 12 12 - 1 = 11 11 - 4 = 7
P3 2 9 21 21 - 2 = 19 19 - 9 = 10
P4 3 5 26 26 - 3 = 23 23 - 5 = 18
P5 4 2 28 28 - 4 = 24 24 - 2 = 22

Average Waiting Time (AWT) =


(0 + 7 + 10 + 18 + 22) / 5 = 11.4 ms
Average Turnaround Time (TAT) =
(8 + 11 + 19 + 23 + 24) / 5 = 17 ms

PART C:
Draw the Gantt chart using Shortest Job First (SJF) (non-
preemptive) scheduling.
Shortest Job First (SJF) (Non-Preemptive) Scheduling:
• The process with the shortest burst time is executed next.
• If two processes have the same burst time, the one that
arrived first is executed first.
| P1 | P5 | P2 | P4 | P3 |
0 8 10 14 19 28

PART D:

Calculate the AWT and TAT for SJF.


Arrival Burst Completion Turnaround Waiting
Process
Time Time Time Time (TAT) Time (WT)
P1 0 8 8 8-0=8 8-8=0
P5 4 2 10 10 - 4 = 6 6-2=4
P2 1 4 14 14 - 1 = 13 13 - 4 = 9
P4 3 5 19 19 - 3 = 16 16 - 5 = 11
P3 2 9 28 28 - 2 = 26 26 - 9 = 17

Average Waiting Time (AWT) =


(0 + 4 + 9 + 11 + 17) / 5 = 8.2 ms
Average Turnaround Time (TAT) =
(8 + 6 + 13 + 16 + 26) / 5 = 13.8 ms
QUESTION 2:
SRTF & Priority Scheduling Consider the following set of
processes:
PART A

SRTF (Preemptive SJF) Scheduling Gantt Chart:

| P1 | P1 | P2 | P2 | P2 | P2 | P2 | P4 | P1 | P3 |
0 1 2 3 4 5 6 9 14 20

PART B:

Calculations for SRTF:

Arrival Burst Completion Turnaround Waiting Time


Process
Time Time Time Time (TAT) (WT)
P1 0 7 14 14 7
P2 2 4 6 4 0
P3 4 6 20 16 10
P4 5 3 9 4 1

Average Waiting Time (AWT) =

(7 + 0 + 10 + 1) / 4 = 4.5 ms

Average Turnaround Time (TAT) =

(14 + 4 + 16 + 4) / 4 = 9.5 ms
PART C :

Preemptive Priority Scheduling Gantt Chart:

| P1 | P2 | P2 | P2 | P2 |P1 | P4 | P3 |
0 2 3 4 5 6 11 14 20

PART D :

Calculations for Priority Scheduling:

Arrival Burst Completion Turnaround Time


Process Waiting Time (WT)
Time Time Time (TAT)
P1 0 7 11 11 4
P2 2 4 16 4 0
P3 4 6 20 16 10
P4 5 3 14 9 6

Average Waiting Time (AWT) =

(11 + 4 + 16 + 9) / 4 = 10 ms

Average Turnaround Time (TAT) =

(4 + 0 + 10 + 6) / 4 = 5 ms

You might also like