← All lessons
How computers work · Lesson 6 of 7

The operating system

The operating system (OS), such as Windows, macOS, Linux, Android or iOS, is the program that starts first and manages everything else. Apps don't talk to the hardware directly; they ask the OS.

A running program is a process. You might have dozens at once, but a CPU core runs one at a time. The OS's scheduler switches between them many times a second, giving each a short slice of time, so they all seem to run together. Switching from one to another is a context switch: the OS saves one process's registers and loads the next one's.

The OS gives each process its own memory space and stops processes reading or wrecking each other's memory. That's why one app crashing usually doesn't take the others down with it. If RAM runs short, it can move parts of memory that aren't being used out to the drive (virtual memory), which is why a computer with too little RAM slows to a crawl.

It also organises storage into files and folders (the file system), decides who may open what (permissions), and talks to each piece of hardware (printer, keyboard, graphics card) through a driver. A program asks the OS for these services with system calls: "open this file", "send these bytes to the network".

The core of the OS, which runs with full control of the hardware, is the kernel. Apps run with fewer rights, so a buggy or hostile app can't take over the machine.

Practice

What's a process?

More info

Quick reference

Operating systemManages hardware and runs the other programs.
ProcessA running program.
SchedulerShares CPU time between processes.
File systemFiles and folders on a drive.
DriverLets the OS work one device.
KernelThe OS core, with full control.

The other computer science courses