The loadable kernel modules in an operating system is an object file that contains code to extend the running kernel, which is also known as the base kernel. The loadable kernel modules are used to add support for file systems, hardware, system calls etc.
An image that shows the loadable modules of the operating system is as follows −
The different types of kernels in the operating system that may require loadable kernel modules are −
A microkernel is the minimum software that is required to correctly implement an operating system. This includes memory, process scheduling mechanisms and basic inter-process communication.
The microkernel contains basic requirements such as memory, process scheduling mechanisms and basic inter-process communication. The only software executing at the privileged level i.e. kernel mode is the microkernel. The other functions of the operating system are removed from the kernel mode and run in the user mode. These functions may be device drivers, file servers, application interprocess communication etc.
The microkernel makes sure that the code can be easily managed because the services are divided in the user space. This means that there is less code running in the kernel mode which results in increased security and stability.
The entire operating system works in the kernel space in the monolithic system. This increases the size of the kernel as well as the operating system. This is different than the microkernel system where the minimum software that is required to correctly implement an operating system is kept in the kernel.
The monolithic kernel provides various services such as memory management, file management, process scheduling etc. using function calls. This makes the execution of the operating system quite fast as the services are implemented under the same address space.
An operating system would have to include all the systems that provided all anticipated functionalities in the base kernel if there were no loadable modules. This would lead to wastage of memory as most of those systems would not be used often. Also, the users would need to rebuild and reboot the base kernel every time they would require a new functionality.
The fragmentation penalty is a major disadvantage of loadable modules in the kernel. This means that every time a new kernel module code is inserted, the kernel becomes fragmented. This leads to a performance penalty because of more TLB (Transaction Lookaside Buffer) misses.