CS代考计算机代写 Carnegie Mellon

Carnegie Mellon
Memory Mapping
 VM areas initialized by associating them with disk objects.
 Process is known as memory mapping.
 Area can be backed by (i.e., get its initial values from) :  Regular file on disk (e.g., an executable object file)
 Initial page bytes come from a section of a file  Anonymous file (e.g., nothing)
 First fault will allocate a physical page full of 0’s (demand-zero page)  Once the page is written to (dirtied), it is like any other page
 Dirty pages are copied back and forth between memory and a special swap file.
1

Carnegie Mellon
Demand paging
 Key point: no virtual pages are copied into physical memory until they are referenced!
 Known as demand paging
 Crucial for time and space efficiency
2

Carnegie Mellon
Sharing Revisited: Shared Objects
Process 1 virtual memory
Physical memory
Process 2 virtual memory
 Process 1 maps the shared
object.
Shared object
3

Carnegie Mellon
Sharing Revisited: Shared Objects
Process 1 virtual memory
Physical memory
Process 2 virtual memory
 Process 2 maps the shared
object.
 Notice how the virtual
addresses can be different.
Shared object
4

Carnegie Mellon
Sharing Revisited:
Private Copy-on-write (COW) Objects
Process 1 virtual memory
Physical memory
Process 2 virtual memory
Private copy-on-write area
 Two processes mapping a private copy-on-write (COW) object.
Private copy-on-write object
 Area flagged as private copy-on- write
 PTEs in private areas are flagged as read-only
5

Carnegie Mellon
Sharing Revisited:
Private Copy-on-write (COW) Objects
Process 1 virtual memory
Physical Process 2 memory virtual memory
 Instruction writing to private page triggers protection fault.
 Handler creates new R/W page.
 Instruction restarts upon handler return.
 Copying deferred as long as
possible!
Copy-on-write
Write to private copy-on-write page
Private copy-on-write object
6