Question: Consider the following set of processes, with the length of CPU burst given in milliseconds.
0

The processes are assumed to have arrived in the order $P_1, P_2, P_3, P_4, P_5$ all at time 0. Calculate the average turnaround time and maximum waiting time for per- emptive scheduling algorithm.

enter image description here

Subject: Operating System

Topic: Process Management

Difficulty: Medium

ADD COMMENTlink
modified 4 months ago by gravatar for Abhishek Tiwari Abhishek Tiwari50 written 3.0 years ago by gravatar for Snehal B Snehal B10
1

a) FCFS scheduling:

Here the processes are scheduled as per the order in which they arrive.

Gantt chart:

enter image description here

Waiting time for P1=0

Waiting time for P2=10

Waiting time for P3=11

Waiting time for P4=13

Waiting time for P5=14

Average waiting time$=\frac{Sum of waiting time for individual process}{No. of processes}$ $=\frac{0+10+11+13+14}{5} = 9.6 $

Average execution time$=\frac{Sum of execution time for individual process}{No. of processes}$ $=\frac{10+1+2+1+5}{5} = 3.8$

Average turn-around time = Average waiting time + Average execution time = 9.6 + 3.8 = 13.4

b) SJF non-preemptive scheduling:

Here the processes are scheduled as per their burst time with the least timed-process being given the maximum priority.

enter image description here

Waiting time for P1=9

Waiting time for P2=0

Waiting time for P3=2

Waiting time for P4=1

Waiting time for P5=4

Average waiting time$=\frac{Sum of waiting time for individual process}{No. of processes}$ $=\frac{9+0+2+1+4}{5} = 3.2$

Average execution time$=\frac{Sum of execution time for individual process}{No. of processes}$ $=\frac{10+1+2+1+5}{5} = 3.8$

Average turn-around time= Average waiting time + Average execution time = 3.2 + 3.8 = 7

c) Priority scheduling :

Here the scheduling happens on the basis of priority number assigned to each process. (Here we would be considering Priority=1 as highest priority)

enter image description here

Waiting time for P1=6

Waiting time for P2=0

Waiting time for P3=16

Waiting time for P4=18

Waiting time for P5=1

Average waiting time$=\frac{Sum of waiting time for individual process}{No. of processes}$ $=\frac{6+0+16+18+1}{5} = 8.2$

Average execution time$=\frac{Sum of execution time for individual process }{No. of processes}$ $=\frac{10+1+2+1+5}{5} = 3.8$

Average turn-around time= Average waiting time + Average execution time = 8.2 + 3.8 = 12

d) Round Robin scheduling:

Here every process executes in the FCFS for the given time quantum. This is a pre-emptive method of scheduling. Here time quantum =1

enter image description here

Waiting time for $P1=(0+(5-1)+(8-6)+(10-9)+(12-11)+(14-13))=9$

Waiting time for P2=1

Waiting time for $P3=2+(6-3)=5$

Waiting time for P4=3

Waiting time for $P5=4+(7-5)+(9-8)+(11-10)+(13-12)=9$

Average waiting time$=\frac{Sum of waiting time for individual process}{No. of processes} $ $=\frac{9+1+5+3+9}{5} = 5.4$

Average execution time$=\frac{Sum of execution time for individual process}{No. of processes}$ $=\frac{10+1+2+1+5}{5} = 3.8 $

Average turn-around time= Average waiting time + Average execution time = 5.4 + 3.8 = 9.2

ADD COMMENTlink
written 3.0 years ago by gravatar for Snehal B Snehal B10
Please log in to add an answer.