In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use Linux Kernel". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use Linux Kernel.
Linux Kernel supports several module types, including device drivers. Each module consists of object code and is not a complete executable program. When the system is running, we can connect the module to the running kernel through insmod. You can also use lsmod to list loaded modules, rmmod or modprobe-r to remove modules.
The Linux system divides devices into three basic types: character devices, block devices, and network interfaces.
A character device is a device that can be accessed like a byte stream and can only be accessed sequentially. Its operation is similar to file operation.
The block device can hold the file system and can be randomly accessed through the file system. Its operation is also similar to file operation.
The network interface is responsible for the transmission and reception of data packets and generally cannot be mapped to the nodes of the file system. It communicates with the kernel differently from the previous two devices, but through socket. A special data structure (sk_buff) is defined between the system and the driver for data transfer. The system supports the cache of sending and receiving data, provides flow control mechanism, and provides support for multi-protocols.
When writing a module, it should be noted that the module is only connected to the kernel, so it can only call those functions exported by the kernel, not other functions not defined by this module.
When developing modules under Linux kernel2.6.X, it is necessary to prepare "kernel tree" in advance, that is, to obtain the source code of the same kernel as this system and compile the target file.
One of the simplest examples of hello world drivers:
Hello_world.c: # include # include MODULE_LICENSE ("Dual BSD/GPL"); static int hello_init (void) {printk (KERN_ALERT "Hello, world\ n"); return 0;} static void hello_exit (void) {printk (KERN_ALERT "Goodbye, cruel world\ n");} module_init (hello_init); module_exit (hello_exit) Makefile: obj-m: = hello.o KERNELDIR? = / lib/modules/$ (shell uname-r) / build PWD: = $(shell pwd) default: $(MAKE)-C $(KERNELDIR) PWD $(PWD) modules where module_init and module_exit in the source file specify the initialization function performed when the module is loaded and the cleanup function performed when the module is unloaded. You can also use module_param to specify parameters that can be set when the module is loaded. The obj-m in Makefile specifies the * .o object file to use when constructing the * .ko object file when using make modules.
At this point, I believe you have a deeper understanding of "how to use Linux Kernel". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.