Operating Systems

An operating system's entire job is to take the single CPU, single pool of DRAM, and single disk described in the previous topic and share them safely across every program running at once, without those programs ever having to coordinate with each other directly. A process is one running program — the terminal shell from the working-with-a-computer topic launches a new process every time a command runs — and the OS gives each process its own private memory, including its own stack and heap from the memory-and-execution topic, so one process can never accidentally read or overwrite another's data. A thread is a lighter-weight unit of execution living inside a process: multiple threads in the same process share that process's memory directly, which makes communicating between them cheap but also means a bug in one thread can corrupt data another thread depends on, a tradeoff processes avoid entirely by staying isolated. Scheduling is how the OS decides which process or thread actually gets the CPU at any given instant, since there are usually far more of them than there are CPU cores: the scheduler rapidly switches between them, giving each a small time slice, which is what makes dozens of programs look like they are all running simultaneously on hardware that is really only executing one instruction stream per core at a time. Virtual memory extends that same illusion to memory itself: every process is given what looks like its own complete, private address space starting at address zero, while the OS's memory manager silently translates those virtual addresses into real physical DRAM locations behind the scenes using a structure called a page table — and when physical DRAM runs short, the OS can even swap a rarely used page out to disk, trading the memory hierarchy's slowest tier for extra breathing room. A filesystem organizes the disk itself into the files and directories this series already introduced, keeping track of which physical disk blocks belong to which file so that path lookups and reads resolve correctly. None of this — process isolation, scheduling, virtual memory, filesystem access — is something a regular program is allowed to do directly; instead it makes a system call, a tightly controlled request that hands control briefly to the OS kernel, which performs the privileged operation on the program's behalf and hands control back, the exact gateway every `ls`, `read()`, or `malloc()` ultimately passes through. This whole layer of isolation and resource-sharing is what the next topic, computer networks, will extend outward from one machine to many, using many of these same ideas — addressing, controlled access, and shared resources — at a much larger scale.

A program needs a resource it doesn't control directly
CPU time, memory, a file, a device
Process / threads
isolated memory vs. shared memory within a process
Scheduling
OS time-slices the CPU across everything waiting
Virtual memory
private address space, translated to real DRAM by a page table
Filesystem
tracks which disk blocks belong to which file
Every request funnels through a system call
the kernel performs the privileged operation and hands control back
Virtual Memory: Every Process Thinks It's Alone The page table translates the illusion into real addresses Process A virtual address space starts at 0, looks private stack + heap live here, same as before, isolated Process B also starts at 0, also looks private cannot see or touch Process A's memory Page table (per process) Real physical DRAM — the actual memory chip When DRAM runs short a rarely used page gets swapped out to disk trading the slowest memory-hierarchy tier for extra room
A System Call Is the Only Door In A regular program never touches hardware directly Your program calls read() to open a file system call OS kernel checks permissions, touches the filesystem Disk actual hardware control returns to your program with the result a process vs. a thread is the same tradeoff as objects vs. functions: isolated memory is safer, shared memory is cheaper to communicate through the scheduler decides which process or thread gets the CPU next, over and over

Take operating systems further

Ask the copilot about this term, or have our engineers assess it against your process.