














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















-^
3
Running multiple programs at the same time brings up more problems.1. Even if each program fits in memory, running 10 programs might
not.^ –
This is really the same problem as on the previous slide.
y^
p^
p
address.
i e
what if both Program A and B want to use address
-^
i.e., what if both Program A and B want to use address0x10000000 as the base of their stack?
-^
It is impractical (if not impossible) to compile every pair ofprograms that could get executed together to use distinct setsof addressesof addresses.
by another program?
5
-^
6
-^
-^
8
-^
-^
-^
9
Because different processes will have different mappings fromvirtual to physical addresses, two programs can freely use thevirtual to physical addresses, two programs can freely use thesame virtual address.
-^
By allocating distinct regions of physical memory to A and B,they are prevented from reading/writing each others data.they are prevented from reading/writing each others data.
ess r
PhysicalMemory
Virt
Program A
Program B
tual Addr r
tual Addre
Vir
Disk
ess
11
Once the translation infrastructure is in place, the problem boilsdown to cachingdown to caching.– We want the size of disk, but the performance of memory.
-^
The design of virtual memory systems is really motivated by theThe design of virtual memory systems is really motivated by thehigh cost of accessing disk.– While memory latency is ~100 times that of cache, disk
latency is ~100,000 times that of memory.
Hence, we try to minimize the miss rate:– VM “pages” are much larger than cache blocks. Why?
A fully associative policy is used
Should a write-through or write-back policy be used?Should a write through or write back policy be used?
12
If it is fully associative, how do we find the right page without scanningall of memory?all of memory?– Use an index, just like you would for a book.Our index happens to be called the page table:
-^
Our index happens to be called the page table:– Each process has a separate page table
tabletable
physical address No tag is needed because the index is the full VPN
14
Virtual address
Page table register
Page offset
Virtual page number
Virtual address
20
12
31
30 29
28 27
15 14
13
12
11 10
9
8
3 2 1 0
Physical page number
Valid
Page table
If 0 then page is notpresent in memory
18
29
28
27
15
14
13
12
11
10
9 8
3 2
1
0
Page offset
Physical page number
Physical address
15
Multi-level page tables– “Any problem in CS can be solved by adding a level of indirection”
Any problem in CS can be solved by adding a level of indirection
Page TableB
P i t
2nd
A 3 l
l^
bl
Base Pointer
1st
3rd
A 3-level page table
VPN
VPN
VPN
offset PPN
PPN
offset
Since most processes don’t use the whole address space, you don’tll
t^
th
t bl
th t
’t^
d d
allocate the tables that aren’t needed– Also, the 2nd and 3rd level page tables can be “paged” to disk.
17
We’ve just replaced every memory access MEM[addr] with:MEM[MEM[MEM[MEM[PTBR + VPN1<<2] + VPN2<<2] +
VPN3<<2] + offset]
-^
i.e.
, 4 memory accesses
And we haven’t talked about the bad case yet (
i.e.
,^ page
y^
, p g
faults)… “Any problem in CS can be solved by adding a level of indirection”
y p
y^
g
How do we deal with too many levels of indirection?
y
18
-^
-^
20
-^
-^
21