Linux kernel modules

Source: Internet
Author: User
Article title: Linux kernel modules that can be loaded. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Linux kernel modules that can be loaded (introduced from Kernel 1.2) are one of the most important innovations in Linux kernel. They provide scalable and dynamic kernels. Explore the principle behind the loadable module and learn how these independent objects are dynamically converted into a part of the Linux kernel.

Linux is generally referred to as a single kernel (monolithic kernel). most features of the operating system are called kernels and run in privileged mode. Unlike the micro-kernel, the latter only provides basic functions (inter-process communication [IPC], scheduling, basic input/output [I/O], and memory management) run as the kernel and exclude other functions (drivers, network stacks, and file systems) from the privileged space. Therefore, you may think that Linux is a completely static kernel, but the opposite is true. Linux kernel module (LKM) can be used to dynamically change Linux during runtime.

Dynamic modification means that a new function can be loaded to the kernel, removed from the kernel, or even added a new LKM that uses other LKM. the advantage of LKM is that it can minimize the memory usage of the kernel and only load the required elements (this is an important feature of the embedded system ).

Linux is not the only (or the first) single kernel that can be dynamically changed. Berkeley Software Distribution (BSD) variants, Sun Solaris, older kernels (such as OpenVMS), and other popular operating systems (such as Microsoft? Windows? And Apple Mac OS X.

Analyze the kernel module

LKM is fundamentally different from the elements directly compiled into the kernel or typical program. A typical program has a main function. the LKM contains the entry and exit functions (in version 2.6, you can name these functions as needed ). When a module is inserted into the kernel, the entry function is called. when a module is deleted from the kernel, the exit function is called. Because the entry and exit functions are user-defined, module_init and module_exit macros exist to define which functions these functions belong. LKM also contains a set of necessary macros and a set of optional macros for defining the module license, Module Author, module description, and so on. Figure 1 provides a very simple LKM view.

Figure 1. simple LKM Source Code View

The Linux kernel of version 2.6 provides a new and simpler method for building LKM. when building LKM, you can use the typical user tool management module (although it has changed internally): Standard insmod (install LKM), rmmod (delete LKM ), modprobe (insmod and rmmod wrapper), depmod (used to create module dependencies), and modinfo (used to find module macro values ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.