Compiling Kernel   «Prev  Next»

Lesson 2 Kernel concepts
Objective Explain the Differences between Modular and Monolithic Kernels

Modular and Monolithic Kernels in Redhat Linux

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.

Modular Kernels

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[1] and increases its overall performance.
Each kernel module contains code to handle some necessary system functionality. Device drivers[2], 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 another instance[3] to meet the demand. This scheme prevents the kernel from needing to rapidly load and unload modules. For example, a red car is an instance of the general "car" object, and you can identify the car by its red characteristic. The kernel shuffles processes[4] around very quickly, simulating "simultaneous" program execution.

Monolithic Kernels

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.
Modular kernels load modules dynamically 2) Monolithic kernels hold all code within the kerne
1) Modular kernels load modules dynamically

1) Modular kernels load modules dynamically 2) Monolithic kernels hold all code within the kernel
2) Monolithic kernels hold all code within the kernel

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.

Red Hat Linux Server
[1]Memory footprint:The total amount of physical and swap memory a process uses.
[2]Device drivers : A unit of code written to interact with a specific hardware device.
[3]Instance: A particular session of any object, where each session has particular characteristics that identify it uniquely.
[4]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."

SEMrush Software2