Skip to Main Content
Understanding the Linux Kernel
book

Understanding the Linux Kernel

by Daniel P. Bovet, Marco Cesati
October 2000
Intermediate to advanced content levelIntermediate to advanced
704 pages
18h 13m
English
O'Reilly Media, Inc.
Content preview from Understanding the Linux Kernel

To Be (a Module) or Not to Be?

When system programmers want to add a new functionality to the Linux kernel, they are faced with an interesting dilemma: should they write the new code so that it will be compiled as a module, or should they statically link the new code to the kernel?

As a general rule, system programmers tend to implement new code as a module. Because modules can be linked on demand, as we see later, the kernel does not have to be bloated with hundreds of seldom-used programs. Nearly every higher-level component of the Linux kernel—filesystems, device drivers, executable formats, network layers, and so on—can be compiled as a module.

However, some Linux code must necessarily be linked statically, which means that either the corresponding component is included in the kernel, or it is not compiled at all. This happens typically when the component requires a modification to some data structure or function statically linked in the kernel.

As an example, suppose that the component has to introduce new fields into the process descriptor. Linking a module cannot change an already defined data structure like task_struct since, even if the module uses its modified version of the data structure, all statically linked code continues to see the old version: data corruption will easily occur. A partial solution to the problem consists of "statically" adding the new fields to the process descriptor, thus making them available to the kernel component, no matter how it has been ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Kernel in a Nutshell

Linux Kernel in a Nutshell

Greg Kroah-Hartman
Linux Kernel Debugging

Linux Kernel Debugging

Kaiwan N. Billimoria
Understanding the Linux Kernel, 3rd Edition

Understanding the Linux Kernel, 3rd Edition

Daniel P. Bovet, Marco Cesati

Publisher Resources

ISBN: 0596000022Catalog PageErrata