๐Ÿ”น What is Round-Robin?

Round-Robin (RR) is a CPU scheduling algorithm where each process is given a fixed time slot (quantum) to run in a cyclic order.

Itโ€™s simple, fair, and preemptive โ€” meaning a running process can be paused to let others run.


๐Ÿ”น Analogy:

Think of students sharing one laptop in a library.
Each gets 5 minutes. After 5 minutes, the next student gets a turn โ€” even if the first one isnโ€™t done.
After everyone gets their chance, the first student gets the laptop again, and so on.


๐Ÿ”น How It Works (Step-by-Step):

  1. All processes are placed in a queue (FIFO order).

  2. The first process runs for a fixed time slice (say, 100ms).

  3. If it finishes early โ†’ it leaves the queue.
    If not โ†’ itโ€™s paused and moved to the back of the queue.

  4. The next process gets its time slice.

  5. This cycle repeats until all processes are completed.


๐Ÿ”น Characteristics:

FeatureDescription
TypePreemptive
FairnessAll processes get equal CPU time (in turns)
Queue UsedCircular FIFO
Response TimeGood โ€” every process gets CPU quickly
Context SwitchesFrequent (depends on time quantum)

๐Ÿ”น Time Quantum (Important Concept)

  • A time quantum is the fixed CPU time given to each process.

  • Too small โ†’ too many context switches โ†’ overhead

  • Too large โ†’ behaves like FCFS (First-Come-First-Serve)

Good system design = choosing a balanced time quantum.


๐Ÿ”น Example:

  • 3 processes: P1, P2, P3

  • Time quantum = 4ms

  • Arrival Time: all at 0ms

  • Burst Times: P1=10ms, P2=4ms, P3=6ms

Execution order:

P1 โ†’ P2 โ†’ P3 โ†’ P1 โ†’ P3 โ†’ P1

Each gets 4ms before switching, continuing in a round-robin fashion until complete.


๐Ÿ”น Advantages:

  • Fair to all processes

  • Simple to implement

  • No starvation โ€” every process gets CPU time

  • Good for time-sharing systems


๐Ÿ”น Disadvantages:

  • Frequent context switching = CPU overhead

  • Performance depends heavily on quantum size