Abstract
Virtual memory abstracts away the majority of the complexity incorporated with physical memory to make what appears to be a large, flat main memory
Key Benefits
Process Isolation
- Impossible to modify another process’ memory if unable to address that memory directly
- Accessing invalid or uninitialized pointers may cause segmentation faults but it doesn’t impact the entire system, only the currently executed program.
Code Relocation
- Binary object files are loaded at the same virtual address, making it straightforward for linking and loading tools
- Ensures locality in the virtual address which minimizes problems with memory fragmentation
Hardware Abstraction
- The virtual address space provides a uniform and hardware-independent view of the memory, despite physical memory resources changing when more RAM is installed or a hosted VM configuration is modified
Virtual Address Space Layout
- Assuming each memory location addresses 1 byte. A 32bit processor will address bytes of memory. This is more commonly known as 4GB of Virtual Address Space
- Linux Virtual Space layouts use (user-space) 3:1 (kernel-space), or 2:2 for 4GB address spaces.
- Raspberry Pi Linux Kernel’s 32bit config specifies 2:2
Diagram:

Allocating memory
- Stack frame (descending stack) - each new call
- Within heap -
mallocornew - Grow the heap –
brk/sbrk - Map new region into memory -
mmap
Memory Access
CPU Mediated: Non Uniform Memory Access
Non-CPU mediated:
Direct memory access (DMA)
Copies data between devices and memory buffers
Remote dynamic memory access (RDMA)
Enables pages to be transferred rapidly between nodes in LAN Copies memory from a remote buffer to a local buffer
- Used in cloud,e.g. VM migration, distributed storage services