The operating system is the software layer that sits between your program and the physical hardware. It plays two fundamental roles: abstraction — hiding the messy details of hardware behind clean, uniform APIs — and multiplexing — safely sharing hardware resources among many programs running simultaneously.
Without an OS, every program would need to know the exact hardware commands for every keyboard model, every disk controller, every network chip ever manufactured. The OS solves that problem once, for everyone.
Grand Analogy: The OS is a government. The kernel is the executive branch. Processes are citizens. System calls are official request forms. Drivers are embassy translators for foreign devices. The file system is the land registry. The scheduler is traffic management. The memory manager is the housing authority.
User Mode vs. Kernel Mode
Modern CPUs enforce two privilege levels in hardware. User mode (Ring 3) is where all application code runs — it cannot directly touch hardware, peek at other processes' memory, or execute privileged CPU instructions. Kernel mode (Ring 0) is where the OS kernel runs — it has unrestricted access to everything.
This boundary isn't a software convention. The CPU physically refuses to execute privileged instructions from Ring 3 code.
Analogy: User mode is being a regular citizen. You can't walk into the power plant and flip switches. You submit a request (a system call) to the government (the kernel), which does it on your behalf — safely.
System Calls
When your program needs something privileged — reading a file, sending network data, allocating memory — it issues a system call (syscall). A syscall is a controlled, hardware-mediated jump from user mode into the kernel. The kernel performs the work, then returns the result and switches back to user mode.
This is the fundamental security boundary of computing. A buggy or malicious application cannot corrupt the kernel or another process's memory because the hardware prevents it. The only path through is a controlled syscall.