100 likes | 285 Views
Virtual Memory Primitives for User Programs. Andrew W. Appel and Kai Li Presented by: Khanh Nguyen. Plan of Attack. Virtual Memory Primitives Virtual Memory Applications Shared Virtual Memory Concurrent Garbage Collection Generational Garbage Collection Heap Overflow Detection
E N D
Virtual Memory Primitives for User Programs Andrew W. Appel and Kai Li Presented by: Khanh Nguyen
Plan of Attack • Virtual Memory Primitives • Virtual Memory Applications • Shared Virtual Memory • Concurrent Garbage Collection • Generational Garbage Collection • Heap Overflow Detection • Applications Patterns • VM Primitive Performance
Virtual Memory Primitives • TRAP: handle page-fault traps in user mode • PROT1: decrease the accessibility of a page • PROTN: decrease the accessibility of N pages • UNPROT: increase the accessibility of a page • DIRTY: return a list of dirtied pages since the previous call. • MAP2: map the physical page at two different virtual addresses, at different levels of protection, in the same address space.
Shared Virtual Memory • Useful for splitting a task into multiple computers working together over the network.
Shared Virtual Memory (cont.) • Each processor has its own memory • Each memory basically represents the big cache for the shared virtual memory. • Read-only page can have copies residing in the physical memories of many processors at the same time. • When a processor trying to access to the page, but it’s not on the its memory, it will trigger a fault that invoke Mapping manager to go out the network to get the up-to-date page. • If it’s a write access, Mapping Manager send out a message to invalidate all other copies. • Uses PROT1, TRAP, and UNPROT
Concurrent Garbage Collection • Base on Baker’s algorithm • Divides the memory heap into from-space and to-space • At the beginning of a collection, all objects are in the from-space and to-space is empty. • Collectors copy any reachable object from from-space to to-space. Any remaining objects are garbage. Remove garbage and Flip the space around. • Any new allocate object will be created in to-space. • Any access to the old object that is still referenced to the from-space will be move to-space. This is done by inserting instruction to check every fetch or virtual memory • Uses PROTN, TRAP, UNPROT
Generational Garbage Collection • Two properties of dynamically allocated object • Younger records are much more likely to die soon than older records. • Younger records tend to point to older records. • Allocated objects are kept in area based on their age. This area is called generation • Collector usually collect in the youngest generation. • If it finds any object in the youngest generation that is pointed by the older generation, it will keep that object. • The only way to find if a young generation is pointed by an older generation, we need to check every assignment operation. • Or protect the older generations with “no write” flag. • Uses PROTN, TRAP, UNPROT, or DIRTY
Heap Overflow Detection • Ordinarily, heap overflow is detected by compare and conditional-branch on every memory allocation operation • Problem: overhead • Similar to stack overflow detection • Mark the top page with “no access” • Use PROT1 and TRAP • Doesn’t use UNPROT because the protection will never be removed.