Level 0 · Module 2

Memory

Understand how an operating system gives processes protected virtual memory.

Difficulty
beginner
Time
10 min read
Prerequisites
File systems
Reading progress0% read

Not completed

By the end, you can

  • Distinguish virtual addresses from physical RAM locations.
  • Explain process memory isolation and address translation.
  • Describe paging and the cost of moving inactive data to storage.

Summary

The OS gives each process a virtual address space and maps its used pages to physical memory. This abstraction protects processes and lets memory be managed flexibly.

Introduction

Two processes can both use an address such as 0x1000 without referring to the same RAM location. The OS and CPU translate each process’s virtual addresses.

Explanation

Memory is divided into fixed-size pages for management. A process uses virtual addresses; page tables map those addresses to physical RAM or record that a page is not currently present. If a needed page is absent, the OS handles a page fault and may load it from storage. Moving pages to slower storage can keep programs running under pressure, but heavy paging makes the system slow.

Real-world example

Two editors, same virtual address

Editor A and Editor B may each store text at virtual address 0x1000. Their separate page tables map that address to different physical memory, preserving isolation.

Translate an address

address-translation.txttext
process A: virtual page 1 → physical frame 8
process B: virtual page 1 → physical frame 21

same virtual address, different physical memory

Code example

page-fault.txttext
CPU requests virtual page 4
page table says: not present
OS loads page 4 from storage into RAM
OS updates mapping; instruction continues

Common mistakes

  • Assuming a virtual address is a raw physical RAM position.
  • Believing a page fault always means a program error.
  • Expecting storage-backed paging to be as fast as RAM.

Quiz

Knowledge check

Why can two isolated processes use the same virtual address safely?

Try it

Diagnose memory pressure

Explain why a computer with many open apps may become slow when it starts moving pages repeatedly between RAM and storage.

Key takeaways

  • Processes operate in protected virtual address spaces.
  • Page tables translate virtual pages to physical memory.
  • Page faults can be normal, but frequent storage-backed paging is costly.
View module overview