It is preemptive scheduling algorithm. A small unit of time known as a time quantum or time slice is used for pre-emption of a currently running process. Ready queue is implemented as a circular queue. CPU is assigned to the entire processes one by one, on first come first serve basis, for a specific time period. Every process executes for specified time period and CPU is given to the next process when time quantum expires. A new process is added at the tail of the ready queue when it enters the system. CPU scheduler selects first process from head of the ready queue and executes it for a specified time quantum. Once the time quantum expires, dispatcher is invoked to pre-empt current running process and CPU is given to the next process placed at the head of the ready queue. The running process may have a CPU burst time less or greater than time quantum. If burst time of running process is less than the time quantum then, the process itself releases the CPU. The scheduler then selects next process from ready queue and executes it. If burst time of running process is longer than time quantum then, context switch occurs and the process is place at the tail of ready queue for remaining burst time execution.
CPU is allocated to process P1 for 4 ms. Since it requires another 20 milliseconds, it is preempted after the first time quantum and the CPU is given to the next process in the queue, process P2. Process P2 does not need 4 milliseconds, so it quits before its time quantum expires. The CPU is then given to the next process, process P3. Once each process has received 1 time quantum, the CPU returns to process P1 for an additional time quantum.