How Operating Systems Work: Kernel, Memory, and Processes
A comprehensive guide to how operating systems manage hardware, memory, and processes through the kernel and system calls.
What Is an Operating System?
An operating system (OS) is the foundational software that manages a computer's hardware resources and provides services to application programs. Operating systems serve as an intermediary layer between physical hardware components — such as the CPU, RAM, and storage drives — and the software applications that users run. Without an operating system, each application would need to directly control hardware, making computing impractical. Major operating systems include Microsoft Windows, macOS, Linux, Android, and iOS.
The Kernel: Core of Every OS
The kernel is the central component of an operating system that operates with the highest level of privilege. It runs continuously in memory and handles the most critical tasks: managing hardware access, scheduling processes, and enforcing security boundaries. The kernel communicates with hardware through device drivers and exposes services to user applications through a defined interface called the system call API.
Kernel Types
- Monolithic kernel: All OS services run in kernel space. Linux and traditional Unix use this model. It offers high performance but reduced fault isolation.
- Microkernel: Only the most essential services (IPC, basic scheduling) run in kernel space. macOS (XNU) and MINIX use microkernels for greater modularity.
- Hybrid kernel: Combines elements of monolithic and microkernels. Windows NT uses a hybrid kernel that balances performance and modularity.
- Exokernel: Minimal kernel that exposes hardware directly to applications; used primarily in research systems.
| Kernel Type | Example OS | Services in Kernel Space | Performance |
|---|---|---|---|
| Monolithic | Linux | All (drivers, FS, networking) | High |
| Microkernel | MINIX 3 | IPC, scheduling only | Moderate |
| Hybrid | Windows NT | Core + select services | High |
| Exokernel | ExOS (research) | Hardware multiplexing only | Very High |
Process Management
A process is an instance of a running program. The OS kernel creates, schedules, and terminates processes, ensuring that each receives a fair share of CPU time without interfering with others. Each process has its own memory address space, file descriptors, and execution state.
Process States
A process moves through several states during its lifetime:
- New: The process is being created and resources are being allocated.
- Ready: The process is loaded into memory and waiting for CPU time.
- Running: The CPU is actively executing the process's instructions.
- Waiting (Blocked): The process is paused, awaiting an event such as I/O completion.
- Terminated: The process has finished execution and its resources are being released.
CPU Scheduling
The OS scheduler determines which process runs at any given moment. Common scheduling algorithms include First-Come, First-Served (FCFS), Round Robin (each process gets a fixed time slice), Shortest Job Next (SJN), and Multilevel Queue Scheduling used in modern systems. Linux uses the Completely Fair Scheduler (CFS), which allocates CPU time proportionally based on process priority weights.
Memory Management
Memory management is one of the most complex responsibilities of an operating system. The OS must allocate RAM to processes, protect each process's memory from unauthorized access, and handle situations where physical memory is exhausted.
Virtual Memory
Virtual memory allows each process to operate as if it has access to a contiguous block of memory larger than physical RAM. The OS and CPU's Memory Management Unit (MMU) translate virtual addresses to physical addresses using a data structure called a page table. When a required page is not in RAM, a page fault occurs and the OS loads the page from disk (swap space).
| Memory Concept | Description | Typical Size (x86-64) |
|---|---|---|
| Virtual Address Space | Per-process logical memory map | 128 TB (user space) |
| Page | Fixed-size unit of virtual memory | 4 KB (default) |
| Page Frame | Fixed-size unit of physical memory | 4 KB |
| TLB (Translation Lookaside Buffer) | Cache for page table lookups | 64–4096 entries |
| Swap Space | Disk area used as overflow memory | 1–16 GB (typical) |
File Systems and I/O
The OS provides a uniform interface for reading and writing data through file systems. A file system organizes data on storage devices into hierarchical directories and files. Common file systems include NTFS (Windows), ext4 (Linux), and APFS (Apple). The OS handles I/O requests through device drivers and maintains buffers to reduce the performance gap between fast CPUs and slower storage hardware.
System Calls and User Space
Applications running in user space cannot directly access hardware or kernel data structures. Instead, they invoke system calls — a controlled interface to kernel services. Common system call categories include process control (fork, exec, exit), file management (open, read, write), and communication (socket, send). The transition from user mode to kernel mode is called a context switch, which carries a small but measurable performance cost.
Security and Protection
Modern operating systems enforce security through multiple mechanisms. Privilege rings (or protection rings) in x86 hardware restrict which instructions are available to code running at each level — the kernel runs in Ring 0 (most privileged), while user applications run in Ring 3. Access control lists (ACLs) and permission bits control which users can read, write, or execute files. Technologies such as Address Space Layout Randomization (ASLR) and Data Execution Prevention (DEP) mitigate common exploit techniques.
Related Articles
artificial intelligence
How Large Language Models Work: Architecture, Training, and Applications
A comprehensive guide to how large language models (LLMs) function — from transformer architecture and tokenization to training at scale and real-world applications.
8 min read
artificial intelligence
How the Internet Works: Protocols, Infrastructure, and the Journey of a Web Request
A clear, comprehensive explanation of how the internet works — from IP addresses and DNS to TCP/IP protocols, data packets, and what actually happens when you load a webpage.
8 min read
artificial intelligence
History of Artificial Intelligence: From Turing to the Age of ChatGPT
A comprehensive timeline of AI history — from the theoretical foundations and the Turing test, through the AI winters, to the deep learning revolution and the emergence of large language models.
8 min read
artificial intelligence
How Recommendation Algorithms Work: The Technology Behind Your Feed
An in-depth look at recommendation systems — how platforms like Netflix, YouTube, Spotify, and Amazon use collaborative filtering, content-based filtering, and deep learning to predict what you want next.
8 min read