---
title: "Page fault; virtual to physical address"
subject: "Operating System"
chapter: 4
key: "semester_6/operating_system:page-fault-64k-virtual-32k-physical"
source: https://www.bctengineer.com/q/semester_6/operating_system/page-fault-64k-virtual-32k-physical
site: BCT Engineering
---

# Page fault; virtual to physical address

Operating System · Chapter 4: Memory Management

- Asked in: 2069 Bhadra, 2+8 marks
- Video: [Page Fault in Virtual Memory](https://www.youtube.com/watch?v=lgmws9oraXE) — TutorialsPoint
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/page-fault-64k-virtual-32k-physical
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-4

## Question

What is page fault? Assume that a virtual memory of size 64K is mapped to physical memory of 32K with page frame 4K. Initially, pages are mapped as: 0,1,2,3,4,5,9,11 correspond to 2,1,6,0,4,3,5,7 respectively. Calculate outgoing physical address for incoming virtual address 20482 with necessary mapping diagrams.

## Short answer

A page fault occurs when a referenced page is not in main memory. For virtual address 20482 with 4KB pages, page number is 5, offset 2; given page table maps page 5 to frame 3, so physical address is 12290 (no fault).

## Answer

#### Page fault
A **page fault** is a trap raised by the MMU when a process references a page that is in its virtual address space but whose page-table entry is marked *not present* in main memory. The OS then finds the page on disk, loads it into a free frame (replacing a page if none is free), updates the page table and restarts the instruction.

#### Address translation
- Page size = frame size = 4 KB = 4096 bytes.
- Virtual pages = 64K / 4K = 16 (pages 0 to 15, 4-bit page number); physical frames = 32K / 4K = 8 (frames 0 to 7, 3-bit frame number). Offset = 12 bits.
- Virtual address = 20482. Page number = 20482 div 4096 = **5** (5 × 4096 = 20480). Offset = 20482 − 20480 = **2**.

Page table (given mappings; others not present):
```text
 page : 0 1 2 3 4 5 9 11
 frame: 2 1 6 0 4 3 5 7
```
Page 5 maps to **frame 3** (present, so no page fault).

```text
 Virtual address 20482 = 0101 000000000010
                          |        |
                      page 5     offset 2
                          v
                 page table[5] = frame 3 (011)
                          v
 Physical address = 011 000000000010
                  = 3 x 4096 + 2 = 12290
```
**Answer: physical address = 12290** (frame 3, offset 2; hexadecimal 0x3002).

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is a page fault?
   A. A protection violation always
   B. A trap when a referenced page's entry is not present in memory
   C. An invalid instruction
   D. A disk failure
   Answer: B. The OS loads the page from disk and restarts the instruction. (Key point: Page fault)

2. For 20482 with 4 KB pages, the page number is?
   A. 20
   B. 4
   C. 2
   D. 5
   Answer: D. 20482 div 4096 = 5 with remainder 2. (Key point: Page number)

3. Page 5 maps to which frame?
   A. 3
   B. 1
   C. 4
   D. 5
   Answer: A. Given mapping: 5 -> 3. (Key point: Frame lookup)

4. Physical address for virtual 20482?
   A. 3002
   B. 20482
   C. 12290
   D. 12288
   Answer: C. 3*4096 + 2 = 12290 (0x3002 in hex, not decimal 3002). (Key point: Physical address)

## Related in Operating System

- [Page fault, demand paging, address translation](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apage-fault-demand-paging-address) — Operating System, chapter 4
- [Logical and physical address bits](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aresidence-monitor-address-bits) — Operating System, chapter 4
- [Segmentation; page table size; TLB](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Asegmentation-address-bits-tlb) — Operating System, chapter 4
- [Page size impact; internal, external fragmentation](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apage-size-impact-fragmentation) — Operating System, chapter 4
- [File system vs virtual memory; contiguous allocation](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afs-vs-virtual-memory-contiguous-tape) — Operating System, chapter 5
- [Virtual memory management; thrashing](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Avirtual-memory-thrashing) — Operating System, chapter 4

## Related in other subjects

- [Memory-mapped I/O reduces address space](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Ammio-address-space) — Computer Organization and Architecture, chapter 7
- [Poisson: error pages in 400-page novel](https://www.bctengineer.com/question.md?key=semester_5%2Fprobability_and_statistics%3Apublisher-typo-pages-400) — Probability and Statistics, chapter 2
- [Unique/non-unique decoding, memory mapped I/O](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aunique-nonunique-decoding-memory-mapped-io) — Microprocessor, chapter 4
- [Memory-mapped I/O design for 8085](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Amemmapped-io-design-1000h) — Instrumentation II, chapter 2
