I am attempting the question below:

Assume a set of processes $P_1, P_2, P_3$ and $P_4$ arrive at different times in the ready queue. The table below shows the burst time, the priority (smallest priority number implies highest priority) and arrival time for each of the processes. \begin{array}{|c|c|c|c|} \hline Process & Burst ~ time & Priority & Arrival ~ Time \\ \hline P_1 & 8& 2& 0\\ \hline P_2 & 2 & 3 & 1 \\ \hline P_3 & 4 & 1 & 3 \\ \hline P_4 & 6 & 2 & 5 \\ \hline \end{array} Draw a Gant chart, illustrating the execution of the processes, to demonstrate each of the following algorithms.

  1. First-Come, First-Served (FCFS)
  2. Round Robin(RR) with time slice of 3 time units.

Problem I am having is that my answer is not matching what I am getting form the simulator here.

The problem might be with the way I am handling my ready Queue. My workings and answer is below. The simulator shows that after first time P3 appears in the chart that P4 should start. But P1 was pre-empted and still had more execution hence I put P1 in there. Where am I going wrong?

Ready Queue (as I was working it out): P1,P2,P3,P1,P4,P3,P1,P4

GANT CHART: enter image description here


1 Answer 1


With round-robin, the scheduler always selects the process that's had the most time since it was last run, and new processes coming in are always assigned a last run time of 1 time unit before the oldest last run time in the current list. (There are other equivalent ways to state this, but this is the simplest one for me. One other way to phrase this that works for many people is "processes that haven't had a chance to run yet have priority".)

So at t=8, we have:

Process Last-run Time-left
P1      0        5
P3      3        1
P4      -1*      6

Note the -1 for P4. The oldest last run time is P1, with 0. So P4 gets assigned -1, and hence gets selected.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.