There is a lot of parallels between this and Cache design. However, their differing historical roots have led to the use of different terminology.
- Allow efficient and safe sharing of memory among several programs, such as for the memory needed by multiple virtual machines for Cloud computing (main reason today)
- Allow a single-user program to exceed the size of primary memory.
- Basically gives you more memory, or at least some illusion of it
- page = A virtual memory block
- So basically instead of calling these Blocks, we call them pages, but they are the same thing
- page fault = virtual memory miss, i.e. trying to access a page not present in the main memory
- This is handled by the Operating System
With virtual memory, the processor produces a virtual address, which is translated by a combination of hardware and software to a physical address, which in turn can be used to access main memory. This process is called address mapping/translation, where we use a Page Table.
The virtual memory address is broken into two parts:
- Virtual Page Number (VPN)
- Page Offset (PO)
The physical memory address is also broken into two parts:
- Physical Page Number (PPN)
- Page Offset (PO)
The page offset is determined by the page size - 4KB page size = 4096B = bytes -> 12 bits for page offset
The illusion of larger amount of virtual memory is created by having a larger number of virtual pages than physical pages.
The Page Table contains the address translations in a virtual memory system.
- Typically stored in memory
- Typically indexed by the virtual page number
- each entry in the table contains the physical page number for that virtual page if the page is currently in memory.
Each program has it’s own page table.
Because the page
Example 1: Assume a physical address size of 28 bits, virtual address size of 32 bits, and page size is 1KB (or 1024B).
- page size of , so page offset = 10 bits.
- VPN = 32 - 10 = 22 bits
- PPN = 28 - 10 = 18 bits