What are demand-paging and pre-paging?

4 years ago
Operating System

With demand paging, a page is brought into memory only when a location on that page is actually referenced during execution. With pre-paging, pages other than the one demanded by a page fault are brought in. The selection of such pages is done based on common access patterns, especially for secondary memory devices.

Demand Paging


Demand paging is a technique used in virtual memory systems where the pages are brought in the main memory only when required or demanded by the CPU. Hence, it is also named as lazy swapper because the swapping of pages is done only when required by the CPU.

Advantages

  • It increases the degree of multiprogramming as many processes can be present in the main memory at the same time.
  • There is a more efficient use of memory as processes having size more than the size of the main memory can also be executed using this mechanism because we are not loading the whole page at a time.

Disadvantages

  • The amount of processor overhead and the number of tables used for handling the page faults is greater than in simple page management techniques.

PrePaging


In demand paging, that page is brought to the main memory which is actually demanded during the execution of the process. But, in pre-paging pages other than the demanded by the CPU are also brought in. The OS guesses in advance which page the process will require and pre-loads them into the memory.

Advantages

  • It saves time when large contiguous structures are used. Consider an example where the process requests consecutive addresses. So, in such cases, the operating system can guess the next pages. And, if the guesses are right, fewer page faults will occur and the effective memory access time will increase.

Disadvantages

  • There is a wastage of time and memory if those pre-paged pages are unused.

This was about demand paging and pre-paging. Hope you learned something new today.

More related questions

Questions Bank

View all Questions