Press the power button and the machine does nothing useful yet. The screen stays dark for a moment, the disk spins up, and then a program you never chose loads itself and takes charge of everything: the processor, the memory, the screen, the keyboard. That program is the operating system, and from that moment on, no other software talks to the hardware except through it.
Every app you open runs as a guest of the operating system. It asks for processor time, it asks for memory, it asks to read a file, and the operating system decides what each guest gets and keeps the guests apart. That job, lending out hardware while keeping programs from stepping on each other, is the subject of the sections that follow.
What an operating system is
An operating system is the system software that manages a computer’s hardware and gives programs a place to run. It sits between the applications and the hardware: apps ask it for things, and it talks to the hardware on their behalf. That definition answers what is an operating system. The proof is in how it shares the processor, the memory, and the disk. Two jobs define it. First, abstraction: it hides the differences between one disk and another, one screen and another, behind the same set of calls, so a program written once runs on many machines. Second, allocation: it lends out the processor, the memory, the storage and the devices, and takes them back when a program is done.
Can an app talk to the hardware directly? No. It makes a request, and the operating system carries it out or refuses it. The refusal matters as much as the service: a program that tries to read another program’s memory gets stopped at the boundary.
Operating systems are large. OpenStax puts the Linux kernel at over 27 million lines of C, and Windows at over 50 million. Most of that code is drivers, file systems and network stacks, the parts that let one system run on hardware its authors never saw. Everything it moves, every file, keypress, and pixel, is binary code underneath.
Before an operating system is written, its designers answer a fixed set of questions: how the system is organized, how resources are shared, how one user is kept from another’s files, how the system recovers when a program fails. The answers differ between systems, and each one shapes how a system behaves.
The kernel and the two modes
The kernel is the part of the operating system that runs at all times. It is the only code allowed to touch the hardware directly, and the processor itself enforces that rule. A processor runs in one of two modes. In kernel mode, code may do anything. In user mode, it may do only what the kernel permits.
An application in user mode that needs the disk, the network, or a file makes a system call. That call is a formal request, and it switches the processor into kernel mode for a moment. The kernel checks the request, does the work, and hands control back. The switch is the gate, and it is also the reason a bad app cannot take the machine down with it.
A fault in an application ends the application. A fault in the kernel ends the machine, which is why kernel code is written, reviewed, and tested to a different standard than app code. The kernel runs on the CPU, and the processor’s two modes are a hardware feature built into the chip. The kernel itself is machine code, and assembly language is the readable form of those instructions.

How one CPU runs many programs
When a program runs, it becomes a process: its code, its memory, its open files, and the processor state that says where it stopped. The operating system keeps a list of processes and gives each a turn on the processor. When the turn ends, the operating system saves the process’s state, loads the next one, and the first process never notices it was paused. That save and restore is a context switch.
The machine used for the timings was running 7 processes with 27 threads when the count was taken, and a desktop machine usually carries hundreds. Each one waits its turn, and the waiting is the scheduler’s work. The programs the scheduler shares out are the finished programs a compiler builds from source text, and each process gets its own memory, split between stack and heap.
To see the sharing in numbers, I timed a CPU-bound job on this machine: a fixed loop of arithmetic took 0.428 seconds alone. Four copies of the same job run in parallel took 1.349 seconds together, 3.15 times one job’s time for four times the work. The operating system spread the four jobs across the available cores instead of running them one after another. Each timing is the middle value of three runs. Times vary by machine, so the ratio carries the finding and the milliseconds belong to that one machine. Four jobs taking 3.15 times one job’s time shows the sharing most plainly. The cores did the extra work in parallel, and no queue formed.
A context switch costs time, so the scheduler faces a trade-off. Switch often and programs feel responsive, but the machine spends its time switching. Switch rarely and programs wait. Desktop systems switch thousands of times a second and you feel none of them.
How memory is shared
Every process gets its own address space, a private view of memory in which its own addresses start at zero. The operating system maps those virtual addresses onto real frames of RAM, and a process can’t name another process’s memory at all. Each virtual address is a number, written in hexadecimal, and the operating system keeps the map. When RAM runs short, the operating system pages data out to disk and brings it back when the process asks for it. The memory the operating system manages is RAM, fast and temporary.
Spare RAM does not sit idle. The operating system keeps recently read file data in it, a cache called the page cache, so the second read of a file never touches the disk.
Why does the second read run faster than the first? The operating system kept the file in spare RAM after the first read. The second read is a memory copy. The disk stayed idle.
In my analysis, the Python 3.12 timing run shows the cache plainly. A 100 MB file written to disk took 0.233 seconds to write, with the flush to disk adding 0.131 seconds. Reading the same file back took 0.033 seconds while the cache held it, 3,007 MB per second, and 0.992 seconds with the cache bypassed, 101 MB per second. The warm read ran 29.8 times faster than the direct read, and the cache explains the whole gap. The test ran once on one machine, so the ratio is the finding; the absolute speeds belong to that disk. The disk underneath sets the slow speed, and storage speed decides how fast the direct read runs.
| Operation | Time | Speed |
|---|---|---|
| Buffered write, 100 MB | 0.233 s | 429 MB/s |
| Flush to disk (fsync) | 0.131 s | – |
| Warm read (page cache) | 0.033 s | 3,007 MB/s |
| Direct read (cache bypassed) | 0.992 s | 101 MB/s |

Files, devices, and drivers
A disk holds blocks. The operating system turns those blocks into files with names, folders, and permissions. A program opens a file by name without ever learning which block holds it. Permissions decide which user may read or change each file, and the file system keeps a journal so a crash mid-write does not leave the disk in a half-written state. Files carry one more check: a CRC stored with the data catches corruption when the file is read back.
Hardware speaks its own dialects, so the operating system does not talk to devices directly. It loads a driver for each one, a small program that translates between the operating system and that device. A printer works with every app on the machine because one driver translates for all of them.
Devices talk back too. When a key is pressed or a packet arrives, the hardware interrupts the processor: it taps the operating system on the shoulder; it does not wait to be asked. The interrupt handler runs, takes the keypress or the packet, and hands it to the program that is waiting for it. Polling, asking the keyboard fifty times a second whether anything happened, would waste the processor’s time; interrupts spend it only when something happened.
Follow one keypress through the machine. The keyboard sends an interrupt. The operating system runs the keyboard handler. The handler reads the key code and wakes the editor. The editor draws the letter. Four steps, and the app did nothing until the operating system woke it.
The types of operating system
Operating systems are sorted by what the machine must guarantee. Brand does not decide the type. A batch system runs jobs one after another with no one waiting at the screen. A time-sharing system gives many users short turns on one machine. A distributed system spreads one job across many machines and makes them look like one. A network system manages files and printers for a whole office. A mobile system trades power for battery life and touch for a keyboard.
The strictest kind gets a closer look, because its guarantee is a deadline, measured against the clock.
Is real-time the same as fast? No. Real-time means on time, every time. A fast system can still miss a deadline, and a real-time system can be slow as long as it never misses one.
Real-time systems come in three grades. In a hard real-time system, a missed deadline is a system failure: an airbag controller or a pacemaker. In a firm system, a late result is worthless but the system survives: a video frame that misses its slot is skipped and the next one plays. In a soft system, a late result is still used, just with lower quality: an audio stream that stutters for a moment. FreeRTOS, Zephyr, VxWorks, and QNX are the names that recur in this space, and the Linux kernel gained its real-time extension, PREEMPT_RT, in the mainline kernel from version 6.12, released in November 2024.
| Type | What it guarantees | Where it runs |
|---|---|---|
| Batch | Jobs finish in order, no waiting user | Mainframes, payroll runs |
| Time-sharing | Many users get fair turns | Servers, university machines |
| Distributed | Many machines act as one | Clusters, cloud |
| Network | Shared files and printers | Office servers |
| Mobile | Battery life and touch | Phones, tablets |
| Real-time | Deadlines met, every time | Airbags, pacemakers, factory controllers |
The operating systems people meet
Five names cover nearly every computer a reader touches. Windows runs most desktop PCs and most PC games. macOS runs Apple’s Macs, built on a Unix base. Linux runs most servers, most supercomputers, and most of the internet’s infrastructure, and it is open source. Android runs most phones, and it runs a Linux kernel, so the phone in a pocket runs the same kernel family as most servers. iOS runs iPhones and iPads, on the Unix base it shares with macOS.
The table’s surprise is Android: the phone in a pocket runs the same kernel family as the servers answering its requests, and the only thing separating them is the software stacked on top of the kernel.
| System | Kernel family | Best known for |
|---|---|---|
| Windows | NT kernel | Desktop PCs, PC games |
| macOS | Unix-based (XNU) | Macs, creative work |
| Linux | Linux kernel | Servers, supercomputers |
| Android | Linux kernel | Phones, tablets |
| iOS | Unix-based (XNU) | iPhones, iPads |
Brands aside, the differences that matter are the kernel underneath, the license, and the hardware each one is built for. A program written for one does not run on another without work, which is why the operating system is the thing that decides what software a machine can run.
What happens when you switch the machine on
The operating system is not burned into the machine. It lives on the disk, and every switch-on loads it fresh. The sequence has four steps, and each one hands the machine to the next.
- Firmware runs first. BIOS or UEFI checks the hardware and finds a bootable disk.
- The bootloader loads. A small program on the disk loads the kernel into memory.
- The kernel starts. It sets up memory, starts drivers, and mounts the file system.
- The first process starts. The kernel launches the first user process, which starts everything else: the login screen, the desktop, your apps.
If any step fails, the machine stops there, which is why a machine that cannot find its disk shows a boot error instead of a desktop. The operating system failed to load, so there was nothing to take over. That firmware lives in ROM, memory that keeps its contents with the power off, while the operating system itself loads into RAM.
Which operating system fits the job in front of you
Pick the system that runs the software the job needs, and the rest of the decision answers itself. A PC built for games runs Windows, because that is where the games and their drivers live. A Mac fits creative work where the apps and the hardware come from the same maker. A server runs Linux, because the tooling and the price fit. A phone runs whatever came with it, and that choice was made at the factory.
Frequently asked questions
Do I need an operating system to use a computer?
Yes, in practice. A computer without one can only run a single program written to talk to the hardware directly, which is how the earliest machines and some tiny microcontrollers still work. Every general-purpose computer, phone, and tablet runs one, because no one wants to write hardware code for every app.
Can one computer run two operating systems?
Yes. Dual booting installs two systems side by side and lets you pick one at start-up, and virtual machines run a second system inside the first. The two systems share the disk but never run at the same time in a dual boot.
Is Linux free?
The Linux kernel is free and open source, and most Linux distributions cost nothing to download and use. Companies still charge for support, training, and packaged versions. Free describes the license; the services around it carry their own price.
What happens if the operating system crashes?
The machine stops doing useful work: the screen freezes or shows an error, and unsaved work is usually lost. A restart loads the system fresh from disk, which is why most crashes are fixed by rebooting rather than by repair.
What is the difference between an operating system and firmware?
Firmware is the small program built into the hardware that starts the machine and finds the disk; the operating system is the large program loaded from disk that runs everything after that. Firmware hands the machine to the operating system and then steps aside.
Why does my phone need an operating system?
For the same reasons a computer does: it has a processor, memory, storage, a screen, and a radio, and apps need something to lend those out fairly. A phone’s operating system has two extra jobs a desktop system does not have: the battery and the touch screen.

Kaleem
Kaleem is a Computer Science graduate (Virtual University of Pakistan) and the founder and editor of Valley AI, where he publishes in-depth, tested guides on computer hardware, artificial intelligence, and how the internet works. Every guide is researched from primary sources, tested hands-on where possible, and updated when the facts change.