Prologue
The Unix operating system is based on a few elegant ideas conceived in the late 1960s. The first version appeared in 1969, originally called UNICS—a pun on the unsuccessful MULTICS project. It was later renamed UNIX, with the first edition of the UNIX Programmer’s Manual released in 1971. Over the next five decades, Unix was refined and extended by generations of elite computer scientists. This organic growth led to the incredible richness and depth, all inherited by today’s Linux.
Modern Linux is a continuation of Unix, shaped by the Open Source development model and profoundly influenced by the rise of the Internet and relentless advances in hardware. It runs on faster, cheaper, and more ubiquitous machines than its creators could have imagined.
At the core of Linux is the kernel—the lowest layer of the system software stack and the component that interfaces directly with the hardware. The kernel is both highly efficient and largely invisible to the untrained eye. While most technically inclined users know that the kernel keeps programs running, this is only part of the story: the kernel creates processes (programs in execution), and those processes exist only within the kernel’s context. Regular programs do not run directly on hardware but on the combination of the kernel and the hardware.
This book explores Linux from the kernel perspective: our goal is to peek under the hood of the Linux kernel to understand its principles. To that end, we sometimes skip over less essential details. For example, while device drivers are important to the kernel, they are only of marginal relevance to users seeking a deeper understanding of how the kernel works. Accordingly, we treat them briefly. A key challenge of writing such a book is that the Linux kernel cannot be learned from theory alone. Practical experience is essential. That’s why a defining feature are exercises—hands-on examples that demonstrate working kernel modules.
Kernel modules allow additional C code to be compiled and inserted into a running kernel, where it becomes part of the kernel itself. This makes them an ideal tool for experimentation—the most exciting way to learn about the kernel. Each exercise is designed to illustrate a specific concept and to give the reader a taste of the fascinating world of kernel programming.