Professional Documents
Culture Documents
II
CSCI-0310
Pascal Van Hentenryck
CSCI-0310 Page 1
Physical Memory
page 0
page 1
page 2
page 3
page 4
…………..
page 220-1
CSCI-0310 2
Address Space
virtual page 0
virtual page 1
virtual page 2
virtual page 3
virtual page 4
……………...
CSCI-0310 3
Address Space
Where is the address space stored?
• On a disk which is large and slow
The disk!
CSCI-0310 4
Address Translation
63 62 … 12 11 … 0
Translate
31 … 12 11 … 0
CSCI-0310 5
Physical Memory
page 0 (4K) vpn LRU Dirty
…
…………..
CSCI-0310 6
Address Translation
63 62 … 12 11 … 0
Translate
31 … 12 11 … 0
CSCI-0310 7
Address Translation
CSCI-0310 8
Address Translation
Page table
Keep track of where the virtual pages
are (in memory or on the disk)
for each virtual page number, keep
whether it is on the disk or in memory
and where
CSCI-0310 9
Page Table
CSCI-0310 10
Translation
CSCI-0310 11
Mapping Virtual to Physical
63 62 … 12 11 … 0
52 bits
…
12 bits
Page 20 bits
Table
31 30 … 12 11 … 0
CSCI-0310 12
Translation
CSCI-0310 13
Mapping Virtual to Physical
PTR 63 62 … 12 11 … 0
…
Page
Table
12
bits
20 bits
31 30 … 12 11 … 0
CSCI-0310 14
Reading/writing
What happens on a read?
Find out if the page is in
memory by accessing the page
table
If the bit is valid, the page table
has the physical address (hit)
Otherwise, page fault. Bring the
page to the RAM (swap in) and
update the page table
What happens on “swap out”
CSCI-0310 15
Reading/writing
What happens on a read?
Find out if the page is in
memory by accessing the page
table
If the bit is valid, the page table
has the physical address (hit)
Otherwise, page fault. Bring the
page to the RAM (swap in) and
update the page table
What happens on “swap out”
update the page table to be
invalid
how can we do this?
CSCI-0310 16
Physical Memory
page 0 (4K) VPN LRU Dirty
…
…………..
CSCI-0310 17
Speeding Up
The virtual-to-physical address
mapping currently requires (at least)
one extra memory reference.
The program must access the page
tables before trying to access the
physical address
This will double the time to service
memory requests.
It is even worse if the value is in the
cache
CSCI-0310 18
Speeding Up
The virtual-to-physical address mapping
currently requires (at least) one extra
memory references.
The solution?
another “cache”
The translation-lookaside buffer (TLB) is a
special cache for storing translation of
virtual to physical address
CSCI-0310 19
Speeding Up
63 62 … 12 11 … 0
31 30 … 12 11 … 0
CSCI-0310 20
Speeding Up
CSCI-0310 21
Reading Time Again
CSCI-0310 22
Reading Time
CSCI-0310 23
Page Table
With a 64-bit address space and 4K
pages, the page table takes about
8,000,000 megabytes
• offset: 12 bits
• virtual page: 52 bits
• how many virtual pages?
252
• what do we store per page?
> 2 words
CSCI-0310 24
Page Table
With a 64-bit address space and 4K
pages, the page table takes about
8,000,000 megabytes
• offset: 12 bits
• virtual page: 52 bits
• how many virtual pages?
252
• what do we store per page?
> 2 words
What are we going to do?
• segmented paging
• inverted page table
CSCI-0310 25
Segmented Paging
26 26
CSCI-0310 26
Segmented Paging
Segments
• Entries point to page tables
Page tables
• Entries point to pages
Features
• Segment table is much smaller
• Keep the segment page in memory
Still not enough (?)
• Add one more level
Main drawback
• How many memory accesses?
CSCI-0310 27
Inverted Page Table
CSCI-0310 28
Reading Time Again
CSCI-0310 30