in Operating System
13,059 views
4 votes
4 votes

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) ?

in Operating System
by
13.1k views

4 Comments

edited by

@Tushar03

  •   Round robin is the preemptive process scheduling algorithm. Each process is provided a fix time to execute, it is called a quantum.
  • Once a process is executed for a given time period, it is preempted and other process executes for a given time period. Round robin scheduling is similar to FCFS scheduling, except that CPU bursts are assigned with limits called time quantum.
  • If the process finishes its burst before the time quantum timer expires, then it is swapped out of the CPU just like the normal FCFS algorithm.
  • A scheduling discipline is preemptive if, once a process has been given the CPU can take away.
  • The strategy of allowing processes that are logically run able to be temporarily suspended is called preemptive scheduling and it is contrast to the "run to completion" method...

 

  1. https://gateoverflow.in/147415/os-round-robin-scheduling?show=343480#a343480 

  2. https://gateoverflow.in/188697/context-switch 

  3. https://gateoverflow.in/75651/context-switch

  4. https://gateoverflow.in/202650/operating-system

 

 

0
0
@minalBallav , my doubt is , for single process , can we consider context switches if time quanta of it is less that burst time in RR. in Galvin an example is taken like that where they showed the consideration of context switches of single process in cpu .
0
0
edited by

@Tushar03

Burst time is - m units (let 10) , time quantum - q units (let 5 or 6 or 4) ,

q < m ..

[m/q ] – 1

In round robin, context switching always takes place even if there’s only one process...

 

  • A context switch 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.

 

  • This allows multiple processes to share a single central processing unit (CPU), and is an essential feature of a multitasking operating system.

 

  • The precise meaning of the phrase “context switch” varies.

 

  • In a multitasking context, it refers to the process of storing the system state for one task, so that task can be paused and another task resumed….

 

 

It clearly says " Assume that dispatching the process first time is not counted as a context switch."

so number of context switch = 0

as there is only one single process....

0
0

2 Answers

5 votes
5 votes
Here total 5 context switches ocur .

`p1 - p2

p2 - p3

p3- p4

p4 - p1

p1- p3

 

during start there is context switch but we don't consider that case.

1 comment

edited by

what about last context switch when P3 will terminate

i think 6 context switches should be there.

https://cs.stackexchange.com/questions/74049/does-a-context-switch-happen-when-a-process-has-terminated

0
0
1 vote
1 vote

context switch occurs when a computer’s CPU switches from one process or thread to a different process or thread.

It should be 5.

Answer:

Related questions