Computing Foundations › Inside the Machine › Day 6

Day 6: Operating Systems: What They Do and Why

Day 6 of 365 — Operating Systems: What They Do and Why

After this lesson you will be able to explain what an operating system does — kernel vs user space, system calls, processes, virtual memory, filesystems, drivers, and permissions — and use that model to explain why AI and server work runs on Linux and to interrogate your own OS from the terminal.

Course
Computing Foundations
Category
Inside the Machine
Reading time
≈ 40 min
Practical time
≈ 30 min
Lesson duration
1h 10m
Last verified
2026-07-12

Hands-on lab for this lesson

Lab files on GitHub: https://github.com/ai-roadmap-365/ai-roadmap-365.github.io/tree/main/labs/sections/computing-foundations/day-006-operating-systems-what-they-do-and

  1. Get the hands-on files. Clone the labs repository once (you can reuse this clone for every lesson). This works on macOS, Linux, and Windows (PowerShell or WSL):
    git clone https://github.com/ai-roadmap-365/ai-roadmap-365.github.io.git
    cd ai-roadmap-365.github.io
  2. Open this lesson's lab. Move into the directory for this specific day. Every lab lives at the same predictable path — section / subsection / week / day:
    cd labs/sections/computing-foundations/day-006-operating-systems-what-they-do-and
  3. Read the lab guide. Open `README.md` in that directory. It lists the exact commands, what each does, the expected output, and how to check your work — read it before running anything.
  4. Run it and check your work. Follow the README's "How to run" section: run the example first to see the finished result, then complete the numbered exercises in `starter/`, then run the tests. The tests pass (exit 0) only when your work is correct.
    bash tests/run_tests.sh   # or the test command named in the lab README

You can also open the lab as a local page (works offline, shows the file tree and expected output).

Learning objectives

By the end of this lesson you will be able to:

Prerequisites

Why this matters


The idea in plain language

Diagram: running on bare hardware compared with running under an operating system

Bare hardware is nearly unusable. The CPU from Day 2 will fetch, decode and execute forever, but it has no idea what a file is and no opinion about who owns the bytes it just wrote.

The operating system plays three roles at once:

To do that safely it splits the machine in two:


Historical background

Timeline: the Unix and Windows family tree from 1969 to today


What it is — and what it is not

Diagram: what runs in user space compared with what only the kernel may do

It is:

It is not:


Why it was created and what problems it solves

Diagram: the five jobs an operating system does and the problem each solves


How it works

Kernel space and user space

Diagram: applications in user space crossing the system-call boundary into the kernel and hardware

System calls: the only door

Diagram: the steps a file-open system call takes through the kernel

Virtual memory, revisited


An everyday analogy

Diagram: the stages of memory pressure on an operating system

Think of a hotel.

The hotelThe operating system
GuestsPrograms
RoomsPrivate address spaces
The front deskThe system-call interface
Staff-only doorsKernel mode
Room keysPermissions
Housekeeping rotaThe scheduler

Examples in practice

Diagram: the boot sequence from firmware to the first user-space process


Implications: security, privacy, performance, scalability, and cost

Diagram: reading a file one byte at a time compared with reading it in blocks


Alternatives: free, open source, and commercial

OptionTypeWhere you meet it
Linux (Ubuntu, Debian)Free, open sourceEssentially every cloud and GPU machine
macOSCommercial, BSD-derivedYour laptop; a good Unix development environment
Windows + WSL2Commercial + freeWindows machines running a real Linux kernel in a VM
FreeBSDFree, open sourceNetwork appliances, storage systems
Container runtimesFree, open sourceSharing one kernel among many isolated workloads

Diagram: the Linux kernel compared with a Linux distribution

TermWhat it actually is
KernelThe privileged core: scheduler, memory, drivers, syscalls
Operating systemThe kernel plus the userland people bundle with it
DistributionAn OS packaged with an installer and update policy
ShellAn ordinary user-space program that runs other programs
FirmwareCode on the hardware itself, running before any OS exists

When to use it — and when not to


The AI connection

Diagram: a virtual machine compared with a container


Knowledge check

quiz:
  question: "A container running a GPU workload starts fine but reports no devices, while the same image works on another host. What is the most likely explanation?"
  options:
    - "The host is missing the GPU kernel driver, which the container shares rather than supplies"
    - "The container image was built for the wrong CPU architecture"
    - "The container was given too little memory to initialise the GPU"
    - "Containers cannot access GPUs and a virtual machine is required"
  answer_index: 0
  explanation: "A container shares the host's running kernel. Drivers are kernel components, so the driver must be present on the host; the image supplies only the user-space runtime that talks to it."

Hands-on exercise

Observe the boundary rather than read about it. Worked through fully in the Day 6 lab directory.

What you are looking atCommand
Which kernel is runninguname -a
The distribution around itcat /etc/os-release (Linux) or sw_vers (macOS)
Every system call a program makesstrace ls (Linux) or sudo dtruss ls (macOS)
Memory pressure and swappingvmstat 1 5 or vm_stat
A permission check failingtouch /etc/nope

Expected output

Linux hostname 6.8.0-40-generic x86_64 GNU/Linux
openat(AT_FDCWD, "data.csv", O_RDONLY) = 3
touch: cannot touch '/etc/nope': Permission denied

Validate your work

Troubleshooting

Common mistakes


Practice assignment


Extension challenge


Quiz

Q1. What is the fundamental difference between kernel space and user space?

  1. Kernel space is stored on disk while user space lives in RAM
  2. Kernel space runs privileged; user space must ask via system calls
  3. Kernel space is for system administrators and user space is for ordinary user accounts
  4. Kernel space runs faster because it uses a separate, faster processor
Show answer

Answer: B. Kernel space runs privileged; user space must ask via system calls

The split is enforced by the CPU's hardware privilege modes: kernel-mode code may execute any instruction and access any memory, while user-mode programs are confined to their own memory and must cross the system-call boundary for anything more.

Q2. What is a system call?

  1. A phone-home request an operating system makes to its vendor
  2. Any function call between two functions in the same program
  3. How a user-space program requests a service from the kernel
  4. A message one application sends to another application
Show answer

Answer: C. How a user-space program requests a service from the kernel

A system call is the single doorway between user space and the kernel: the program executes a special instruction that switches the CPU into kernel mode at a kernel-chosen entry point, where the request is checked and serviced.

Q3. When a program successfully opens a file, what does the operating system actually hand back to it?

  1. The physical disk address where the file's data begins
  2. A complete copy of the file loaded into the kernel's memory
  3. Direct read/write access to the disk hardware for that file
  4. A file descriptor — a small integer used as a ticket for later calls
Show answer

Answer: D. A file descriptor — a small integer used as a ticket for later calls

The kernel keeps all the real bookkeeping and hardware access to itself; the program receives only a file descriptor — a number it hands back across the system-call boundary on every subsequent read or write.

Q4. Which statement about the Unix family history is accurate?

  1. Unix began at Bell Labs in 1969; Linux is a from-scratch Unix-like kernel
  2. Linux was created by AT&T in 1983 as the commercial successor to Unix systems
  3. Unix was derived from Windows NT in the early 1990s
  4. macOS abandoned its Unix heritage when Apple bought NeXT in 1996
Show answer

Answer: A. Unix began at Bell Labs in 1969; Linux is a from-scratch Unix-like kernel

Ken Thompson and Dennis Ritchie started Unix at Bell Labs in 1969; the family branched into BSD and System V; and in 1991 Linus Torvalds wrote the Linux kernel independently — Unix-like in design, but new code. macOS, via NeXT and Darwin, genuinely descends from the Unix/BSD line.

Q5. Why does virtually all server and GPU/AI infrastructure run on Linux?

  1. Linux is the only operating system that can run Python programs
  2. It is license-free at any scale, adaptable, scriptable, and remotely run
  3. Linux is the only operating system with a graphical desktop
  4. Laws in most countries require datacenter servers to run open-source software
Show answer

Answer: B. It is license-free at any scale, adaptable, scriptable, and remotely run

Zero per-machine license cost across huge fleets, an open kernel that cloud and GPU vendors can modify, end-to-end scriptability, and remote text-based administration made Linux the default for servers, clouds, and GPU clusters — not fashion or legal mandate.

Q6. What is a container, in operating-system terms?

  1. A complete emulated computer running its own separate kernel
  2. A compressed archive format for shipping source code
  3. A kernel-enforced isolated slice of user space sharing the host kernel
  4. A physical case that holds multiple separate servers in a datacenter rack
Show answer

Answer: C. A kernel-enforced isolated slice of user space sharing the host kernel

Containers use kernel features (namespaces and control groups on Linux) to isolate processes while sharing the host kernel — lighter and faster to start than a virtual machine, which emulates a whole machine with its own kernel.

Q7. A script works on your laptop but fails on a server with "Permission denied". Which OS subsystem produced that message, and at what moment?

  1. The compiler, when the script was first written
  2. The CPU cache, when it ran out of room for the script
  3. The bootloader, when the server last restarted
  4. The kernel's permission check, against the file's ownership bits
Show answer

Answer: D. The kernel's permission check, against the file's ownership bits

Permission checks happen inside the kernel during system calls such as open: the caller's user identity is compared against the file's owner and permission bits, and a mismatch returns the error the program reports as "Permission denied".

Q8. What is the relationship between Linux and a Linux distribution such as Ubuntu?

  1. Linux is the kernel; Ubuntu packages it into a complete product
  2. Ubuntu is a rival kernel that competes with Linux
  3. Linux is a graphical desktop that runs on top of Ubuntu
  4. They are the same thing under two names
Show answer

Answer: A. Linux is the kernel; Ubuntu packages it into a complete product

Linux proper is only the kernel. Distributions like Ubuntu, Debian, and Fedora bundle it with user-space tools and policies — which is why cloud providers offer "Ubuntu" images rather than "Linux" ones.

Glossary

operating system
The software layer that manages a computer's hardware and provides common services to programs — a manager of resources, an illusionist providing private-machine fictions, and a guard enforcing protection.
kernel
The privileged core of an operating system, running in a special CPU mode with unrestricted access to memory and devices; it contains the scheduler, memory manager, filesystems, drivers, and security machinery.
user space
The unprivileged world where all ordinary programs run, confined to their own memory and required to request every hardware service from the kernel through system calls.
system call
The controlled doorway through which a user-space program asks the kernel for a service such as opening a file, allocating memory, or sending a network packet.
file descriptor
The small integer the kernel returns when a program opens a file — a ticket the program hands back on every subsequent read or write, while the kernel keeps the real bookkeeping.
device driver
A hardware-specific module, usually loaded into the kernel, that translates one device's particular dialect into the standard interface the rest of the system expects.
filesystem
The OS subsystem that organizes raw disk blocks into named files, folders, timestamps, and permissions — the human-usable fiction layered over storage hardware.
permission
A rule attached to a file or resource stating which users may read, write, or execute it; the kernel checks permissions during system calls, producing "Permission denied" on failure.
virtual memory
The memory-management scheme that gives each process a private, contiguous-looking address space mapped by page tables onto physical RAM, with less-used pages evicted to disk when memory runs short.
process
A program in execution: the running instance of a program file, with its own virtual address space, identity, and entry in the scheduler's ledger.
shell
The user-space program (such as zsh or bash) that reads typed commands and asks the kernel to run them — distinct from both the terminal window and the operating system itself.
Unix
The operating system begun at Bell Labs in 1969 by Ken Thompson and Dennis Ritchie, whose portable C implementation and licensed source code made its design the ancestor or model for macOS, Linux, and most server systems.
Linux distribution
A complete product (Ubuntu, Debian, Fedora, Arch) that packages the Linux kernel with installers, a package manager, default tools, and an update policy.
WSL
The Windows Subsystem for Linux — a Windows feature whose current version runs a real Linux kernel in a lightweight virtual machine, giving Windows users a genuine Linux environment alongside Windows.
container
A kernel-enforced isolated compartment of user space — separate process list, filesystem view, and network stack — that shares the host's kernel, packaged with an application's exact environment so it runs identically anywhere.

Sources and further reading


Kept in this browser, no account needed. Your progress page turns the whole record into one link you can bookmark or open on another device.