Memory Protection with Virtual Memory
You'll learn: How operating systems use virtual memory's page table entries to control which memory each process can access and prevent programs from interfering with each other.
Core Idea
Every entry in a page table doesn't just store the mapping from virtual to physical addresses—it also contains permission bits that specify what operations are allowed on that page. Think of these like file permissions, but for memory: read, write, and execute.
When the MMU translates an address, it checks these permission bits. If a process tries to write to a read-only page, or execute code from a non-executable page, the hardware triggers a protection fault and the OS terminates the offending process.
How It Works
Each page table entry typically includes:
- Read bit: Can the process read from this page?
- Write bit: Can the process write to this page?
- Execute bit: Can the CPU treat bytes here as instructions?
- User/Supervisor bit: Is this accessible from user mode?
Process isolation comes naturally: Process A's page table simply doesn't contain entries mapping to Process B's physical frames. Even if Process A tries every possible virtual address, the MMU won't translate any to Process B's memory—the page table entries either don't exist or point to completely different physical frames.
Real-World Analogy
Imagine an apartment building where each tenant gets a personalized directory. Your directory only lists your rooms with keys labeled "can enter," "can rearrange furniture," or "no access." You physically cannot access another tenant's rooms because they're not even in your directory.
Key Takeaway: Virtual memory protection uses permission bits in page table entries to enforce read/write/execute restrictions and process-specific page tables to ensure complete isolation between processes.