1
43kviews
Draw the Gantt Charts for FCFS,SJF,Preemptive priority and RR(Quantum=2)

Subject: Operating System

Topic: Process Management And Memory Management

Difficulty: Medium


Consider the following set of processes,with length of CPU bursts given in Millisecond as follows:

Process Burst Time Arrival Time Priority
P1 8 0 3
P2 1 1 1
P3 3 2 2
P4 2 3 3
P5 6 4 4

1.Draw the Gantt Charts for FCFS,SJF,Preemptive priority and RR(Quantum=2)

2.What is the turn around time of each process for above algorithm?

3.What is the waiting time of each process for each of the above algorithm?

4.Which algorithm results in minimum average waiting time.

1 Answer
2
2.5kviews

Turn Around Time = Process Completion Time – Process Arrival Time

Waiting time = Turn Around time – Burst time

First Come First Serve (FCFS) Scheduling

FCFS 2

Process Arrival Time Burst Time Completion Time Turn Around Time Waiting Time
P1 0 8 8 8 – 0 = 8 8 – 8 = 0
P2 1 1 9 9 – 1 = 8 8 – 1 = 7
P3 2 3 12 12 – 2 = 10 10 – 3 =7
P4 3 2 14 14 – 3 = 11 11 – 2 = 9
P5 4 6 20 20 – 4 = 16 16 – 6 = 10

Average Turn Around Time = (8 + 8 + 10 + 11 + 16)/5 = 10.6 ms

Average Waiting time = (0 + 7 + 7 + 9 +10)/5 = 6.6 ms

Shortest Job First (SJF) Scheduling

SJF 2

Process Arrival Time Burst Time Completion Time Turn Around Time Waiting Time
P1 0 8 20 20 – 0 = 20 20 – 8 = 12
P2 1 1 2 2 – 1 = 1 1 – 1 = 0
P3 2 3 5 5 – 2 = 3 3 – 3 = 0
P4 3 2 7 7 – 3 = 4 4 – 2 = 2
P5 4 6 13 13 – 4 = 9 9 – 6 = 3

Average Turn Around Time = (20 + 1 + 3 + 4 + 9)/5 = 7.4 ms

Average Waiting time = (12 + 0 + 0 + 2 + 3)/5 = 3.6 ms

Preemptive Priority Based Scheduling

PPB

Process Arrival Time Burst Time Priority Completion Time Turn Around Time Waiting Time
P1 0 8 3 12 12 – 0 = 12 12 – 8 = 4
P2 1 1 1 2 2 – 1 = 1 1 – 1 = 0
P3 2 3 2 5 5 – 2 = 3 3 – 3 = 0
P4 3 2 3 14 14 – 3 = 11 11 – 2 = 9
P5 4 6 4 20 20 – 4 = 16 16 – 6 = 10

Average Turn Around Time = (12 + 1 + 3 + 11 + 16)/5 = 8.6 ms

Average Waiting time = (4 + 0 + 0 + 9 + 10)/5 = 4.6 ms

Round Robin Scheduling

Quantum = 2 ms

RR

Process Arrival Time Burst Time Completion Time Turn Around Time Waiting Time
P1 0 8 20 20 – 0 = 20 20 – 8 = 12
P2 1 1 3 3 – 1 =2 2 – 1 = 1
P3 2 3 12 12 – 2 = 10 10 – 3 = 7
P4 3 2 7 7 – 3 = 4 4 – 2 = 2
P5 4 6 18 18 – 4 = 14 14 – 6 = 8

Average Turn Around Time = (20 + 2 + 10 + 4 + 14)/5 = 10 ms

Average Waiting time = (12 + 1 + 7 + 2 + 8)/5 = 6 ms

Shortest Job First (SJF) Results in minimum Average Waiting time from all other schedulings

Please log in to add an answer.