Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

application but cannot (or often does not) write the documentation. The
comments the programmer puts in the source code are often the only
documentation that exists for the code.


Small testing programs are even “hidden” in the comments of some of the
code, along with comments and references to other information. Because the
source code is written in a language that can be read as easily—almost—as
English, a nonprogrammer might be able to get an idea of what the
application or driver is actually doing (see Chapter 40, “Using Programming
Tools for Ubuntu,” for an idea of how that could happen). This information
might be of use to an intermediate to advanced Linux user who is confronted
by kernel- and driver-related problems.


NOTE
The interaction and control of hardware is handled by a small piece of the
kernel called a device driver. The driver tells the computer how to interact
with a modem, a SCSI card, a keyboard, a mouse, and so on in response to
a user prompt. Without the device driver, the kernel does not know how to
interact with the associated device.

Types of Kernels


In the early days of Linux, a kernel was a single block of code containing all
the instructions for the processor, the motherboard, and the other hardware. If
you changed hardware, you were required to recompile the kernel code to
include what you needed and discard what you did not need. Including extra,
unneeded code carried a penalty because the kernel became larger and
occupied more memory. On older systems that had only 4MB to 8MB of
memory, wasting precious memory for unnecessary code was considered
unacceptable. Kernel compiling was something of a “black art,” as early
Linux users attempted to wring the most performance possible from their
computers. Such kernels compiled as a single block of code are called
monolithic kernels.


As the kernel code grew larger and the number of devices that could be added
to a computer increased, the requirement to recompile became onerous. A
new method of building the kernel was developed to make the task of
compiling easier. The part of the kernel’s source code that composed the code
for the device drivers could be optionally compiled as a module that could be
loaded and unloaded into the kernel as required. This is known as the modular
approach to building the kernel. Now, all the kernel code could be compiled at
once, with most of the code compiled into these modules. Only the required

Free download pdf