in Operating System edited by
199 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
in Operating System edited by
199 views

3 Comments

Answer should be a. only pre-emption as no other process exists, hence no context switch

1
1
is it C?
0
0
pre-empition from user mode to kernal mode and kernal mode to user mode
0
0

1 Answer

3 votes
3 votes
Best answer

(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
by

4 Comments

@DebSujit thats why i told just to add one thing😑.

1
1

@samarpita Arey maam cazz 😂

0
0

@samarpita

As mentioned by you,

“If there is only 1 process then we do not need a context switch”

So, if the process will come again for execution, then will there be a context switch and pre-emption happen na?

0
0

Related questions