Linux Security
Linux Security
Linux Security

Book Review: Linux Kernel Programming

Date 04 Apr 2011
Posted By Dave Wreski
As Linux is implemented on increasingly wider number of devices, the number of people responsible for developing and maintaining Linux on those platforms have increased. As the level of maturity of the kernel increases, so does the complexity, capabilities, and size. This book provides the Linux programmer the tools necessary to understand the core aspects of the kernel and how to interface with it.

Title: Review: Linux Kernel Development, Third Edition
Author: Robert Love
ISBN: ISBN-13: 978-0-672-32946-3
Reviewer: Dave Wreski <This email address is being protected from spambots. You need JavaScript enabled to view it.>
Review Score: 5 of 5 Penguins
Publisher: Prentice Hall Professional
Verified By: Doug Ledford
Sample Chapter: Chapter Two: Getting Started with the Linux Kernel

Written by seasoned kernel programmer and one of the architects of the Linux implementation for Google Android, Robert Love details every aspect of the current version of the Linux kernel, and helps the reader not only understand how it works, but also provides the programmer with the foundation to modify and adapt it as necessary.

The kernel is the key piece of software of an operating system that controls every other piece of software. It directly interfaces with the hardware device on which it is running to manage memory, accept input from the keyboard, access the video display or hard disk, keep accurate time, and so on. The ability to interface with these functions to support a new hardware device, such as a new ethernet controller, requires an understanding of how the kernel works.

This book is incredibly easy to read for such an immensely complex topic. Certainly a firm understanding of the C programming language and a solid understanding of how an operating system works is also really necessary. If you meet those qualifications though, this book is clearly the definitive source for those interested in hacking on the kernel.

The first few chapters talk about how to access the kernel source, some history behind the initial design and its Unix heritage, as well as how kernel versions are numbered.

It then quickly gets serious with a great overview of process management. By page 33 the author is already talking about page table entries, the fork()/exec() procedure for creating new processes, and how Linux has never had a concept of threads. Instead, all threads are processes that share resources with other processes.

Process scheduling, multitasking, and kernel preemption are covered in chapter four. Determining the most efficient means to provide access for a process to a particular resource, particularly when there are scalability and other factors involved, is always a challenge. This chapter provides a great explanation of how it all works together.

With still very little actual kernel code included thus far, chapter five outlines system calls, how they are implemented and relate to library calls.

Chapter six outlines the kernel data structures, including link lists and how to traverse them, queues and associative arrays, binary trees, and how each should be used.

Hardware devices, such as keyboards or network controllers, communicate with the operating system through the use of interrupts. These hardware devices can send an electrical signal to the processor when it needs to be serviced (the keyboard has received user input, for example). An example using the real-time clock is used to describe how to build an interrupt handler to manage these events.

What happens when two programs are accessing and modifying the same resource at the same time? Race conditions are explored in chapter nine. Synchronization of processes requires that the developer understand and causes of concurrency such as multiple processors, kernel preemption, and interrupts need to be understood and managed by the kernel developer, and know how to deal with these issues. Chapter nine and ten detail how this process is done.

Chapter eleven outlines how the kernel manages timing events. Have you ever heard of BogoMIPS? During the boot process on your Linux PC, you may have seen a message like:

Detected 2000.482 MHz processor.

Calibrating delay loop (skipped), value calculated using timer frequency.. 4000.96 BogoMIPS (lpj=2000482)

This is really the number of busy loop iterations the processor can perform in a given period. Effectively, BogoMIPS is a representation of how fast a processor can do nothing!

Timing is critical in many areas of the kernel, including device drivers as the author describes.

For those of you who are really courageous, there's a discussion of memory management in chapter twelve. Despite being only thirty pages long, this chapter details how to manage kernel memory and why managing it is more difficult than working with memory from user-space. There's a later chapter devoted exclusively to managing memory in process address space.

Managing the filesystem is another major area of responsibility for the kernel. With more than 60 different filesystems in the default kernel, a sophisticated abstraction layer that makes it possible to support so many filesystems with a consistent interface is required and clearly explained in later chapters.

Every device on a Linux system is represented as a file, and it is uniquely identified in the filesystem. Chapter thirteen outlines the data structures that are used to store filesystem information and the functions that are used to access that information. A clear description of the functions are briefly detailed. There's also a structure that keeps track of the individual capabilities and behavior of each filesystem and running processes.

One of the features that differentiates Linux from other Unix systems is the concept of dynamically loadable modules. These modules provide "pluggable" capability to support new devices as necessary. Typically these are in the form of a network or USB controller, or even a new filesystem or encryption mechanism. Chapter Seventeen details the process of interfacing with this device model, and provides the programmer with the knowledge of how to interface his new driver with the kernel.

The remaining few chapters detail information on debugging kernel problems, an outline of issues a programmer should know about, portability concerns and how they're managed, as well as how to communicate with the kernel community, such as through the Linux kernel mailing list.

This book is an incredible introduction for those beginning with kernel programming. It's suprisingly easy to read, focused, and provides critical organization to the millions of lines of code that comprise the kernel. For the experienced kernel programmer, this guide provides a great reference for how the various systems within the kernel operate, making it easier to understand the proper ways to write kernel code.

LinuxSecurity Poll

How frequently do you patch/update your system?

No answer selected. Please try again.
Please select either existing option or enter your own, however not both.
Please select minimum 0 answer(s) and maximum 3 answer(s).
[{"id":"179","title":"As soon as patches\/updates are released - I track advisories for my distro(s) diligently","votes":"45","type":"x","order":"1","pct":81.82,"resources":[]},{"id":"180","title":"Every so often, when I think of it","votes":"5","type":"x","order":"2","pct":9.09,"resources":[]},{"id":"181","title":"Hardly ever","votes":"5","type":"x","order":"3","pct":9.09,"resources":[]}] ["#ff5b00","#4ac0f2","#b80028","#eef66c","#60bb22","#b96a9a","#62c2cc"] ["rgba(255,91,0,0.7)","rgba(74,192,242,0.7)","rgba(184,0,40,0.7)","rgba(238,246,108,0.7)","rgba(96,187,34,0.7)","rgba(185,106,154,0.7)","rgba(98,194,204,0.7)"] 350

Please vote first in order to view vote results.



bottom 200

Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]

We use cookies to provide and improve our services. By using our site, you consent to our Cookie Policy.