200 likes | 354 Views
Windows XP Memory Management. Aaron Lanoy and Jason Farnsworth. Outline. Virtual Memory Manager Memory Allocation Page Replacement Paged vs. non-paged pools. Virtual Memory Manager. Seems to let each process “have” 4GB of contiguous memory Page frames (main memory) or page files (disk)
E N D
Windows XP Memory Management Aaron Lanoy and Jason Farnsworth
Outline • Virtual Memory Manager • Memory Allocation • Page Replacement • Paged vs. non-paged pools
Virtual Memory Manager • Seems to let each process “have” 4GB of contiguous memory • Page frames (main memory) or page files (disk) • Copy-on-write • Lazy allocation • Disk I/O as little as possible, but fetches large chunks when done
Virtual Memory Manager • Allocates a unique 4GB virtual address space to each process • A process can only access the first 2GB • 4KB fixed-size page frames • Pseudo-Exception: Large Pages • Large set of contiguous pages treated as a single page • Data that is always accessed together • Speeds up page access • Must be 2MB or greater multiple, must allow read & write, constituent pages must be contiguous in virtual and physical memory
Virtual Memory Manager • Processes have one page directory table • Loaded into page directory register • Page directory entries point to page tables • Page table entries point to page frames • VMM uses virtual addresses along with the memory map to translate into a physical address
Address Translation Address Translation Animation
Virtual Memory Manager • Address translation: • Translation is algorithm very quick • Delay caused by the time required to read PDE’s and PTE’s out of main memory • Can be sped up through use of Translational Look-aside Buffer (TLB)
Virtual Memory Manager • PTE’s are 32 bits long, 5 of which are used for protection / state indication • Read, write, execute, copy-on-write, exception flag, valid, modified, transition, etc… • Copy-on-write • Utilizes prototype page tables – instead of pointing directly to the frame, points to a PPTE that points to the frame • File mapping, common area of memory for inter-process communication • Better utilization of memory but longer address translations
Memory Allocation • 3-step memory allocation: • Reservation • Commitment • Access • Windows XP denies all “must-succeed requests” • Shifts burden onto components to deal with the denial
Memory Allocation • Problem: Low memory situation Solution: I/O Throttling • Switches from fetching large numbers of pages at each disk I/O access to fetching a single page at a time • Slows down the system, but prevents crashes
Memory Allocation • Page frame database • Tracks the state of all frames with a singly linked list for each possible state • 8 States:
Page Replacement Scenario Page replacement demonstration
Page Replacement • The working set of a process is all of its pages that are in main memory • Balance set manager moves some of a process’s working set to page files when memory becomes scarce • Localized least-recently used policy to determine which pages to move to disk • Working set max (can be dynamic) • Working set min (dynamic only if system memory is low)
Memory Allocation • Virtual Address Descriptors, the virtual address space allocated to a process • Windows XP attempts to anticipate needed pages • Demand paging: loads the requested page and nearby pages (spatial locality) • Pages in the same cluster are likely to be part of the same file • Loads the pages from an entire cluster at a time • Results in higher memory usage, lowered disk hits
Memory Allocation • Windows XP and prefetching • Tracks the last 8 applications loaded, for the 9th application, loads all the pages from those applications • On boot, prefetches pages while devices are initialized • Logical Prefetcher – records memory accesses in a scenario file • Requires extra time to write this file • Results in a less disk I/O (faster load times) • Used for ALL applications and Windows XP itself
Paged vs. Non-paged • Non-paged pool • Cannot be written to disk • Data always remains in memory • Examples: Code for interrupt handling, unencrypted passwords, portions of device drivers and the VMM • Cons: Limited space, no access paged pool or disk
The Near-Future • DEP (Data Execution Prevention): Security bit with all 64-bit processors and more recent Pentiums • 32 vs. 64 bit systems
Summary • Virtual Memory Manager • Memory Allocation • Page Replacement • Paged vs. non-paged pools