The operating system and the program
Lesson 3 of 4
3The operating system and the program
You now have a processor, memory and a disk. But who decides which program gets the processor right now? And who stops a game from reading your passwords? That is the operating system.
Map of this part
The concepts in order, click any one to jump to it:
Two ways into the same idea
An operating system is like a hotel manager. The guests are programs, the rooms are memory, and the lift is the processor. The manager gives each guest a room and keeps them out of other rooms, and schedules the lift so nobody hogs it. A program never talks to the hardware directly; it asks the manager.
The kernel schedules processes on the CPU, gives each process its own isolated virtual memory, and offers system calls for files and the network. A process is a running program with a PID. Linux is an open-source kernel behind most servers and Android devices.
Before You Start
🧮The processor and memory lesson
You know the processor runs one instruction at a time and that memory forgets.
📱Using a phone or computer
You have opened many apps at once and watched one of them freeze. All of that is here.
The Core Idea
1Why we need a go-between
If every program could touch the disk and memory directly, one bad program could ruin everyone else's files. So a go-between was put in place, the kernel, the heart of the operating system.
Follow the picture: the program does not read the disk. It asks the kernel to read, and the kernel checks its right and then does it. That request is called a system call.
The direct path is blocked by the hardware itself, not by agreement. That is why an old virus could take down the whole machine, while today it is confined to one program.
2A process: a program while it runs
A file on disk is a program. When it is copied into memory and the processor starts running it, it becomes a process. One program can run as three processes, like three browser windows.
Follow the picture: one processor and three processes. Each gets a slice of time, a few thousandths of a second, then the next. The speed makes the turn-taking look simultaneous.
The kernel remembers where each process got to and gives it private memory the others cannot see. When an app "freezes", its process has stopped responding, and the kernel can end it without bringing the rest down.
3What Linux is and why it is everywhere
Linux is a kernel. It was written in 1991 and released as open source, so any company could build its own system on top. An Android phone has a Linux kernel, and so do most internet servers.
What you see on screen is not the kernel but programs above it: a desktop, an editor, a browser. On servers there is no screen at all, so you talk to the kernel through text commands. That is why you learn the shell in the Engineer Toolkit track.
The rule to take away: every program lives above the kernel, and the kernel lives above the hardware. Everything you learn after this lesson sits in one of those two layers.
How It Works, Step by Step: What happens when you click a program's icon
The desktop asks the kernel to create a new process.
The kernel copies the program from disk into memory and gives it its own private space.
It places the process in the processor's queue, where it takes time slices alongside the other processes.
Whenever the process needs a file, the network or the screen, it asks the kernel through a system call, and the kernel checks and carries it out.
Try it without code
Myth vs Reality
| Myth | Reality |
|---|---|
| The operating system is the interface I see. | The interface is a program above the kernel. The kernel is what shares the processor and protects memory, and it runs even without a screen. |
| Linux is for experts only. | Linux is the kernel inside your phone, your TV and your router. What looks hard is the text commands, and those you learn step by step. |
| Programs really all run at the same time. | They take turns on the processor very quickly. Multi-core processors do run a few processes together, but the rest wait their turn. |
Try it yourself
Your browser froze but the music keeps playing. What explains that?
Each program is an independent process with its own memory and its own turn on the processor. One process hanging does not stop the kernel from sharing time with the rest, which is why you can end the browser alone.
Quick review cards
Check Your Understanding
Why can you end a frozen app without restarting the machine?
Because it is an isolated process with its own memory, and the kernel can end it and free its resources without touching the rest.
What stops a game from reading your password file?
Every read goes through a system call, and the kernel checks the process's permission before carrying it out.
If your machine has four cores, how many processes truly run at the same instant?
Four at most; the remaining dozens take turns on them in time slices.
Resources for this lesson
Grouped by type. Start with the official docs for precision, or an article or video for the explanation.
Done with this lesson?
Sign in to save your progress.