Skip to main content

Page fault, demand paging, address translation

Short answer

A page fault occurs when a referenced page is not in memory; demand paging loads pages only on demand. For logical address 18325, page number 2 maps to frame 11, giving physical address 92053.

Define page fault and demand paging. Consider a paged memory system with eight pages of 8KB page size each and 16 page frames in memory. Using the given page table, compute the physical address for the logical address 18325.

PageFrame
710
64
50
47
313
211
114
05

Page fault

A page fault is a trap generated by the MMU when a process references a page which is not present in main memory. The OS loads the page from disk into a free frame, updates the page table and restarts the instruction.

Demand paging

In demand paging a page is brought into memory only when it is demanded (referenced) for the first time, rather than loading the whole program at start. A valid/invalid bit in each page-table entry shows if the page is in memory. A reference to an invalid page causes a page fault, which the OS services. Advantages: less I/O, less memory used per process, faster start, more processes in memory. This scheme is called "lazy swapping" using a pager.

Address translation

  • Page size = 8 KB = 8192 bytes (13-bit offset). 8 pages = 64 KB logical space (16-bit logical address: 3 bits page + 13 bits offset). 16 frames = 128 KB physical memory (17-bit physical address: 4 bits frame + 13 bits offset).
  • Logical address = 18325.
  • Page number = 18325 div 8192 = 2 (2 × 8192 = 16384).
  • Offset = 18325 − 16384 = 1941.
  • From the page table, page 2 → frame 11.
  • Physical address = 11 × 8192 + 1941 = 90112 + 1941 = 92053.
 18325 = 010 0011110010101
          |       |
        page 2   offset 1941
        page table[2] = 11 = 1011
 physical = 1011 0011110010101 = 92053

Answer: physical address = 92053.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Operating System chapter 4 questions →