|Lesson 2|| Kernel concepts |
|Objective|| Explain the Differences between Modular and Monolithic Kernels|
The kernel is the Linux operating system's core component. It is responsible for managing system memory, scheduling processes to run,
and accessing the system's hardware on behalf of the users.
As you can imagine, the kernel has a big job to do and needs to operate efficiently.
One way to increase efficiency is to reduce the kernel's total memory requirement, allowing it to focus on managing processes' memory and not its own.
To reduce the memory requirement we have to remove unnecessary kernel components.
A modular kernel allows an administrator to add functionality only when required.
Keeping only what is necessary in kernel memory reduces the kernel's memory footprint and increases its overall performance.
Each kernel module contains code to handle some necessary system functionality. Device drivers , for example, are common modules: a device driver such as a network module provides the support for a particular brand of network card.
Modular kernels require a small amount of time to load modules. However, if the kernel was constantly loading and unloading modules, it would eventually spend more time processing load and unload requests than handling its other responsibilities.
To address this issue, the Linux kernel only loads modules when the system needs the functionality.
Once loaded, a module remains in the kernel until explicitly removed. If another resource needs the module, the kernel can create anotherinstance to meet the demand.
This scheme prevents the kernel from needing to rapidly load and unload modules.
RHCSA & RHCE Red Hat Enterprise Linux 7
- Memory footprint:The total amount of physical and swap memory a process uses.
- Device drivers : A unit of code written to interact with a specific hardware device.
- Instance: A particular session of any object, where each session has particular characteristics that identify it uniquely.
For example, a red car is an instance of the general "car" object, and you can identify the car by its red characteristic.
- Process : The computer's representation of a task. When a program is run from the command line,
the binary is loaded into memory as a "process." The kernel shuffles processes around very quickly, simulating "simultaneous" program execution.
A monolithic kernel is the exact opposite of a modular kernel. All support for system functionality, such as device drivers, is built directly into the kernel.
Because the kernel supports all conceivable devices, especially those rarely used, kernel memory is wasted on unused support.
The image below illustrates the difference between modular and monolithic kernels.
A reasonable approach
In reality, most kernels are not strictly modular or monolithic, but are a reasonable mixture.
It makes sense to include some functionality directly in the kernel--for example, frequently used or boot-required functionality.
It also makes sense to leave unused or rarely used code modular.
For example, you might not have a ZIP drive now, but in the future you may, so building a module for it now and loading it when needed saves you some work later.
You should always build mostly modular kernels.
The next lesson shows you how ton work with kernel modules.