Memory management and file systems
The OS gives each process its own private view of memory and organises storage into files and folders that people and programs can find.
Virtual memory
With virtual memory, each process sees its own address space, as if it had the whole memory to itself. The OS and hardware's memory management unit (MMU) translate virtual addresses to physical addresses. This isolates processes, so one cannot read or corrupt another's memory, and lets the system use more memory than is physically present.
Paging
Memory is divided into fixed-size blocks called pages, often 4 kilobytes. A page table maps each virtual page to a physical frame. Pages not recently used can be moved to disk (swapped or paged out). If a program touches a page that is on disk, a page fault occurs and the OS loads it back, which is slow.
Thrashing
If running programs need more memory than is available, the system may spend most of its time moving pages between memory and disk instead of doing useful work. This is thrashing; the computer becomes extremely slow. Closing programs or adding RAM fixes it.
Files and directories
A file system organises storage into named files grouped in directories (folders) arranged as a tree. Each file has metadata: name, size, timestamps, owner, and permissions. Paths name files, such as C:\Users\Ana\notes.txt on Windows or /home/ana/notes.txt on Linux and macOS.
File system types
Different operating systems use different file systems: NTFS on Windows, APFS on macOS, and ext4 on many Linux systems, with FAT32 and exFAT common on USB drives for compatibility. Modern file systems use journaling, recording intended changes before making them, so they can recover cleanly after a crash or power cut.
Permissions
The OS controls who can read, write, or execute each file. Unix-like systems assign permissions to the owner, the group, and others, shown as strings such as rwxr-xr--. Windows uses access control lists. Permissions, together with separate user accounts, prevent one user or program from damaging others' files.
Virtual machines and containers
A virtual machine runs a complete guest operating system on virtualised hardware managed by a hypervisor, letting one physical server host many isolated systems. Containers, such as those run by Docker, share the host's kernel but isolate applications and their dependencies, making them lighter and faster to start. Both are foundations of cloud computing.
Worked example
A system uses 4-kilobyte pages. A program uses 2 megabytes of memory: 2,048 kilobytes / 4 = 512 pages. The page table records where each of those 512 pages lives in physical memory, or that it is on disk. If the program's working set of active pages fits in RAM, it runs smoothly; if not, frequent page faults slow it down.
Key takeaways
Virtual memory gives each process a private address space, translated by the MMU, which isolates processes. Paging divides memory into pages mapped by page tables; page faults load pages from disk. Too little memory causes thrashing. File systems organise files in directory trees with metadata; NTFS, APFS, and ext4 are common, and journaling aids recovery. Permissions protect files. Virtual machines and containers isolate workloads and underpin the cloud.
Flashcard
Private address space for each process
Check your understanding
What is the main benefit of giving each process its own virtual address space?
