edited by
776 views
3 votes
3 votes

Suppose only a process P1 is executing, using Round Robin scheduling. After the time slice expires, the same process comes back into execution. This could be considered as: (Time Slice of RR is smaller than burst of P1)

  1. Only preemption
  2. Only context switch 
  3. Both preemption and context switch
  4. None
edited by

1 Answer

Best answer
3 votes
3 votes

(C) is the correct option.

Two things you need to know before answering this –

  1. Context Switch – It is the process of storing the state of a process or thread so that it can be restored and resume execution at a later point, and then restoring a different, previously saved, state. 
  2. Pre-emption – It is the act of temporarily interrupting an executing task, with the intention of resuming it at a later time. This interrupt is done by an external scheduler with no assistance or cooperation from the task.

Pre-emption happens only after storing the state of the current process.

Now, what happens in Round-Robin algorithm, is as soon as the time quanta for a process expires that process is pre-empted and “context switched” (note the definition of context switch above), and stored in the selection queue. This happens irrespective of the number of processes stored in the queue. The algorithm at the end of each time quanta does the above and then chooses the front-most element from the queue.

The algorithm has no idea if that queue has one or more processes stored, it follows the same step for any possible scenario.

Here is a small paragraph from Galvin (Page 272) supporting the above claim-

Another image (Galvin Page 272) showing how context switch happens irrespective of the process ID,

edited by

Related questions

1 votes
1 votes
1 answer
1
sanyam53 asked Jan 7, 2017
1,675 views
How many time context switch in Round Robin? ( if only one process remain in ready queue at end of scheduling does that count every time, when time slice over or only one...
4 votes
4 votes
2 answers
3
Xylene asked Aug 12, 2017
13,213 views
Here what are the number of context switches ? Is it 5 or 6? Do we consider context switch before P1 (i.e during the start) ?