Two-level scheduling in Operating Systems

Two-level scheduling is an efficient scheduling method that uses two schedulers to perform process scheduling.

Let us understand it by an example :
Suppose a system has 50 running processes all with equal priority and the system’s memory can only hold 10 processes simultaneously. Thus, 40 processes are always swapped out and written on virtual memory on the hard disk. To swap out and swap in a process, it takes 50 ms respectively.

Let us take up the above scenario with straightforward Round-robin scheduling: a process would need to be swapped in (least recently used processes are swapped in) every time when a context switch occurs. Swapping in and out costs too much, and the unnecessary swaps waste much time of scheduler.

So the solution to the problem is two-level scheduling. There are two different schedulers in two-level scheduling :

1. Lower level scheduler
2. Higher level scheduler 





  1. Lower level scheduler –
    This scheduler selects which process will run from memory.
  2. Higher level scheduler –
    This scheduler focuses on swapping in and swapping out the processes between hard disk and memory. Swapping takes much time, therefore it does its scheduling much less often. It also swaps out the processes which are running for a long time in memory and are swapped with processes on disk that have not run for a long time.



Following variables are used :

  1. Response time –
    Response time variable is important as it prevents resource starvation and a process will be completed. Some other processes will have to wait unnecessarily for a long time if a process is swapped out for too long. Therefore, this variable is essential.

  2. Size of the process –
    Larger processes are less often swapped because they take a long time to swap. As these processes are larger, only some of them can share the memory with the process.

  3. Priority –
    The process with higher priority stays in memory for longer time so that it completes faster.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.