What's the difference between loadable modules and built-in (statically linked) modules?
I got this question while finding out an answer for difference between system calls subsys_initcall()
and module_init()
Under Linux use the file /proc/modules shows what kernel modules (drivers) are currently loaded into memory.
A module is a set of functions, types, classes, ... put together in a common namespace. A library is a set of modules which makes sense to be together and that can be used in a program or another library. A package is a unit of distribution that can contain a library or an executable or both.
The Linux loadable modules have two important characteristics: Dynamic linking: A kernel module can be loaded and linked into the kernel while the kernel is already in memory and executing. A module can also be un- linked and removed from memory at any time. Stackable modules: The modules are arranged in a hierarchy.
Loadable kernel modules have several advantages over monolithic "blobs" of code in the kernel: * Device drivers don't have to be hard-coded into the kernel. For example, if a new chip-set comes out that powers many webcams, that kernel module can simply be loaded instead of recompiling the kernel with the new module.
Linux kernel supports inserting of modules (aka device drivers) in two ways:
insmod driver.ko
or modprobe driver.ko
The advantage the loadable modules have over the built-in modules is that you can load unload them on run-time. This is good if you are working on a module and you need to test it. Every time you test it and you need to make changes to it, you can easily unload it (rmmod driver.ko
or modprobe -r driver.ko
) and then after making changes, you can insert it back. But for the built-in modules if you need to make any changes in the module then you need to compile the whole kernel and then reboot the system with the new image of the kernel.
Configuration:
You can configure a module to be either of the two by editing the .config
file in the root folder of your kernel source:
DRIVER_1=y // y indicate a builtin module
DRIVER_1=m //m inicates a loadable module
Note: lsmod
displays only the dynamically loaded modules
not the built-in
ones.
Read on: http://www.tldp.org/HOWTO/Module-HOWTO/x73.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With