1. For loading a program in memory, the traditional method usually loads the entire program in memory.
2. However, it may lead to programs or lines of codes with at the end go untouched.
3. To overcome this drawback, we use the concept of demand paging.
4. In Demand Paging, only the pages needed currently for execution are brought in to memory as and when needed.
5. The virtual memory system is commonly implemented using the concept of demand paging.
6. Demand Paging uses a lazy swapper to swap the pages from memory.
7. An important feature of a lazy swapper is that it never swaps until that page is needed.
8. In Demand Paging instead of word swapper the term pager is used.
9. When a process is to be swapped in, the pager guesses which pages will be used before the process is swapped out again.
10. The pager then brings only those pages into memory.
11. The valid-invalid bit scheme is used to determine if the page is on the disk.
a. When bit set to “valid”: The page is legal and in memory.
b. When bit set to “invalid”: The page is not in its address specified or it is currently on the disk.
12. A page-table entry is made based in this for every pages.
13. Access to a page marked invalid in the page-table entry causes a Page Fault.
14. It results in a trap to the operating system.
15. After this the OS swaps page into frame via scheduled disk operation and replacement algorithms.