Pergunta

(this was a question asked in the 5th semester of my computer engineering degree)

What will the order of process execution be in the following scenario, given that the scheduling used is Round Robin?

QUANTUM SIZE = 4

Process----Arrival time----Burst time

A---0---3

B---1---5

C---3---2

D---9---5

E---12---5

My real doubt comes at time 9. At this point, A and C have finished execution. B is in the queue and D has just entered. Which one will be executed first? B or D?

should the overall order be A-B-C-D-E-B-D-E or A-B-C-B-D-E-D-E?

Foi útil?

Solução

In round robin processes are executed for a time period called Quantum you haven't mentioned it. Still there is no problem. Round Robin algorithm says that each process will get equal time period for execution in a circular fashion. At the point of ambiguity, it implements First Come First Serve method. You are mentioning a deadlock situation here. B should com first. Here are few references: Word Definition a simple example

Outras dicas

the order of exe will be A-B-C-B-D-E-D-E, because at time 3 i.e. after exe of a ready queue have B , C in same order , so B is executed till time 7 (as TQ < burst time of b ) and B is queued back in circular queue (ready queue) as follows A-B-C-B
and at time 7 c will execute till time 10 , while exe of c d arrived at ready queue at time 9 therefore queue like A-B-C-B-D... final chart will be

Q= | A | B | C | B | D | E | D | E | T= | | | | | | | | | 0 3 7 10 11 15 19 20 21

Round Robin scheduling is similar to FCFS (First Come First Serve) scheduling, but preemption is added. The ready queue is treated as a circular queue. The CPU scheduler goes around the ready queue, allocating CPU to each process for a time interval of up to 1 time quantum. Operating System Concepts (Silberschatz)

Now in your case, the Gantt Chart will look like this:

A   |  B  |  C  |  D  |  E  |  B  |  D  |  E  |
0   3     7     9     13    17    18    19   20     

Notice in this case at first we consider FCFS and start with process A (arrival time 0 ms) then we continue dispatching each process based on their arrival time (the same sequence in which you have listed in the question) , for 1 time quantum (4 ms each).

If the burst time of a process is less than the time quantum then it releases the CPU voluntarily otherwise preemption is applied.

So, the scheduling order will be :

A -> B -> C -> D -> E -> B -> D -> E

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top