Operating Systems18 min readBeginner

What an Operating System Actually Does

The four jobs of an OS: manage processes, memory, files, and devices.

What an OS is, in one sentence

An operating system is a program that sits between your applications and the hardware, mediating access to CPU, memory, disk, and network. Without it, every program would have to know how to talk to the disk controller, the network card, the keyboard, and arrange not to step on every other program's memory. With it, programs ignore those concerns and the OS provides a clean abstraction.

🏢
Real-life analogy — The OS is the building's facilities team
The hardware is the building (electricity, water, elevators). The applications are the tenants. The OS is facilities — it gives every tenant the illusion of unlimited utilities, schedules the elevators fairly, and stops one tenant from eavesdropping on another's wiring.

The four core responsibilities

  • Process management — start, schedule, suspend, kill processes; let them communicate.
  • Memory management — give each process its own address space; share memory safely; swap to disk when RAM is tight.
  • File systems — present a hierarchical name space (/home/ada/notes.txt) on top of raw disk blocks.
  • Device drivers — uniform read/write interface for keyboards, screens, network cards, USB devices.

Kernel mode vs user mode

Modern CPUs run in (at least) two privilege levels. KERNEL MODE can do anything: talk to hardware, modify any memory. USER MODE is restricted — your programs run here. When a user-mode program needs something only the kernel can do (open a file, send a network packet), it makes a SYSTEM CALL — a controlled jump into kernel mode.

# Every line below triggers a system call under the hood
f = open("/etc/hostname")   # open()
data = f.read()              # read()
print(data)                  # write() to stdout
f.close()                    # close()
💡 Tip
On Linux, run `strace python myscript.py` to see every system call your program makes. The first time you do this, you'll be surprised how many.