The Operating System
Table of Contents
- The Manager of Everything
- The Four Big Jobs
- The Kernel
- Drivers
- User Mode and Kernel Mode
- System Calls: Asking the OS for Help
- What Happens When You Turn It On
- Windows, macOS, and Linux
- Try It Yourself
1. The Manager of Everything
Right now your computer is running dozens — probably hundreds — of programs at once: a browser, a music app, a chat app, background updaters, and many you've never heard of. They all need the same CPU, the same RAM, the same disk, and the same screen.
Without someone in charge, it would be chaos: two programs writing to the same part of RAM, one app hogging the CPU forever, any program reading any other program's passwords.
The operating system (OS) is the one in charge. It is the layer of software between the hardware and every application (remember the layers diagram from chapter 1). Its job is to manage the hardware and share it safely and fairly between programs.
2. The Four Big Jobs
Most of what an operating system does falls into four areas:
| Job | What the OS does | Covered in |
|---|---|---|
| Process management | Starts and stops programs, and decides which one gets the CPU at each moment | Chapters 7–8 |
| Memory management | Gives each program its own area of RAM and stops them from touching each other's | Chapters 4, 7 |
| File management | Runs the file system and enforces permissions | Chapter 5 |
| Device management | Talks to keyboards, screens, disks, network cards, and everything else | This chapter and chapter 9 |
On top of that, most operating systems come with a user interface — the desktop, windows, and taskbar on a laptop, or the home screen on a phone — and a set of built-in apps. But those are the visible parts; the real work happens underneath.
3. The Kernel
The core of the operating system is called the kernel. It's the first part of the OS to load when the computer starts, and it stays in memory the whole time the computer is on.
The kernel is the only software allowed to control the hardware directly. Everything else — including parts of the OS you can see, like the desktop or the file manager — is a regular program that has to ask the kernel for what it needs.
Each major OS has its own kernel:
- Windows — the Windows NT kernel
- macOS and iOS — XNU
- Linux distributions (Ubuntu, Debian, Fedora…) and Android — the Linux kernel
That last point surprises people: every Android phone runs the Linux kernel. So does nearly every cloud server — and every Docker container on your machine shares a Linux kernel too.
4. Drivers
There are thousands of different printers, graphics cards, Wi-Fi chips, and webcams, and each one is controlled differently. The kernel can't know about all of them in advance.
A driver is a small piece of software that teaches the operating system how to talk to one particular device. The graphics card manufacturer writes the graphics driver; the printer company writes the printer driver.
This is what makes the layered design work. An app says "print this page"; the OS passes the request to whatever printer driver is installed; the driver speaks that printer's specific language. The app never needs to know which printer you own.
When a device "isn't working" after you plug it in, the missing piece is often the driver.
5. User Mode and Kernel Mode
The CPU itself helps the OS stay in charge. It can run in two modes:
- Kernel mode — full access to all memory and all hardware. Only the kernel runs like this.
- User mode — restricted. Programs can use their own memory and do calculations, but they cannot touch hardware or other programs' memory directly.
Every app you run — your browser, your editor, your own code — runs in user mode. If a user-mode program tries to do something forbidden, the CPU stops it and hands control to the kernel, which usually ends the program. That's why one app crashing almost never takes down the whole computer.
When something does crash in kernel mode — often a buggy driver — there's nothing above it to catch the problem. That's the famous Windows "blue screen", or a "kernel panic" on macOS and Linux.
6. System Calls: Asking the OS for Help
If apps can't touch the hardware, how does anything get done? How does your text editor save a file, or your browser open a network connection?
They ask the kernel through a system call (or syscall) — a formal request to the operating system. There are system calls for things like:
- open, read, and write a file
- start a new program, or exit
- allocate more memory
- open a network connection and send or receive data
So when your JavaScript code does this:
fs.readFileSync("notes.txt");
Node.js turns it into system calls: open the file, read its bytes, close it. The kernel checks your permissions, gets the file system and disk driver to fetch the data, copies it into your program's memory, and returns control to your code. You wrote one line; the OS did a lot of careful work on your behalf.
Every useful thing a program does — printing text, saving a file, talking to the network — goes through a system call eventually.
7. What Happens When You Turn It On
Starting a computer is called booting (from "pulling yourself up by your bootstraps" — the computer has to load the software that loads the software). In simplified form:
- Power on. The CPU starts running a small program stored in a chip on the motherboard, called the firmware (UEFI, or BIOS on older machines).
- Hardware check. The firmware checks the basics — is there RAM, is there a disk — and finds a drive to boot from.
- Bootloader. The firmware loads a small program from the disk called the bootloader, whose only job is to find and load the operating system.
- Kernel starts. The bootloader loads the kernel into RAM and hands over control. The kernel sets up memory management, loads drivers, and mounts the file system.
- First process. The kernel starts the very first user-mode
program (on Linux, usually
systemd), which then starts all the background services. - Login. Finally, the login screen appears, and after you sign in, your desktop and startup apps load.
All of this usually takes just a few seconds on a modern SSD — a hard drive made this much slower, which is why upgrading an old laptop to an SSD makes such a big difference.
8. Windows, macOS, and Linux
The three desktop operating systems you'll meet as a developer:
| Windows | macOS | Linux | |
|---|---|---|---|
| Made by | Microsoft | Apple | Open source community (many distributions, like Ubuntu) |
| Runs on | Most PCs | Apple computers only | Almost anything |
| Common for | Everyday users, gaming, businesses | Developers, designers | Servers, developers, cloud |
| Cost | Paid license (usually bundled) | Bundled with a Mac | Free |
macOS and Linux share a common ancestry in Unix, so they behave very similarly in the terminal — the same commands, forward-slash paths, and permission model. Windows is different, but tools like WSL (Windows Subsystem for Linux) let you run a real Linux environment inside Windows.
Why this matters for you: most servers run Linux. Even if you develop on Windows or macOS, the code you deploy will very likely end up running on the Linux kernel — directly, or inside a Docker container.
9. Try It Yourself
- Find your OS name and version:
- Windows: Settings → System → About
- macOS: Apple menu → About This Mac
- Linux: run
uname -ain a terminal — the output includes the kernel version
- See your drivers:
- Windows: right-click the Start button → Device Manager. Expand a few categories — each device listed has a driver.
- macOS: Apple menu → About This Mac → More Info → System Report.
- Time your next boot from pressing the power button to seeing the login screen. Now you know the six steps happening in those seconds.
The operating system runs programs — but what exactly is a running program? That's the next chapter.
Buy Me a Coffee
Found this tutorial helpful? Consider buying me a coffee to support more free content!