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.

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 RAM 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 private address space, looks like the only one stack and heap live here, same addresses as before Process B also looks like the only one running cannot see or touch Process A's memory Page table (per process) Real physical RAM, the actual memory chip When RAM 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 asks to read a file system call OS kernel checks permissions, touches the filesystem Disk actual hardware control returns to your program with the result even typing ls into a terminal, covered early in this series, is a process making exactly this kind of request 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.