title: Does a context switch occur in a system whose ready queue has only one process and which uses round-robin scheduling?
body: <p>Does a context switch occur in a system whose ready queue has only one process and which uses round-robin scheduling?</p>
  
  <p>Assume that current cpu burst of the lone process spans more than one time-slice of the round-robin algorithm.</p>
  
  <p>My reasoning is as below</p>
  
  <p>The steps that may take place when a timer interrupt occurs in a typical case are</p>
  
  <ol>
  <li>Interrupt occurs. Switch to kernel mode</li>
  <li>OS saves current context into PCB(save registers, process state and memory-management info of current process)</li>
  <li>Perform many architecture-specific operations, including flushing
  data and instruction caches and TLB's.  </li>
  <li>Put current process into the ready queue</li>
  <li>Choose the new process to execute</li>
  <li>Load context from the PCB of that process</li>
  <li>Switch to user mode. Start executing the new process</li>
  </ol>
  
  <p>I am now thinking that the OS might as well inspect the ready queue first and check if there are other processes. If there aren't any there is no need for a context switch. Thus handling of the timer interrupt will entail switching between the user mode and kernel mode, checking the ready Q, and switching back to the user mode to resume execution of the process.</p>
  
  <p>Is this what happens? Or does a proper context switch of involving the unnecessary saving of the current state of the lone process and the restoring the same take place?</p>
  
  <p>If the later does happen, is there a special reason?</p>
  
  <p>This confusion arose due to a question in a exam paper concerning the calculation of the time spent in context-switching in such a situation. The answer given implies that context switches do take place.</p>
  
  <p>I am hoping that people who have looked into kernel code will be able to through light on this. Thus this question on stackoverflow.</p>