Professional Documents
Culture Documents
Address Translation
Review
Segmentation
g
creates external fragmentation
g
and requires
q
large
g
regions of contiguous physical memory.
We look to fixed sized units, memory pages, to solve the problem.
Virtual Memory
Concept
2n-1
Program
Ps
VAS
Issues
Placement strategies
Replacement strategies
0
3
(f,o)
o
Physical
Memory
f
PA:
log2 (fmax omax)
log2 omax
(0,0)
(3,6)
1,542
o
3
PA:
Physical
Memory
0000011000000110
16
10 9
1,542
(0,0)
0
5
Questions
(p,o)
Virtual
Address
Space
p
VA:
log2 (pmaxomax)
log2 oMAX
(0,0)
Paging
Mapping virtual addresses to physical addresses
Virtual
Address
Space
(p2,o2)
(f1,o1)
Physical
Memory
(p1,o1)
(f2,o2)
Address translation is
A. Frequent
B. Infrequent
Paging
Virtual address translation
Program
P
(f,o)
CPU
Ps
Virtual
Address
Space
(p,o)
p
20
o
10 9
f
1
16 10 9
Virtual
Addresses
Add
Physical
Memory
Physical
Addresses
f
p
Page Table
10
Contents:
CPU
p
20
10 9
16 10 9
Virtual
Addresses
PTBR
Physical
Addresses
010
p
Page Table
11
(4,1023)
32 KB of physical memory
1024 byte pages
(4,0)
(3,1023)
CPU
Ps
Virtual
Address
Space
p
15
Physical
Addresses
o
10 9
f
0
14
o
10 9
Physical
Memory
Virtual
Addresses
Add
10000000
01100100
Page Table
(0,0)
12
Page table can be very large; a part of the page table can be on
disk.
For a machine with 64-bit addresses and 1024 byte pages, what is
the size of a page table?
What to do?
Most computing problems are solved by some form of
Caching
Indirection
13
Physical
Addresses 16 10 9
CPU
p
20
o
10 9
Virtual
Addresses
o
1
Key
Value
f
p
TLB
Page Table
14
Virtual Address
p1 p2
p3
Second-Level
Page Tables
p2
o
p3
p1
Third-Level
Page Tables
First-Level
Page Table
15
CPU
p1 p2
20
PTBR
16
o
10
Memory
Virtual
Addresses
1
page table
p1
Physical
Addresses
f
16
o
10
p2
First-Level
Page Table
Second-Level
Page Table
16
Use one entry for each physical page with a hash table
Size of translation table occupies a very small fraction of physical
memory
Size of translation table is independent of VM size
17
18
Page Registers
How does a virtual address become a physical address?
Memory
CPU
p
20
o
9
Virtual
Address
Physical
Addresses
Hash
PTBR
PID
running
g
=?
=?
PID page
f
16
o
9
tag check
fmax 1
0 1 1 fmax 2
h(PID, p)
0
Inverted Page Table
20
21
Minor complication
Since the number of pages is usually larger than the number of
slots in a hash table, two or more items may hash to the same
l
location
ti
22
Questions
23
Code
Data
Stack
File System
(Disk)
OS/MMU
Physical
Memory
24
Virtual Memory
Physical
Memory
Page
Table
Program
P
Ps
VAS
Disk
25
Example:
26
27
28
Virtual Memory
Summary
29
A. Fine-grained protection.
B Easier
B.
E i tto manage transfer
t
f off segments
t to/from
t /f
the
th disk.
di k
C. Requires less hardware support
D. No external fragmentation
A. Fine-grained protection.
B. Easier to manage transfer of pages to/from the disk.
C Requires less hardware support
C.
support.
D. No external fragmentation.
30