ECE344 Fall 2026 (Sec 1) Lec 9 - Virtual Memory
Watch on YouTube →
Overview
Jon Eyolfson explains how virtual memory gives each process an isolated address space while the CPU’s memory management unit (MMU) translates virtual addresses into physical RAM addresses. He moves from variable-sized segmentation to fixed 4,096-byte pages, explains RISC-V Sv39 address fields and page-table entries, and works through address-translation examples before connecting per-process page tables to fork and copy-on-write.
Key takeaways
- Virtual memory provides process isolation because the kernel gives each process its own mappings, preventing unrestricted access to other processes’ physical memory.
- The MMU performs address translation and permission checks on every instruction fetch, load, and store; the kernel configures the mappings but hardware applies them.
- With 4 KiB pages, the lowest 12 address bits are the within-page offset and stay the same; translation replaces only the virtual page number with a physical page number.
- RISC-V Sv39 provides 39-bit virtual addresses and 27-bit VPNs with 4 KiB pages, so a simple flat page table would require 2^27 entries per process.
- A page fault is the hardware event for an invalid mapping or forbidden access; an unhandled fault can result in Linux delivering SIGSEGV.
- Copy-on-write makes fork more efficient by allowing processes to share physical pages until one attempts to modify a shared page.
Chapters
- Each process uses its own virtual memory, so separate processes can use the same virtual addresses without referring to the same RAM.
- The kernel determines what a process’s virtual addresses mean; user processes do not see the resulting physical addresses.
- A direct virtual-to-physical mapping for every byte would require excessive mapping metadata.
- Virtual memory prevents one process from freely reading or writing another process’s memory; explicitly shared mappings can support interprocess communication.
- The MMU translates addresses for every instruction fetch, load, and store, and checks permissions such as read, write, and execute.
- The kernel configures the MMU because privileged kernel-mode instructions control its mappings.
- A 64-bit address space has up to 2^64 byte addresses, making a separate 8-byte translation entry for every byte impractical.
- Segmentation divides a process’s virtual address space into regions such as code, data, heap, and stack, each with permissions.
- A segment-table entry contains a physical base address, a size limit, and access permissions.
- The MMU checks the segment limit and permissions, then adds the virtual offset to the base to form a physical address.
- Each process needs its own segment table, allowing identical virtual addresses in different processes to map to separate physical locations.
- Growing a contiguous segment may require moving it or finding a larger contiguous region, while shrinking one can leave unusable fragments.
- Modern operating systems instead map equal-sized virtual-memory pages to physical-memory frames, which can be placed anywhere in RAM.
- Legacy x86 segmentation remains in hardware, but Linux effectively disables its address translation by using a zero base and a maximum limit.
- A common page size is 4,096 bytes (4 KiB), or 2^12 bytes; a virtual-memory chunk is a page and its physical-memory counterpart is a frame.
- The kernel chooses page-to-frame mappings, while the MMU applies those mappings and enforces permissions.
- A virtual object can span multiple contiguous virtual pages even when those pages map to noncontiguous physical frames.
- Two virtual pages may map to one physical frame when the operating system explicitly permits memory sharing.
- RISC-V Sv39 uses 39-bit virtual addresses, giving each process a virtual address space of up to 512 GiB.
- With 4 KiB pages, the lowest 12 address bits are the page offset; the remaining 27 bits identify the virtual page number (VPN).
- The offset remains unchanged during translation, while the VPN indexes a page table to retrieve a physical page number (PPN).
- A flat Sv39 page table would need 2^27 entries; increasing virtual-address width quickly multiplies page-table size.
- RISC-V page-table entries are 64 bits (8 bytes) and include a PPN plus validity and access-control information.
- A clear valid bit means no mapping exists; read, write, execute, and user-access bits determine whether an access is allowed.
- The MMU raises a page fault for an invalid mapping or forbidden access; the kernel may handle it or deliver SIGSEGV to the process.
- Linux tools such as getconf PAGE_SIZE and /proc/self/maps can reveal page size and page-aligned process mappings.
- With 4 KiB pages, the final three hexadecimal digits represent the 12-bit offset and remain unchanged.
- For virtual address 0AB0, VPN 0 maps to physical page 1, producing physical address 1AB0.
- For virtual address 1FA0, VPN 1 maps to physical page 4, producing physical address 4FA0.
- In the example system, an 8-bit virtual address and 64-byte pages yield a 6-bit offset and a 2-bit VPN.
- Two VPN bits allow 4 virtual pages; a 10-bit physical address leaves 4 PPN bits, allowing 16 physical frames.
- A page table has one entry per virtual page, so this example’s table contains 4 entries.
- For address F1, split the binary value into VPN 11 (page 3) and offset 110001; with page-table entry 3 equal to 8, the physical address is 0x231.
- Each process has its own page table, and a privileged MMU register points to the page table currently in use.
- After fork, parent and child can use the same virtual addresses while their page tables determine their physical mappings.
- Copying every page immediately would be costly, so copy-on-write lets parent and child share pages until a write requires a copy.
- The lecture previews implementing copy-on-write as part of Lab 3.
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Jon Eyolfson.