<<

Processes

Memory Memory Memory Stack Stack Stack Heap Heap Heap Data … Data Code Code Code

CPU CPU CPU Registers Registers Registers

Sean Barker 1

Virtual Memory Solution: (address )

Virtual memory

Process 1

virtual Physical memory addresses virtual-to-physical mapping physical Virtual memory addresses

Process n virtual addresses

Private virtual Single space per process. Sean Barker managed by OS/hardware.2

6 Address Translation Virtual Addressing and Address Translation

Memory Management Unit translates virtual address to physical address Main memory 0: CPU Chip 1: Virtual address Physical address 2: (VA) (PA) 3: CPU MMU 4: 4100 4 5: 6: 7: 8: ...

M-1:

Data

Physical addresses areSean Barker invisible to programs. 3 9

Memory Pages Page-based Mapping both address spaces Virtual divided into fixed-size, aligned pages Address Space page size = power of two 0 Virtual Physical Page Address Space 0 0 Virtual Physical Page Page 0 1 Virtual Physical Page Page 2 1 Virtual Page Map virtual pages 3 … onto physical pages. Physical … Page m 2p - 1 Virtual 2 - 1 Page 2n - 1 2v - 1 Some virtual pages do not fit! Where are they stored? Sean Barker 4 Page Fault Page Fault: exceptional control flow

Process accessed virtual address in a page that is not in physical memory.

Process User Code OS exception handler

exception: page fault movl Load page return into memory

Returns to faulting instruction: movl is executed again! 20

Sean Barker 5

Paging Example

Sean Barker 6 Page Tables

Sean Barker 7

Translation Look-aside Buffer (TLB)

v: valid

Sean Barker 8