Loadable kernel module
lastmod 2019-10-22created 2019-10-221 edits
A loadable kernel module (LKM) is an object file that contains code to extend the running kernel of an operating system. LKMs are typically used to add support for new hardware (device drivers) or file systems, or to add system calls. When the functionality provided by an LKM is no longer required, it can be unloaded to free its memory and resources.
Most current Unix-like operating systems and Microsoft Windows support loadable kernel modules, though they may use different names: kernel loadable module (kld) on FreeBSD, kernel extension (kext) on OS X, and kernel-mode driver on Windows NT. They are also called Kernel Loadable Modules (KLM), or simply Kernel Modules (KMOD).
Although they use different names, most Unix-like systems and Windows (kernel-mode drivers) support loadable kernel modules.
Pros
Without loadable kernel modules, an operating system would have to include all possible anticipated functionality directly in the base kernel. Much of it would reside in memory even while unused, wasting memory and increasing the user's reboot time. Most operating systems that support loadable kernel modules include modules to support the required functionality.
Cons
One criticism of modular kernels is the so-called fragmentation penalty. The base kernel is always unpacked into real contiguous memory by its setup routines, so the base kernel is never fragmented. Once modules are inserted, inserting new kernel code can fragment the kernel, which can cause a small performance penalty.