Demand Paging

A demand paging system is quite similar to a paging system with swapping. When we want to execute a process, we swap it into memory. Rather than swapping the entire process into memory, however, we use a lazy swapper called pager.

When a process is to be swapped in, the pager guesses which pages will be used before the process is swapped out again. Instead of swapping in a whole process, the pager brings only those necessary pages into memory. Thus, it avoids reading into memory pages that will not be used in anyway, decreasing the swap time and the amount of physical memory needed.

Hardware support is required to distinguish between those pages that are in memory and those pages that are on the disk using the valid-invalid bit scheme. Where valid and invalid pages can be checked by checking the bit. Marking a page will have no effect if the process never attempts to access the page. While the process executes and accesses pages that are memory resident, execution proceeds normally.

Demand Paging

Access to a page marked invalid causes a page-fault trap. This trap is the result of the operating system's failure to bring the desired page into memory. But page fault can be handled as following

Page Fault

Step Description
Step 1 Check an internal table for this process, to determine whether the reference was a valid or it was an invalid memory access.
Step 2 If the reference was invalid, terminate the process. If it was valid, but page have not yet brought in, page in the latter.
Step 3 Find a free frame.
Step 4 Schedule a disk operation to read the desired page into the newly allocated frame.
Step 5 When the disk read is complete, modify the internal table kept with the process and the page table to indicate that the page is now in memory.
Step 6 Restart the instruction that was interrupted by the illegal address trap. The process can now access the page as though it had always been in memory. Therefore, the operating system reads the desired page into memory and restarts the process as though the page had always been in memory.

Advantages

Following are the advantages of Demand Paging

  • Large virtual memory.
  • More efficient use of memory.
  • Unconstrained multiprogramming. There is no limit on degree of multiprogramming.

Disadvantages

Following are the disadvantages of Demand Paging

  • Number of tables and amount of processor overhead for handling page interrupts are greater than in the case of the simple paged management techniques.
  • Due to the lack of an explicit constraints on a jobs address space size.

results matching ""

    No results matching ""