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

Process Burst Time Priority
P1 2 2
P2 1 1
P3 8 4
P4 4 2
P5 5 3

The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.

a. Draw four Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: FCFS, SJF, nonpreemptive priority (a larger priority number implies a higher priority), and RR (quantum - 2)

b. What is the turnaround time of each process for each of the scheduling algorithms in part a?

c. What is the waiting time of each process for each of these scheduling algorithms?

d. Which of the algorithms results in the minimum average waiting time (over all processes)?

Respuesta :

Answer:

a) Drawing for grant charts that illustrates execution of the process is in the image attached

b) To find turn around time we use: completion time - arrival time

•Turn around time for FCFS scheduling algorithm will be:

P1 = 2-0= 2

P2= 3-0 = 3

P3 = 11-0 = 11

P4 = 15-0 = 15

P5 = 20-0 = 20

• Turn around time for SJF scheduling algorithm

P1 = 3-0= 3

P2 = 1-0 = 1

P3= 20-0 = 20

P4= 7-0 = 7

P5 = 12-0 = 12

• Turnaround time for non-preemptive algorithm

P1 = 15-0 = 15

P2 = 20-0 = 20

P3 = 8-0 = 8

P4 = 19-0 = 19

P5 = 13 - 0 = 13

• Turnaround time for RR

P1 = 2-0=2

P2= 3-0= 3

P3= 20 - 0 = 20

P4 = 19-0 = 19

P5 = 18-0 = 18

c) To find waiting time we use (turnaround time - burst time)

•Waiting time for FCFS

P1= 2-2 = 0

P2 = 3-1 = 2

P3 = 11-8 = 3

P4 = 15-4 = 11

P5 = 20-5= 15

• Waiting time for SJF

P1= 3-2 = 1

P2 = 1-1 = 0

P3 = 20-8 = 12

P4 = 7-4 = 3

P5 = 12-5 = 7

• Waiting time for non-preemptive

P1= 15-2 = 13

P2 = 20-1 = 19

P3 = 8-8 = 0

P4 = 19-4 = 15

P5 = 13 - 5 = 8

• Waiting time for RR

P1 = 2-2 = 0

P2 = 3-1 = 2

P3 = 20-8 =12

P4 = 13-4= 9

P5= 18-5=13

d) Average waiting time

•'For FCFS

= (0+2+3+11+15)/5

= 31/5

= 6.2milliseconds

•average waiting time For SJF

(1+0+12+3+7)/5

=23/5

= 4.6milliseconds

• Average waiting time For non-preemptive

(13+9+0+15+8)/5

=55/5

=11milliseconds

• average waiting time For RR

(0+2+12+9+13)/5

=7.2milliseconds

Since the SJF algorithm has 4.6milliseconds, it results in the minimum average waiting time.

Ver imagen Chrisnando