what is demand paging

what is demand paging

1 year ago 39
Nature

Demand paging is a memory management technique used in computer operating systems to optimize memory usage and system performance. In a system that uses demand paging, the operating system loads only the necessary pages of a program into memory at runtime, instead of loading the entire program into memory at the start. This is often referred to as lazy loading, as only those pages demanded by the process are swapped from secondary storage to main memory.

Demand paging follows the principle that pages should only be brought into memory if the executing process demands them. This approach is very efficient in terms of memory usage since it does not require the entire program to be loaded into memory at once. Contrast this to pure swapping, where all memory for a process is swapped from secondary storage to main memory during the process startup.

The working process of demand paging involves six steps:

  1. Handle the page faults.
  2. Find the required page in the page table.
  3. Access the page and forward it to the process.
  4. If the target page is not found, generate a trap or page fault signal.
  5. Send the signal to the operating system.
  6. Apply the demand paging technique.

Some strategies to optimize demand paging include using efficient page replacement algorithms and data structures to manage page tables and swap space. Demand paging allows the system to swap out pages that are not currently in use, freeing up memory for other processes. When a page that has been swapped out is needed again, the system can bring it back into memory. Therefore, the main motivation behind demand paging is to reduce the time taken for process initialization and to reduce the memory requirements for a process.

Read Entire Article