Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following set of processes, with the length of the CPU burst time g

ID: 3774884 • Letter: C

Question

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

Process Burst Time Priority

P1 2 2

P2 1 1

P3 8 4

P4 4 2

P5 5 3

a) Draw four Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: FCFS, SJF, non-preemptive 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)?

Explanation / Answer

Considering arrival time as 0,1,2,3,4 for process P1,P2,P3,P4,P5

FCFS:

Process

Arrival Time

Execute Time

Service Time

P1

0

2

0

P2

1

1

2

P3

2

8

3

P4

3

4

11

P5

4

5

15

GANTT CHART

|P1 | P2 |P3 |P4 |P5 |

0 2 3 11 15 20

SJF:

Process

Arrival Time

Execute Time

Service Time

P1

0

2

1

P2

1

1

0

P3

2

8

12

P4

3

4

3

P5

4

5

7

GANTT CHART

|P2 |P1 |P4 |P5 |P3 |

0 1 3 7 12 20

Priority:

Process

Arrival Time

Execute Time

Priority

Service Time

P1

0

2

2

13

P2

1

1

1

19

P3

2

8

4

0

P4

3

4

2

15

P5

4

5

3

8

GANTT CHART

|P3 |P5 |P1 |P4 |P2 |

0 8 13 15 19 20

RR:

GANTT CHART

|P1 |P2 |P3 |P4 |P5 |P3   |P4   |P5   |P3   |P5   |P3   |

0 2 3 5    7    9      11   13     15    17     18   20

B. TurnAround Time:

FCFS:

P1=2

P2=3-0=3

P3=11-2=9

P4=15-3=12

P5=20-4=16

SJF:

P1=3-0=3

P2=1-1=0

P3=20-2=18

P4=7-3=4

P5=12-4=8

PRIORITY:

P1=15-0=15

P2=20-1=19

P3=8-0=8

P4=19-3=16

P5=13-4=9

RR:

P1= 2-0=2

P2=3-1=2

P3=20-2=18

P4=13-3=10

P5=18-4=14

C. WAITING TIMES-

FCFS WAIT TIME:

P1=0

P2=(2-1)=1

P3=(3-2)=1

P4=(11-3)=8

P5=(15-4)=11

SJF WAIT TIME:

P1=1-0=1

P2=0-0=0

P3=12-2=10

P4=(3-3)=0

P5=(7-4)=3

Priority WAIT TIME:

P1=13-0

P2=19-1=18

P3=0

P4=(15-3)=12

P5=(8-4)=4

RR WAIT TIME:

P1=0

P2=2-1=1

P3=(3-2)+(9-5)+(15-11)+(18-17)=1+4+4+1=10

P4=(5-3)+(11-7)=2+4=6

P5=(7-4)+(13-9)+(17-15)=3+4+2=9

D. Average Wait time:

FCFS: 0+1+1+8+11/5=4.2

SJF: 1+0+10+0+3/5=2.8

PRIORITY: 0+18+0+12+4/5=6.8

RR: 0+1+10+6+9/5=5.2

SJF took minimum average waiting time

Process

Arrival Time

Execute Time

Service Time

P1

0

2

0

P2

1

1

2

P3

2

8

3

P4

3

4

11

P5

4

5

15