30
Virtual Memory By Steven LaBarbera

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

Embed Size (px)

Citation preview

Page 1: 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

Virtual Memory

By

Steven LaBarbera

Page 2: 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

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

Page 3: 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

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.

Page 4: 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

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.

Page 5: 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

Why did lack of space have serious implications?

Programmers had to re-code their program every time they switched machines or added more memory.

Page 6: 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

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.

Page 7: 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

The creation of virtual memory

The technique was invented at the University of Manchester for the Atlas Computer, completed in 1962.

Page 8: 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

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

Page 9: 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

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.

Page 10: 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

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

Page 11: 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

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

Page 12: 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

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

Page 13: 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

Translation from virtual memory to physical memory

Translations are managed by the Memory Management Unit (MMU) .

Page 14: 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

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

Page 15: 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

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

Page 16: 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

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 ).

Page 17: 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

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

Page 18: 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

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 19: 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

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 20: 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

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

Page 21: 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

DAT Unit

In the book the DAT Unit is used to translate virtual addresses to physical addresses.

Dynamic Address Translation Unit

Page 22: 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

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.

Page 23: 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

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.

Page 24: 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

Demand Paging

Each page table contains two parts

1. The frame number

2. A valid bit

Page 25: 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

Valid bit field

The valid bit indicates if the corresponding page is in memory.

0 = not in memory

1= in memory

Page 26: 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

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.

Page 27: 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

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

Page 28: 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

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.

Page 29: 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

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

Page 30: 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

References

Virtual Memory Tutorial http://cne.gmu.edu/itcore/virtualmemory/vmhistory.html

Virtual Memory Modulehttp://cne.gmu.edu/modules/vm/