Virtual memory: Difference between revisions
No edit summary |
No edit summary |
||
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 | |||
= 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. |
Revision as of 01:57, 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
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.