Round robin scheduling

22
Round Robin Scheduling (RR) Baljit Singh Saini

Transcript of Round robin scheduling

Page 1: Round robin scheduling

Round Robin Scheduling (RR)

Baljit Singh Saini

Page 2: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5 2

P3 3 4

P4 2 5

P10

0

Baljit Singh Saini

At time ZERO P1 is in the system

Page 3: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4/3 0

P2 5 2

P3 3 4

P4 2 5

P1

1

0

Baljit Singh Saini

At time 1 no new process arrives

Page 4: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4/2 0

P2 5 2

P3 3 4

P4 2 5

P1

2

0

Baljit Singh Saini

P2

At time 2 P2 arrives

Page 5: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4/1 0

P2 5 2

P3 3 4

P4 2 5

P1

3

0

Baljit Singh Saini

P2

3

At time 3 no new process arrives

But quantum of P1 expires.So P1 is preempted and P2 gets

the CPU

Page 6: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4/1 0

P2 5 2

P3 3 4

P4 2 5

P1

3

0

Baljit Singh Saini

3

After time 3 the state of the system is this

P1

P2

Page 7: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4/1 0

P2 5/4 2

P3 3 4

P4 2 5

P1

4

0

Baljit Singh Saini

3

P2

P1 P3

Page 8: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4/1 0

P2 5/3 2

P3 3 4

P4 2 5

P1

5

0

Baljit Singh Saini

3

P2

P1 P3 P4

Page 9: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4/1 0

P2 5/2 2

P3 3 4

P4 2 5

P1

6

0

Baljit Singh Saini

3

P2

P1 P3 P4

6

Page 10: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4/0 0

P2 5/2 2

P3 3 4

P4 2 5

P1

7

0

Baljit Singh Saini

3

P2 P1

P3 P4

6

P2

7

Page 11: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/2 2

P3 3 4

P4 2 5

P1

7

0

Baljit Singh Saini

3

P2 P1

P3 P4

6

P2

7

Page 12: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/2 2

P3 3/2 4

P4 2 5

P1

8

0

Baljit Singh Saini

3

P2 P1 P3

P4

6

P2

7

Page 13: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/2 2

P3 3/1 4

P4 2 5

P1

9

0

Baljit Singh Saini

3

P2 P1 P3

P4

6

P2

7

Page 14: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/2 2

P3 3/0 4

P4 2 5

P1

10

0

Baljit Singh Saini

3

P2 P1 P3

P4

6

P2

7 10

Page 15: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/2 2

P3 3 4

P4 2 5

P1

10

0

Baljit Singh Saini

3

P2 P1 P3

P4

6

P2

7 10

Page 16: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/2 2

P3 3 4

P4 2/1 5

P1

11

0

Baljit Singh Saini

3

P2 P1 P3

6

P2

7 10

P4

Page 17: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/2 2

P3 3 4

P4 2/0 5

P1

12

0

Baljit Singh Saini

3

P2 P1 P3

6

P2

7 10

P4

12

Page 18: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/2 2

P3 3 4

P4 2 5

P1

12

0

Baljit Singh Saini

3

P2 P1 P3

6

P2

7 10

P4

12

Page 19: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/1 2

P3 3 4

P4 2 5

P1

13

0

Baljit Singh Saini

3

P2 P1 P3

6 7 10

P4

12

P2

Page 20: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5/0 2

P3 3 4

P4 2 5

P1

14

0

Baljit Singh Saini

3

P2 P1 P3

6 7 10

P4

12

P2

14

Page 21: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4 0

P2 5 2

P3 3 4

P4 2 5

P1

14

0

Baljit Singh Saini

3

P2 P1 P3

6 7 10

P4

12

P2

14

Page 22: Round robin scheduling

Time quantum = 3process Burst time Arrival time

P1 4

P2 5 2

P3 3 4

P4 2 5

P1

0

Baljit Singh Saini

3

P2 P1 P3

6 7 10

P4

12

P2

14

Waiting time

P1 =

0

0 - 0 + 3 = 3

P1 waiting for next burst

P2= 3 - 2 + 6 = 7

P2 waiting for next burst

2

P3 =7 – 4 = 3P4 = 10 – 5 = 5