Virtual memory: Difference between revisions
No edit summary |
No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Virtual memory gives the illusion of a bigger memory. Each programs use the same virtual addresses. | Virtual memory gives the illusion of a bigger memory by making memory acts as a cache for hard disk storage. | ||
= Functionality = | |||
Each programs use the same set virtual addresses. That is, two programs can have the same virtual addresses. | |||
The entire address space will be stored on hard drive, but a subset would be in main memory. The CPU translates the virtual addresses into DRAM addresses, and if the address you're looking for is not there, it is fetched from the hard drive. | |||
= Compare to cache = | |||
A lot of concepts here are the same as in [[cache]]s: | |||
* Block == Page | |||
* Miss == Page fault | |||
* Tag == Virtual page number | |||
= Page table = | |||
Page tables are used to translate virtual address into physical address. It is usually stored in physical memory due to its size. This means that a virtual memory access normally requires 2 main memory accesses: translation and access. | |||
== Translation lookaside buffer == | |||
The TLB is a small cache that stores the most recent translations to reduce the number of memory accesses. Because page accesses have high temporal locality, where consecutive loads and stores are likely to access the same page due to the page size being large, TLB is fully associative. | |||
= Memory protection = | |||
A good thing about virtual memory is that because each program has their own virtual address table, memory protection can be easily enforced, where a malicious program cannot corrupt the memory of another program. | |||
= Archived notes = | |||
Physical memory acts as a cache for virtual memory. A '''page table''' can be used to translate virtual to physical address. | Physical memory acts as a cache for virtual memory. A '''page table''' can be used to translate virtual to physical address. | ||
Line 5: | Line 27: | ||
Most accesses hits physical memory, but some doesn't. | Most accesses hits physical memory, but some doesn't. | ||
A '''translation lookaside buffer''' is a small cache of recent translations that reduces memory accesses. | A '''translation lookaside buffer (TLB)''' is a small cache of recent translations that reduces memory accesses. Page tables are high temporal locality so fully associative. | ||
Each process has a page tables that only maps to one section of physical address. The OS prevents accesses from one process to another. When processes switch, we either store a process id or to just flush the page tables. | |||
[[Category:Computer Architecture]] | [[Category:Computer Architecture]] |
Latest revision as of 02:02, 7 June 2024
Virtual memory gives the illusion of a bigger memory by making memory acts as a cache for hard disk storage.
Functionality
Each programs use the same set virtual addresses. That is, two programs can have the same virtual addresses.
The entire address space will be stored on hard drive, but a subset would be in main memory. The CPU translates the virtual addresses into DRAM addresses, and if the address you're looking for is not there, it is fetched from the hard drive.
Compare to cache
A lot of concepts here are the same as in caches:
- Block == Page
- Miss == Page fault
- Tag == Virtual page number
Page table
Page tables are used to translate virtual address into physical address. It is usually stored in physical memory due to its size. This means that a virtual memory access normally requires 2 main memory accesses: translation and access.
Translation lookaside buffer
The TLB is a small cache that stores the most recent translations to reduce the number of memory accesses. Because page accesses have high temporal locality, where consecutive loads and stores are likely to access the same page due to the page size being large, TLB is fully associative.
Memory protection
A good thing about virtual memory is that because each program has their own virtual address table, memory protection can be easily enforced, where a malicious program cannot corrupt the memory of another program.
Archived notes
Physical memory acts as a cache for virtual memory. A page table can be used to translate virtual to physical address.
Most accesses hits physical memory, but some doesn't.
A translation lookaside buffer (TLB) is a small cache of recent translations that reduces memory accesses. Page tables are high temporal locality so fully associative.
Each process has a page tables that only maps to one section of physical address. The OS prevents accesses from one process to another. When processes switch, we either store a process id or to just flush the page tables.