Open In App

Two-level scheduling in Operating Systems

Improve
Improve
Like Article
Like
Save
Share
Report

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.


Last Updated : 12 Aug, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads