In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article is about what the linux module means. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
In linux, a module is a way to add device drivers, file systems, and other components to the linux kernel. It is a collection of functions and data types that can be compiled as stand-alone programs and can be loaded into kernel space either statically or dynamically.
The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
What does the linux module mean?
A module is a way to add device drivers, file systems, and other components to the Linux kernel without recompiling the kernel or restarting the system. As far as the kernel is concerned, what it needs to deal with is the loading and unloading of modules and the dependencies between modules. Because the module runs in the kernel space, the module must use the functions provided by the kernel, and we can also use the module to call the corresponding kernel functions, which is a way of kernel state programming. The essence of a module file is a relocatable binary file, which usually appears in the form of * .ko.
The Linux module can be loaded into the kernel space statically or dynamically. Static loading refers to loading during the kernel startup process; dynamic loading refers to loading at any time while the kernel is running. When a module is loaded into the kernel, it becomes part of the kernel code. When the module is loaded into the system, the system modifies the symbol table in the kernel and adds the resources and symbols provided by the newly loaded module to the kernel symbol table to facilitate the communication between modules.
The use of modules
Composition of the module
The Linux kernel module mainly consists of the following parts:
Module load function (must): when the kernel module is loaded through the insmod command, the module load function will be automatically executed by the kernel to complete the initialization work related to this module.
Module unload function (must): when a module is unloaded with the rmmod command, the module's unload function is automatically executed by the kernel, performing the opposite function to the module load function.
Module license statement (required): the module license (LICENSE) statement describes the permissions of the kernel module, and if LICENSE is not declared, the module will receive a warning of kernel contamination when it is loaded.
Module parameter (optional): the module parameter is the value that can be passed to the module when it is loaded, and it corresponds to the global variable within the module.
Module export symbols (optional): kernel modules can export symbols (symbol, corresponding to functions or variables) so that other modules can use variables or functions in this module
Information declaration such as module author (optional).
An example of a module:
/ / kernel header file # include#include#include// load function static int _ _ init init_hello_module (void) {/ / kernel print function. The linux system uses the dmesg command to view print information printk (KERN_INFO "Hello World\ n"); return 0;} / uninstall function static void _ _ exit exit_hello_module (void) {printk (KERN_INFO "Exit the Hello world Module!\ n");} module_init (init_hello_module) Module_exit (exit_hello_module); MODULE_LICENSE ("GPL"); MODULE_AUTHOR ("Eric"); MODULE_VERSION ("v0.1"); MODULE_DESCRIPTION ("TEST FOR MODULE")
Makefile file corresponding to the module:
# Makefileobj-m:=hello.oKERNELBUILD:=/lib/modules/$ (shell uname-r) / buildall: make-C $(KERNELBUILD) Manners $(shell pwd) modulesclean: make-C $(KERNELBUILD) Manners $(shell pwd) clean Thank you for reading! This is the end of this article on "what does the linux module mean?" I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.