21
Virtual Memory By: Dinouje Fahih

Virtual Memory

Embed Size (px)

DESCRIPTION

Virtual Memory. By: Dinouje Fahih. Definition of Virtual Memory. - PowerPoint PPT Presentation

Citation preview

Page 1: Virtual Memory

Virtual Memory

By: Dinouje Fahih

Page 2: Virtual Memory

Definition of Virtual Definition of Virtual MemoryMemory

Virtual memory is a concept that, allows a computer and its operating system, to use a very large range of memory or storage addresses for stored data. The computing system maps the programmer's virtual addresses to real hardware storage addresses (Hard Disks).

In addition to managing the mapping of virtual storage addresses to real storage addresses, a computer implementing virtual memory or storage also manages storage swapping between active storage (RAM) and hard disk or other high volume storage devices

Page 3: Virtual Memory

All modern general-purpose computer All modern general-purpose computer operating systems use virtual memory operating systems use virtual memory techniques for ordinary applications, techniques for ordinary applications, such as word processors, spreadsheets, such as word processors, spreadsheets, multimedia players, accounting, etc multimedia players, accounting, etc

Older operating systems, such as DOS of Older operating systems, such as DOS of the 1980s, or many mainframe operating the 1980s, or many mainframe operating systems of the 1960s, had no virtual systems of the 1960s, had no virtual memory functionality.memory functionality.

Embedded Systems and other special-Embedded Systems and other special-purpose computer systems which require purpose computer systems which require very fast, very consistent response time very fast, very consistent response time do not generally use virtual memory.do not generally use virtual memory.

Page 4: Virtual Memory

Computer Memory HierarchyComputer Memory Hierarchy

Page 5: Virtual Memory

Virtual Memory Usage.Virtual Memory Usage.

Memory Memory ExtensionExtension

Memory Memory ProtectionProtection

Page 6: Virtual Memory

How Does it Work?How Does it Work?

Memory Management UnitMemory Management Unit ((MMUMMU)) Hardware component responsible for Hardware component responsible for handling accesses to memory handling accesses to memory requested by the (CPU). One of Its requested by the (CPU). One of Its functions include translation of functions include translation of virtual addresses to physical virtual addresses to physical addresses (Virtual Memory addresses (Virtual Memory management), management),

Page 7: Virtual Memory

► Virtual Memory provides Virtual Memory provides expansion of expansion of Main Main MemoryMemory by ‘overflowing’ by ‘overflowing’ data and program code data and program code onto onto Magnetic DiskMagnetic Disk..

► The area on disk The area on disk

reserved for this purpose reserved for this purpose is known as the is known as the Swap Swap SpaceSpace

► Dividing main memory Dividing main memory into into Frames (pages)Frames (pages)

Page 8: Virtual Memory

PagesPagesThe RAM physical memory subdivided The RAM physical memory subdivided into into 4kb-64kb pages. 512MB/4K = 131072 4kb-64kb pages. 512MB/4K = 131072 pgpg

Page TablePage Table provides a look up whereby the logical provides a look up whereby the logical page number can be exchanged for the page number can be exchanged for the physical frame number. physical frame number.

It is an Array of (PTE).It is an Array of (PTE).

Page 9: Virtual Memory

ProcessProcess When programs are using the CPU at When programs are using the CPU at

the same time, each running program the same time, each running program and the data structures needed to and the data structures needed to manage it.manage it.

AddressesAddresses AA Load InstructionLoad Instruction A Store InstructionA Store Instruction Fetching an InstructionFetching an Instruction

Page 10: Virtual Memory
Page 11: Virtual Memory

Maximum Virtual Address space:Maximum Virtual Address space: Size of a program address is determined by the maximum Size of a program address is determined by the maximum

size of the virtual address space. The number of bits in a size of the virtual address space. The number of bits in a virtual address is the virtual address is the log base 2log base 2 of this value. of this value.

Maximum Physical Address space:Maximum Physical Address space: The amount of real memory that the system can support The amount of real memory that the system can support determined the number of bits needed to address the determined the number of bits needed to address the physical memory. The size of physical address is physical memory. The size of physical address is log base 2log base 2 of this value.of this value.

Size of a PageSize of a Page::This is the size of a virtual memory page and a physical This is the size of a virtual memory page and a physical memory memory frame. It is always a frame. It is always a power of 2power of 2

Virtual Memory Address TranslationVirtual Memory Address Translation

Page 12: Virtual Memory

Page number and page Page number and page offsetoffset

A virtual address is therefore split into two parts. A virtual address is therefore split into two parts. The more significant part gives the page number. The more significant part gives the page number. The less significant part gives the address of the The less significant part gives the address of the byte within the page. The less significant part is byte within the page. The less significant part is also called the “page offset.”also called the “page offset.”

The number of bits allocated to the page offset The number of bits allocated to the page offset should be able to address every byte in the page. should be able to address every byte in the page. Therefore, in our example. Since we have 4 KB = Therefore, in our example. Since we have 4 KB = 221212 byte page tables, we need 12 bits for page byte page tables, we need 12 bits for page offset.offset.

Likewise for the physical address.Likewise for the physical address.

Page 13: Virtual Memory

13 bits13 bits 10 bits10 bits

page numberpage number offsetoffset

16MB Maximum Virtual Address space (24 bits)16MB Maximum Virtual Address space (24 bits)

8MB Maximum Physical Address space (23 bits) 8MB Maximum Physical Address space (23 bits)

1024byte Page size (10 bits) 1024byte Page size (10 bits)

Virtual Address can be represented as: Virtual Address can be represented as:

Page 14: Virtual Memory

Page FaultPage Fault The memory manager locates the missing page The memory manager locates the missing page

in secondary memory. in secondary memory.

The page is loaded into primary memory, The page is loaded into primary memory, usually causing another page to be unloaded.usually causing another page to be unloaded.

The page table in the memory manager is The page table in the memory manager is

adjusted to reflect the new state of the memory. adjusted to reflect the new state of the memory.

The processor re-executes the instructions The processor re-executes the instructions which caused the page fault. which caused the page fault.

Page 15: Virtual Memory

Translation Look-aside Translation Look-aside BufferBuffer

The TLB tends to be fully associative. The TLB uses write-back.

Therefore, needs a dirty bit to indicate if the page is dirty Or have a Read or Write Permission bit

This is because a TLB miss is very costly, and is to be avoided.

Page 16: Virtual Memory
Page 17: Virtual Memory

MEMORY PERFORMANCE COMPARISON

Page 18: Virtual Memory

How to Access the Virtual Memory in your Computer?How to Access the Virtual Memory in your Computer?

1

Page 19: Virtual Memory

2 3

Page 20: Virtual Memory

4

RAMRAM Virtual Virtual Mem.Mem.

1GB1GB 1536MB 1536MB 2048MB2048MB

2GB2GB 3072MB3072MB

4096MB4096MB

3GB3GB 4644MB4644MB

6144MB6144MB

Page 21: Virtual Memory

Conclusion!

Questions??