Final answer:
Demand paging is a memory management technique where pages are loaded into memory only when a page fault occurs. It is efficient as it only loads necessary pages, and when memory is full, it replaces pages based on a replacement algorithm like LRU or FIFO.
Step-by-step explanation:
Demand paging is a memory management scheme that loads pages into memory only when they are needed. This strategy is used to optimize the use of the physical memory (RAM) and to reduce the number of pages loaded, improving the system's efficiency. In demand paging, pages are loaded only when a page fault occurs, meaning that a page that is not currently in memory is being requested by the process. If there is not enough memory available, the system decides which page to remove, typically using a page replacement algorithm.
Once a page fault happens, the operating system locates the required page on the secondary storage (such as a hard drive) and then loads it into the memory. If memory is full, it will replace an existing page, often selecting the one that has not been used for the longest period or the one least likely to be used soon, according to the page replacement policy being used, such as Least Recently Used (LRU) or First-In-First-Out (FIFO).