Skip to main content
Be Bitwise

The Kernel

OS & The Kernel · Assembly & OS track

3 min read

In this module

The Core of the Operating System

Not every part of the OS sits at the same level. The innermost piece — the one with full access to the hardware — is the kernel. A small bootloader loads it into memory when your computer starts, and it stays resident the whole time the machine is on.

Think of the kernel as the foundation of the entire software stack. Every other piece of the OS, and every application, sits on top of it.

What the Kernel Does

The kernel has a short but vital list of responsibilities:

  • Memory management — tracks which regions of RAM are in use, hands memory out to processes, and reclaims it when they're done
  • Process scheduling — decides which process gets CPU time and for how long, switching between them fast enough that everything looks simultaneous
  • Device I/O — talks to hardware devices through drivers, handling the low-level dance of reading disks, sending packets, and so on
  • System call handling — exposes the interface user programs call when they need the kernel to do something on their behalf
Always Running

The kernel is always in memory once the system boots. It runs at the highest privilege level the CPU offers, meaning it can execute any instruction and reach any memory address. That's what lets it manage everything else on the system.

Monolithic vs. Microkernel

Two major design philosophies have fought it out for decades:

A monolithic kernel lumps everything — file systems, device drivers, networking, memory management — into one large blob of code running in kernel space. Linux is the classic example, with loadable modules bolted on. The win is speed: everything shares an address space, so components talk to each other cheaply.

A microkernel flips that. It keeps only the bare essentials in kernel space (scheduling, basic memory management, inter-process communication) and runs everything else — drivers, file systems, networking — as separate user-space processes. Stability and security go up: a crashing driver doesn't take down the kernel with it. The cost is extra overhead from all the inter-component messaging.

Follow a single read() through each design and the difference shows up as the number of times control crosses the user/kernel line. In a monolithic kernel the file system and driver are ordinary function calls inside the kernel. In a microkernel they're separate processes, and every hop between them is a message the kernel has to deliver.

The replies travel back the same way, so the microkernel version pays for several extra trips through the kernel per request. Modern microkernels like seL4 have made each trip very cheap, which is why the debate never quite ended.

Most mainstream kernels sit somewhere in between. Windows and macOS are usually called hybrid kernels: they borrow a microkernel's internal structure, but run the file systems, drivers and most services in kernel mode for speed. Flip through the tabs below, then turn on side-by-side to compare the three.

Kernel architecture

Lx

Linux: monolithic, with loadable modules

One large kernel image. File systems, the network stack and nearly all drivers run in kernel mode and share one address space. Modules can be loaded at runtime, but once loaded they're just more kernel code.

DesignMonolithic
Drivers run inKernel mode (loadable modules)
File systems run inKernel mode (FUSE allows user-space ones)
Internal communicationDirect function calls
Buggy driver crashesUsually the whole kernel (a panic or oops)

Why It Matters

Knowing the kernel helps you see why some operations are fast and others aren't, why a bad driver can take down the whole system, and why the boundary between kernel code and user code gets guarded so carefully. That boundary is what we'll dig into next.