CS代考计算机代写 Carnegie Mellon

Carnegie Mellon
Handling Page Fault
 Page miss causes page fault (an exception)
Virtual address
PTE 0
Physical page number or disk address
Physical memory (DRAM)
PP 0 PP 3
Virtual memory (disk)
VP 1
VP 2
VP 7
VP 4
Valid
1
0
1
null
0
0
PTE 7
null
0
1
1
VP 1
VP 2
VP 3
VP 4
VP 6
VP 7
Memory resident page table (DRAM)
1

Carnegie Mellon
Handling Page Fault
 Page miss causes page fault (an exception)
 Page fault handler selects a victim to be evicted (here VP 4)
Virtual address
PTE 0
Physical page number or disk address
Physical memory (DRAM)
PP 0 PP 3
Virtual memory (disk)
VP 1
VP 2
VP 7
VP 4
Valid
1
0
1
null
0
0
PTE 7
null
0
1
1
VP 1
VP 2
VP 3
VP 4
VP 6
VP 7
Memory resident page table (DRAM)
2

Carnegie Mellon
Handling Page Fault
 Page miss causes page fault (an exception)
 Page fault handler selects a victim to be evicted (here VP 4)
Virtual address
PTE 0
Physical page number or disk address
Physical memory (DRAM)
PP 0 PP 3
Virtual memory (disk)
VP 1
VP 2
VP 7
VP 3
Valid
1
1
0
null
0
0
PTE 7
null
0
1
1
VP 1
VP 2
VP 3
VP 4
VP 6
VP 7
Memory resident page table (DRAM)
3

Carnegie Mellon
Handling Page Fault
 Page miss causes page fault (an exception)
 Page fault handler selects a victim to be evicted (here VP 4)
 Offending instruction is restarted: page hit!
Physical memory (DRAM)
PP 0 PP 3
Virtual memory (disk)
Virtual address
Physical page number or disk address
VP 1
VP 2
VP 7
VP 3
Valid
PTE 0
1
1
0
null
0
0
PTE 7
null
0
1
1
VP 1
VP 2
VP 3
VP 4
VP 6
VP 7
Memory resident page table (DRAM)
4

Carnegie Mellon
Locality to the Rescue Again!
 Virtual memory works because of locality
 At any point in time, programs tend to access a set of active virtual pages called the working set
 Programs with better temporal locality will have smaller working sets
 If (working set size < main memory size)  Good performance for one process after compulsory misses  If ( SUM(working set sizes) > main memory size )
 Thrashing: Performance meltdown where pages are swapped (copied) in and out continuously
5