Winter Semester 2026–27 · VIT-AP · BACSE106 · Operating Systems · Dr. Krithika L.B

Session 1.2: Operating-system structure

How millions of lines of kernel code are organised: monolithic, layered, microkernel and modular designs — and the hybrids real systems actually use.

Module 1 1.5 hours Theory CO1
← Before
1.1 OS basics & history
What the OS manages
You are here
1.2 Operating-system structure
Module 1 · Operating Systems and Structure
Next →
1.3 Services & system calls
How programs ask the kernel

Learning objectives

By the end of this session you should be able to:

  • Explain why OS structure is a trade-off between performance and isolation/maintainability.
  • Describe monolithic, layered, microkernel and modular structures with one real example each.
  • Explain how loadable kernel modules work and inspect them on a Linux system.
  • Compare the four structures on communication, performance, fault isolation and extensibility.
  • Classify Linux, Windows, macOS and Android as hybrid systems and justify the classification.

Lecture notes

1. Why structure matters

The Linux kernel has more than 30 million lines of code. A system that large and that critical has to be engineered so that it can be understood, debugged, extended and kept fast. The usual approach is to split the work into components with clear interfaces — but where the boundaries are drawn, and whether crossing them is cheap or expensive, defines four classic structures: monolithic, layered, microkernel and modular.

Two forces in tension

Performance wants everything in one address space with plain function calls. Reliability, security and maintainability want components isolated so that a bug in one cannot corrupt another. Every structure below is a different compromise.

2. Monolithic structure

The simplest structure is no structure at all: put all kernel functionality — scheduling, memory management, file systems, network stack, device drivers — into a single static binary that runs in one address space in kernel mode. Early MS-DOS was an extreme case: no separation even between applications and the kernel, so one bad program could crash the whole machine.

Traditional UNIX is monolithic but layered into two parts: the kernel and the system programs. Everything below the system-call interface and above the hardware is the kernel. Linux follows the same model (with loadable modules, see §5).

Monolithic kernel: one large kernel with every service inside, entered through the system-call interface.
Monolithic kernel: one large kernel with every service inside, entered through the system-call interface.
Advantages
  • Very fast — a service is a function call away; little overhead in the system-call path.
  • Simple to build initially.
Disadvantages
  • A bug in any driver can crash the entire system.
  • Hard to understand, maintain and extend as it grows.
  • Tightly coupled: a change in one part can break another.

3. Layered approach

A layered OS is broken into a number of levels. Layer 0 is the hardware; the highest layer (layer N) is the user interface. Each layer is an abstract object made of data and operations, and a layer may use only the services of the layers below it. Dijkstra's THE system (1968) was the first well-known example.

Layered OS: each layer hides the details of the layers beneath it.
Layered OS: each layer hides the details of the layers beneath it.

Why it is attractive: construction and debugging are simple. Debug layer 1 using only the hardware; once it is correct, debug layer 2 assuming layer 1 works, and so on. If an error appears in layer k, it must be in layer k, because everything below was already verified.

Why pure layering is rare today:

  • Defining the layers is hard. The disk driver (for swapping) needs the CPU scheduler to block while waiting, but the scheduler may need to swap a process out — which layer goes below which?
  • Performance. A request may pass through several layers, each adding parameter copying and call overhead.

Modern systems keep the idea (well-defined interfaces, information hiding) without strict one-way layering. The network stack (TCP/IP layers) is still a good example of layering inside a kernel.

4. Microkernel

In the mid-1980s, Carnegie Mellon's Mach kernel took the opposite direction from monolithic designs: move everything that is not essential out of the kernel and into user-level programs. What remains in the microkernel is minimal: basic process and memory management and, above all, inter-process communication (message passing).

Microkernel: file systems, drivers and other services run as user-level servers and talk through kernel message passing.
Microkernel: file systems, drivers and other services run as user-level servers and talk through kernel message passing.

A client asking the file server to read a file

Application→ send message→ Microkernel→ File server→ Microkernel→ Application

The client and the server never call each other directly — every request and reply crosses the kernel.

Advantages
  • Reliability: a crashing driver or file server is just a user process — restart it.
  • Security: less code runs with full privilege.
  • Extensibility & portability: add a service without touching the kernel; small kernel is easier to port.
Disadvantages
  • Performance: every service request costs messages and extra mode/context switches.
  • Windows NT 4.0 moved graphics back into the kernel for exactly this reason.
Examples

Mach, QNX (cars, medical devices), L4 family, MINIX 3, seL4 (formally verified).

5. Modular structure — loadable kernel modules

Probably the best current methodology is the modular kernel. The kernel has a set of core components and links in additional services through loadable kernel modules (LKMs), either at boot time or while the system is running. A new file system, a USB device driver or a firewall rule engine can be added without rebuilding or rebooting the kernel.

  • Like a layered system, each module has a defined, protected interface.
  • But it is more flexible: any module may call any other module.
  • Like a microkernel, the core is small and knows how to load and talk to modules.
  • But it is more efficient: modules run inside the kernel, so no message passing is needed.

Linux, Solaris, macOS and Windows all use modules. On any Linux machine you can see them:

Terminal — exploring kernel modules (try this in Lab 1)
$ uname -r                 # which kernel is running?
6.5.0-35-generic
$ lsmod | head -5          # modules currently loaded
Module                  Size  Used by
nls_iso8859_1          12288  1
snd_hda_codec_hdmi     94208  1
snd_sof_pci_intel_tgl  12288  0
ext4                 1069056  2
$ modinfo ext4 | head -3   # details of one module
filename:       /lib/modules/6.5.0-35-generic/kernel/fs/ext4/ext4.ko
license:        GPL
description:    Fourth Extended Filesystem
$ sudo modprobe loop       # load a module (and its dependencies)
$ sudo rmmod loop          # unload it again

A kernel module is just C code with an entry and exit function. You do not need to write one in this course, but seeing it makes the idea concrete:

hello_mod.c — a minimal Linux kernel module (illustration)
#include <linux/module.h>
#include <linux/kernel.h>

MODULE_LICENSE("GPL");

static int __init hello_init(void)
{
    printk(KERN_INFO "hello_mod: loaded into the kernel\n");
    return 0;               /* 0 = success, module stays loaded */
}

static void __exit hello_exit(void)
{
    printk(KERN_INFO "hello_mod: removed from the kernel\n");
}

module_init(hello_init);    /* called by insmod / modprobe */
module_exit(hello_exit);    /* called by rmmod            */

6. Hybrid systems

Real operating systems rarely follow one pure model; they combine structures to balance performance, security and usability.

Linux

Monolithic (one address space, for speed) + modular (LKMs for drivers and file systems).

Windows

Largely monolithic for performance, but keeps microkernel ideas: separate subsystems ("personalities") run as user-mode processes; supports loadable drivers.

macOS / iOS (Darwin)

Mach microkernel and BSD UNIX kernel combined in one kernel address space (XNU), plus dynamically loadable kernel extensions.

Android

Modified Linux kernel at the bottom; hardware abstraction layer (HAL), native libraries and the ART runtime above it.

7. Comparing the four structures

MonolithicLayeredMicrokernelModular
Core ideaAll services in one kernelHierarchy; each layer uses only lower layersMinimal kernel; services as user processesSmall core + loadable modules
CommunicationFunction callsCalls to the layer belowMessage passing via kernelFunction calls through module interfaces
PerformanceHighestLower (layer crossings)Lowest (messages, switches)High
Fault isolationPoorModerateBestPoor–moderate (modules run in kernel mode)
ExtensibilityRebuild kernelHard (fixed layers)Add user-level serversLoad module at run time
ExamplesTraditional UNIX, MS-DOSTHE, MULTICS (rings)Mach, QNX, MINIX 3, L4Linux, Solaris
Scenario — a buggy USB driver dereferences a NULL pointer
  • Monolithic / modular: the driver runs in kernel mode → kernel panic (Linux) or blue screen (Windows); the whole machine goes down.
  • Microkernel: the driver is a user process → it is killed and restarted; other programs keep running.
  • Layered: the fault is easy to localise to the driver's layer, but it still runs privileged unless that layer is outside the kernel.

VideoBytes

Monolithic and layered structures

Video coming soon

Monolithic and layered structures

Recorded by Dr. Krithika L.B. Slot m1-monolithic-layered

Microkernel, modular and hybrid kernels

Video coming soon

Microkernel, modular and hybrid kernels

Recorded by Dr. Krithika L.B. Slot m1-microkernel-modular

Interactive lessons

Work through these in order after the lecture — each one expands a part of the notes with diagrams, hover notes and a quick check.

Lab connection

Check your understanding

Answer each question in your own words first, then reveal the model answer.

Revealed 0
Why is debugging easier in a layered OS?

Layers are verified bottom-up. When layer k is being tested, layers 0 … k−1 are already known to be correct, so any new error must be inside layer k.

Give one reason pure layering is difficult to implement.

Circular dependencies: the backing-store (swap) driver needs the scheduler to block while waiting for I/O, yet the scheduler may need the backing store to swap processes. Neither can be strictly below the other.

Why is a microkernel usually slower than a monolithic kernel?

A service request becomes messages: application → kernel → server → kernel → application. Each hop involves mode switches, possibly context switches and copying, whereas a monolithic kernel simply calls a function.

How is a modular kernel similar to, and different from, a microkernel?

Similar: a small core with services added separately. Different: modules run in kernel mode in the same address space and call each other directly, so there is no message-passing overhead — but also no fault isolation.

Is Linux monolithic or modular?

Both: it is a monolithic kernel (all core services in one address space) that also supports loadable kernel modules, so it is usually described as a modular monolithic or hybrid design.

Key takeaways

  • Monolithic: fastest, least isolated. Layered: easiest to verify, hard to define. Microkernel: most isolated, message-passing overhead.
  • Modular kernels combine a small core with run-time loadable modules — the dominant approach today.
  • Real systems are hybrids: Linux (monolithic + modules), Windows, macOS/iOS (Mach + BSD), Android (Linux + runtime).
  • Whatever the structure, user programs enter the kernel through the same narrow door: the system-call interface.

Where this leads

Regardless of how the kernel is organised inside, applications only see it through the services it offers and the system calls that request them. Next we open that door.

Continue to 1.3 — OS services and system calls →