Beruflich Dokumente
Kultur Dokumente
Virtual Memory
Virtual Memory
Goal: every process thinks it has a huge memory
entirely to itself.
Virtual address space: addresses 0 to 2321
- (or 0 to 2641 on machines with 64-bit addressing).
- even if there is much less physical memory.
Virtual memory also provides protection
-
-
Virtual Memory
Can be seen as another level in the memory hierarchy
Main memory is a cache of a larger memory space.
Disk holds data in VM that doesn t fit in cache
VM may be bigger than disk
cpu
cache
memory
virtual memory
disk
virtual addresses
disk
Virtual Memory
For historical reasons, it uses different terminology
Cache
VM
Block (line)
page
Cache miss
Page fault
address
Virtual address
Therefore:
large pages [analogous to cache line] (4 KB to MBs)
associative mapping of pages (typically fully associative)
software handling of misses (but HW handles hits!!)
Many pages
With 64 MByte memory, 4KBytes/page, have 16K pages
- It s not practical to have 16K comparators
- Nor to have software do many comparisons
How can we get virtual memory with full associativity???
Page table
Physical page or
disk address
Valid
1
1
1
1
0
1
1
0
1
1
0
1
Physical memory
Disk storage
Address Translation
Virtual address
31 30 29 28 27
15 14 13 12
11 10 9 8
3210
Page offset
T ranslat ion
2 9 2 8 27
15 14 13 12
11 10 9 8
3210
Page offset
Physical address
8
Virtual address
31 30 29 28 27
1 5 1 4 1 3 12 1 1 1 0 9 8
Vir tual page number
Page offset
20
Valid
3 2 1 0
12
P hysical page number
Page table
18
If 0 then page is not
present in memory
29 2 8 27
15 1 4 13 1 2 11 10 9 8
P hysical page number
Physical address
3 2 1 0
Page offset
10
V a l id
Ta g
1
1
1
1
0
1
P hy sica l pa ge
a dd res s
P h y s ic a l m e m o r y
P a g e ta b l e
P h y si ca l p a g e
V a li d o r d is k a d d r e s s
1
1
1
1
0
1
1
0
1
1
0
1
D is k s t o r a g e
11
12
15 14 1 3 1 2 11 1 0 9 8
Virtua l p ag e nu mb er
3210
Pa ge o ffset
20
Va lid Dirty
12
P hysic al pa ge n um be r
Ta g
T LB
T L B h it
20
Ph ysica l p a ge nu m be r
Page o ffset
P hy sical ad dre ss
Ph ysica l ad dre ss tag
C ac he in de x
14
16
Va lid
Ta g
B y te
offse t
2
D a ta
Ca ch e
32
Cache hit
D a ta
13
Key Terms
15
Key Terms
16