CS 208 s20 — Learning Block #24

Table of Contents

1 Quick Check

Which of the following would NOT cause a page fault?1

  • Accessing a memory address that doesn't exist
  • Accessing a part of program data for the first time
  • Dividing by zero
  • Deferencing a NULL pointer

2 Exercises

We are given a 1 MB byte-addressed machine with 4 MB of VM and 128 KB pages. How many bits wide are the following?2

  • VPN
  • PPN
  • Page Offset
  • Page Table Base Register

What is a virtual page? What is a physical page? What is the relationship between them?3

3 Practice

CSPP practice problem 9.2 (p. 807)4

Determine the number of page table entries (PTEs) that are need for the following combinations of virtual address size (\(n\)) and page size (\(P\)).

\(n\) \(P = 2^p\) Number of PTEs
16 4KB  
16 8KB  
32 4KB  
32 8KB  

Footnotes:

1

Dividing by zero will cause an exception, but not a page fault as it does not involve a memory access outside a valid page

2

128 KB is 217 bytes, 1 MB is 220 bytes, 4 MB is 222 bytes

  • VPN: 5 bits (32 128 KB pages fit into 4MB of virtual memory)
  • PPN: 3 bits (8 128 KB pages fit into 1 MB of physical memory)
  • Page Offset: 17 bits (need a 20-bit physical address to specify a byte within 1 MB of physical memory, 3 bits for PPN leaves 17 bits of offset)
  • Page Table Base Register: 20 bits (address in physical memory)
3

A virtual page is a fixed-size block of memory within a virtual address space. A physical page is a fixed-size block of memory within physical memory or on disk. A virtual and physical page are the same size. Once initialized, a virtual page maps to a physical page either in memory or on disk. The hardware/OS translates addresses within virtual pages to the corresponding addresses within physical pages.

4
\(n\) \(P = 2^p\) Number of PTEs
16 4KB 16
16 8KB 8
32 4KB 1 M
32 8KB 512 K