Even when we have 1 process still context switch will happen in Round Robin .
Round Robin is a scheduling Algorithm in which process share CPU in time sharing mode. So when the time quantum expires, process need to be context switch irrespective of number of process as process executes in running state and available processes are present in ready state.
@badalgupta9911103602 good point!
Generally, Round Robbin is imeplemented with a queue. This queue maintains the order of execution of the process (FIFO). when a process finishes its time quantum and has remaining time for its complete execution ,it enters the queue(waiting) from the back. Since in this case the queue will be empty and this process will be the first as well as last one.
We can say the process context switches with itself since there are no other process.
,it enters the queue(waiting) from the back. Since in this case the queue will be empty and this process will be the first as well as last one.
@ashubeckham and @badalgupta9911103602 :
Does it mean that even with only one process, context switching will happen for all scheduling mechanism which share CPU on time sharing method?
Can you provide couple of examples of such scheduling algorithm
@rujul Context switch depends on weather a process is preemptive or not . For example Shortest job first and Round Robbin are Preemptive and hence context switch will be take place in them . But in shortest job first context switch is based on weather there is process with less CPU burst time is available(in ready queue) ,If not then current process continue to execute.
If you have any more doubts you can refer a book : Operating System Concepts ( by SILBERSCHATZ ,GALVIN and GAGNE).
This post explains it good.
At different times, kernel will call the scheduler to select a new process to run. But it may turn out that the scheduler finds no other task but the currently running task. In that case scheduler will not undertake a "context switch" rather simply return by doing nothing.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.