Open In App

Time Slicing in CPU scheduling

CPUs kernel doesn’t simply distribute the entirety of our PCs’ resources to single process or service. CPU is continuously running many processes that are essential for it to operate, so our kernel needs to manage these processes without moment’s delay.

When program needs to run, process must be created for it. This process needs to have important resources like RAM and CPU. The kernel schedules time periods for CPU to perform commands and instructions in process. Be that as it may, there’s just single CPU and numerous processes.



How does CPU outstand to execute different processes without moment’s delay? It does it by executing processes one by one, individually by time slice. A time slice is short time frame that gets assigned to process for CPU execution.

Time slice :
It is timeframe for which process is allotted to run in preemptive multitasking CPU. The scheduler runs each process every single time-slice. The period of each time slice can be very significant and crucial to balance CPUs performance and responsiveness.



If time slice is quite short, scheduler will take more processing time. In contrast, if the time slice is too long, scheduler will again take more processing time.

When process is allotted to CPU, clock timer is set corresponding to time slice.

The ongoing queue is managed like circular queue, so, after all processes are executed once, scheduler executes first process again and then second and so forth.

Example –

Process Queue Required burst time by process(ms)
P1 1
P2 4
P3 5

We have three processes(P1, P2, P3) with their corresponding burst times(1ms, 4ms, 5ms). A rule of thumb is that 80% of CPU bursts should be smaller than the time quantum. Considering time slice of 2ms.
Here’s how CPU manages it by time slicing.

time-slicing approach for process management

Advantages :

Disadvantages :

Article Tags :