What an Operating System Does
An operating system is the layer between programs and hardware. It decides who gets the CPU, which memory is valid, and how bytes reach a disk.
In plain English
An operating system is the school principal. It decides who uses the playground, when, and for how long.
By the end you will be able to
- Name the four resources an operating system manages.
- Explain why processes, files, and address spaces are useful abstractions.
- Distinguish kernel code from user programs.
- Describe the OS as both a resource manager and an abstraction layer.
The four resources
The kernel manages four scarce resources: CPU time, physical memory, I/O devices, and persistent storage. CPU time is shared by switching between processes. Memory is divided into protected address spaces. I/O devices are accessed through drivers and interrupts. Storage is exposed as files and directories. Every OS policy you will study is a strategy for allocating one of these resources fairly, efficiently, or predictably.
Abstractions hide the hardware
A process is an abstraction for a running program. A file is an abstraction for persistent bytes. A virtual address is an abstraction for a physical memory location. A system call is an abstraction for a privileged hardware operation. These abstractions let a programmer write portable code without knowing which disk or CPU model is underneath.
/* a program sees a file, not disk sectors */
FILE *fp = fopen("data.txt", "r");
/* the kernel sees blocks, buffers, and a device driver */
/* read(block 42) -> driver -> disk controller -> platter */Kernel and user programs
The kernel is the privileged core that runs in kernel mode. User programs run in user mode with limited access. When a program needs a privileged service, it executes a system call or traps into the kernel. The boundary protects one process from another and protects the hardware from buggy code. The kernel is not the whole OS: the shell, libraries, and utilities are user-level programs built on top of it.
Key takeaways
- The kernel manages CPU, memory, I/O, and storage.
- Processes, files, address spaces, and system calls are abstractions over hardware.
- The kernel runs privileged; user programs run unprivileged.
- The shell and utilities are user-level, not part of the kernel.
Common pitfalls
- Thinking the OS is only the graphical desktop.
- Confusing a process with a program file.
- Assuming every hardware access is a system call; some are handled by drivers inside the kernel.
Kernel notes
- Be able to name the four resources and one policy for each.
- Explain why an abstraction is useful, not just what it is called.
- Know the difference between kernel mode and user mode.
Quick check
1. Which component runs with privileged hardware access?
2. Why is a process considered an abstraction?