Operating Systems
An operating system's entire job is to take the single CPU and single pool of RAM from computer architecture 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 covered early in this series 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 already covered in memory and program execution, 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. Scheduling is how the OS decides which process or thread actually gets the CPU at any given instant, rapidly switching between them using the exact fetch-decode-execute cycle covered in computer architecture, 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, while the OS silently translates those addresses into real physical RAM locations behind the scenes using a structure called a page table, reusing the exact addresses and pointers already covered in memory and program execution — and when physical RAM 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 into the files and directories already covered early in this series, 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 file listing or memory request ultimately passes through, including the very `ls` or `cd` commands typed into a terminal early in this series. 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.