As we see in the concept of Virtual Memory, for execution of any process, OS does not load the entire process into main memory. It means that only some pages of a process will be loaded in the main memory at any time. Here, the demand paging is very important.
Because It is difficult to decide in advance, that which pages to be kept in main memory and which pages to be kept in secondary memory, because we don’t know that a process will require a particular page at specific time.
To remove this problem demand paging concept comes into picture. According to demand paging, kept all pages of a process in the secondary memory until they are required. In simple words, don’t load any page of process in the main memory until it is requested by CPU.
In this way, when a page request for first time then that page will not be in main memory. it will be loaded from secondary memory to main memory for execution.
Whenever it request in future, then it may or may not be found in main memory. If it not found in main memory then it is a page fault. It depends upon the page replacement algorithm. Some page replacement algorithms are
- The theoretically optimal page replacement algorithm
- Least recently used
- First-in, first-out
- Not frequently used (NFU)
Degree of multi-programming is increase.
Problems in Demand Paging
Page fault may increase due to which system performance will decrease.