Presentation is loading. Please wait.

Presentation is loading. Please wait.

Virtual Memory CS 147 October 30, 2007 Chris Stewart.

Similar presentations

Presentation on theme: "Virtual Memory CS 147 October 30, 2007 Chris Stewart."— Presentation transcript:

1 Virtual Memory CS 147 October 30, 2007 Chris Stewart

2 What is Virtual Memory? Computer technique that gives application the impression it is working with contiguous memory when in fact the memory is physically fragmented Memory may also spill into physical storage (hard drives)‏ Not only limited to using hard drive space as “extended RAM” Memory extension is a consequence of virtual memory techniques

3 What is Virtual Memory? Virtual memory is, by definition, tricking applications into thinking the memory they are working with is contiguous Makes application programming easier for users, as management of virtual addresses is done at a low level

4 A pretty picture Shamelessly stolen from Wikipedia

5 History 1940s-1950s: No virtual memory. Large programs had to contain logic for managing “two-level storage” and were responsible for moving data between secondary and primary storage. 1960s: Virtual memory developed, debate over efficiency lasted until 1969 Virtual memory became widespread from there Initially, memory was “segmented” and these segments could vary in size Was inefficient with larger segments

6 How does it work? Multiple methods of implementing virtual memory Almost all of them require a Page Table  A “page” is a block of contiguous virtual memory addresses  Virtual addresses are unique to the accessing program or process and map uniquely to a physical address  Provides memory protection, among other benefits x86 Implementation – Two modes – Real and Virtual

7 How does it work? Real:  Address registers contain an integer that addresses some word or byte of RAM  Memory is addressed sequentially Virtual:  Memory is divided into pages that are 4096 bytes long  Pages may reside in any available RAM location  Address Registers are divided into an “index” and an “offset”  Addresses are resolved by looking up the index in the page table, which yields a physical address, and adding the offset

8 How does it work? Translation between Virtual and Physical Addresses is done in hardware. This component looks up the physical address corresponding to a particular virtual address and passes it to the CPU. Should there be no record of the virtual address being looked up, a “page fault interrupt” is generated. This interrupt is handled by a special part of the operating system.

9 How does it work? The paging supervisor is a part of the operating system responsible for creating and maintaining page files. If the translation hardware raises a page fault, the following process occurs:  Paging supervisor searches page file(s) on disk  Page containing the required virtual address is read into memory  Page table updated to reflect movement of page  Translation hardware told to restart search Uses LRU ordering when determining which area of physical memory to overwrite

10 Paging Confusing terminology time! Paging is the process of saving inactive memory pages to disk and restoring them to physical memory when they are needed again. Pages do not necessarily return to the same physical memory location they left Applications are only aware of their virtual addresses Page table must be updated each time memory changes physical locations

11 Another Pretty Picture Which has also been shamelessly stolen from Wikipedia

12 So why do it? Extend memory onto hard disk, allowing programs access to more memory than is currently installed on the system  Simply called “page file” on NT systems  Called “swap space” on Unix and Unix-like systems Memory is protected: applications are only aware of a small subset of virtual addresses, which makes memory conflicts less likely

13 Sources Wikipedia!

Download ppt "Virtual Memory CS 147 October 30, 2007 Chris Stewart."

Similar presentations

Ads by Google