Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / Operating Systems

    What an Operating System Is

    The hotel manager plus staff is the operating system (OS): the software that manages the

    Chapter 1 of 125 min read

    Start With the Problem#

    Right now on your laptop, these are all "running at the same time":

    • StudyBuddy, with your notes open

    • Chrome, with 30 tabs

    • Spotify, playing music

    • a Zoom call

    • dozens of invisible helper programs

    Your CPU has maybe 8 cores (How Computers Work Ch 5). There are hundreds of programs. So:

    1. Who decides which program gets a core, and for how long?

    2. What stops a buggy (or evil) program from reading StudyBuddy's memory — your notes, your passwords?

    3. Every program thinks it can use memory address 0x1000. How can they all use the same address without overwriting each other?

    4. When StudyBuddy saves a file, how does it talk to the SSD? Does every app need to know how every brand of SSD works?

    5. When two parts of StudyBuddy update your quiz score at the same moment, why does the score sometimes come out wrong?

    Without an answer to these, a computer could only safely run one program at a time — which is how the very first computers worked. The software that answers all five is the operating system.

    The Plain Picture#

    Think of a big hotel.

    • The guests are the programs. Each wants a room, food, laundry, phone calls.

    • Guests are not allowed into the kitchen, the electrical room or other guests' rooms.

    • If a guest wants something, they call the front desk. The front desk decides whether to allow it, and staff do the actual work.

    • The hotel manager decides who gets which room, handles fights over the one gym, and throws out guests who break the rules.

    Without the manager, guests would walk into each other's rooms, fight over the lifts, and nobody would know how to operate the boiler.

    The Real Name#

    • The hotel manager plus staff is the operating system (OS): the software that manages the hardware and shares it between programs.

    • The protected core of the OS — the part with keys to every room — is the kernel. It is the first thing loaded when the computer starts, and it stays in memory until shutdown.

    • Everything else — your apps, and even many OS tools — runs in user space: the guest area.

    The main operating systems you'll meet:

    OSWhere you meet itKernel
    Linuxalmost every server, every cloud machine, Docker containers, AndroidLinux kernel
    macOSyour laptopXNU (a Unix-family kernel)
    Windowsmany desktopsWindows NT kernel

    macOS and Linux are both Unix-like: they follow the same design ideas and share most commands. That's why what you learn on your Mac terminal carries over to servers (The Linux Command Line).

    Under the Hood#

    The OS has five big jobs. The rest of this file is one chapter (or more) per job:

      ┌────────────────────────── OPERATING SYSTEM ──────────────────────────┐
      │                                                                      │
      │  1. CPU        share the cores between programs      → Ch 3, 4, 7   │
      │  2. MEMORY     give each program private memory      → Ch 5, 6      │
      │  3. STORAGE    turn a raw disk into files/folders    → Ch 10        │
      │  4. DEVICES    keyboard, screen, network, SSD        → Ch 2, 11     │
      │  5. SAFETY     stop programs harming each other      → Ch 2, 5      │
      │                                                                      │
      └──────────────────────────────────────────────────────────────────────┘

    Drivers: every brand of SSD, Wi-Fi chip or graphics card works differently. A device driver is a piece of kernel code that knows how to talk to one kind of device. Programs never talk to hardware directly; they ask the kernel, and the kernel uses the right driver. That's how StudyBuddy can save to any SSD without knowing its brand (question 4 from Part 0).

    Check yourself

    3 questions
    1

    What is the kernel?

    Show answer

    The protected core of the operating system that controls the hardware and stays loaded all the time.

    2

    What is user space?

    Show answer

    The area where normal programs run, without direct access to hardware or other programs' memory.

    3

    Why don't apps need to know which brand of SSD you have?

    Show answer

    They ask the kernel to read/write; the kernel uses a device driver that knows that SSD.