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
- Lower level scheduler –
This scheduler selects which process will run from memory.
- 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 :
- 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.
- 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.
- 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.
- CPU Scheduling in Operating Systems
- Operating Systems | CPU Scheduling | Question 1
- Operating Systems | CPU Scheduling | Question 2
- Operating Systems | CPU Scheduling | Question 3
- Operating Systems | CPU Scheduling | Question 4
- Operating Systems | CPU Scheduling | Question 5
- Operating Systems | CPU Scheduling | Question 6
- Operating Systems | CPU Scheduling | Question 7
- CPU Scheduling in Operating Systems using priority queue with gantt chart
- I/O scheduling in Operating Systems
- Operating Systems | Input Output Systems | Question 5
- Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling
- Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
- Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
- Difference between Multi Level Queue Scheduling (MLQ) and Priority Scheduling
- Least Slack Time (LST) scheduling Algorithm in real-time systems
- Scheduling in Real Time Systems
- Lottery Process Scheduling in Operating System
- Multiple-Processor Scheduling in Operating System
- List scheduling in Operating System
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.