Upload
paula-walker
View
222
Download
1
Embed Size (px)
Citation preview
Virtual Memory
By
Steven LaBarbera
What I plan to cover
The history of virtual memory How virtual memory has evolved How virtual memory is used today Why is virtual memory important
History of virtual memory
Early computers used a two-level storage system consisting of main memory and secondary memory.
main memory (RAM) for the first computers were magnetic cores.
The secondary memory (hard disks) were magnetic drums.
History of virtual memory
Early in computers infancy memory was neither inexpensive nor easy to find.
the most sophisticated computers were lucky to have 128 kilobytes of memory, a fraction of what a floppy disk can hold.
This lack of space had serious implications on older systems processing power.
Why did lack of space have serious implications?
Programmers had to re-code their program every time they switched machines or added more memory.
How did they deal with this?
programmers divided programs into sections that were transferred into main memory for a period of processing time. As the program proceeded, new sections moved into main memory and replaced sections that were not needed. In this early era of computing, the programmer was responsible for devising this overlay system.
The creation of virtual memory
The technique was invented at the University of Manchester for the Atlas Computer, completed in 1962.
How virtual memory works
when a memory location is read or written to hardware within the computer translates the memory address generated by the software (the virtual memory address) into a, usually distinct, real memory address
Continued
This is accomplished by preserving the low order bits of the binary representation of the input address while treating the high order bits as a key to one or more address translation tables.
a range of consecutive addresses in the virtual address space whose size is a power of two will be translated in a corresponding range of consecutive physical addresses.
Simple Paging
The memory referenced by such a range is called a page
In a simple paging system you view the users program as consisting of fixed length blocks
The page size is typically in the range of 512 to 8192 bytes
Simple Paging
In a paging system consider the addresses as consisting of two components.
1. The page number
2. The displacement into the page
Page 0
0FFF
Page 1
1FFF
Page 2
2FFF
Page 3
3FFF
The displacement component
This must be big enough to hold any displacement within a page.
Example 2^12 – byte (4k) page size, the displacement of this has to hold 2^12 – 1.
Thus a 2^12 displacement requires a 12 bit (3 hex digit) displacement field 2^n page requires n-bit displacement field
Translation from virtual memory to physical memory
Translations are managed by the Memory Management Unit (MMU) .
Translation from virtual memory to physical memory
( 1 ) or "logical address" consisting of a logical page number plus the location within that page (x) must be interpreted or "mapped" onto an actual (physical) main memory address by the operating system using an address translation function or mapper
Translation from virtual memory to physical memory
( 2 ) If the page is present in the main memory, the mapper substitutes the physical page frame number for the logical number
Translation from virtual memory to physical memory
( 3 ) If the mapper detects that the page requested is not present in main memory, a fault occurs and the page must be read into a frame in main memory from secondary storage
( 4 , 5 ).
What does the mapper do?
translates the logical page number generated by the program into the physical page frame number where the main memory holds the page
What does the mapper do?
This translation is accomplished by using a directly indexed table called the page table which identifies the location of all the program's pages in the main store
Page Table
As the operating system loads pages of a user program into memory, it uses a page table to keep track of the location of each page.
A page table is a one-dimensional array in main memory that contains a slot for every page in the users program.
Page Table
the page table shows that pages 0,1,2, and 3 are in frames 4,6,2,and 5
Page Number
0
1
2
3
Frame Number
4
6
2
5
DAT Unit
In the book the DAT Unit is used to translate virtual addresses to physical addresses.
Dynamic Address Translation Unit
Paging pros and cons
Pros
• Eliminates memory fragmentation problems seen in multiprogramming systems.
• Paging systems do not have compaction overhead that systems with relocation have.
Cons• Has to do two operations
every time CPU fetches an item from memory.
1. Obtain page number from page table.
2. Obtain desired item from main memory at the computed physical address.
How they fix this inefficiency
Carefully designing the DAT Unit. Every time CPU fetches an item from
memory you keep a copy of the page table in a local memory area of the DAT Unit.
So every time a DAT Unit translates an address from the program, it can get the framer number from local memory.
Demand Paging
Each page table contains two parts
1. The frame number
2. A valid bit
Valid bit field
The valid bit indicates if the corresponding page is in memory.
0 = not in memory
1= in memory
Why is Virtual Memory Important?
The advantage of virtual memory is that it allows a computer to multiplex its CPU and memory between multiple programs without the need to perform expensive copying of the programs' memory images. If the combination of virtual memory system and operating system supports swapping, then the computer may be able to run simultaneously programs whose total size exceeds the available physical memory.
Review
when a memory location is read or written to hardware within the computer translates the memory address generated by the software (the virtual memory address) into a, usually distinct, real memory address
Review
MMU or Memory Management Unit DAT Unit or Dynamic Address Translation
Unit
These are the techniques used to translate a virtual address to a physical address.
Review
Simple Paging
Fixed length blocks
Holds page number
Displacement field
Demand Paging
Holds frame number
Boolean valid bit
1 = in memory
0= not in memory
References
Virtual Memory Tutorial http://cne.gmu.edu/itcore/virtualmemory/vmhistory.html
Virtual Memory Modulehttp://cne.gmu.edu/modules/vm/