2017-2018-1 20179209 "Linux kernel Fundamentals and Analysis" Tenth week assignment

Source: Internet
Author: User

Device and Module equipment classification block equipment

Block devices can be addressed in blocks, with different block sizes depending on the device, and devices typically support relocation operations, which are random access to data. Examples of block devices are external memory, CDs, and so on.

Character device

The character device is not addressable and is only used for streaming data, which is a character or byte. Examples of character devices are keyboards, mice, printers, and so on.

Network equipment

The most common types of network devices are sometimes referred to as Ethernet devices, which provide access to the network through a physical adapter and a specific protocol. Network devices break the Unix "Everything is a file" design principle, it is not accessed through the device node, but through the socket API such a special interface to access.

Module
    • Linux is the operating system of a "monolithic kernel" (the entire system core is run in a separate protection domain). But the Linux kernel is modular, which allows the kernel to remove code from or to it dynamically at runtime. The code (including related subroutines, data, function entries, or exits) is combined in a separate binary image, known as a loadable kernel module, or simply as a module. The benefit of the support module is that the basic kernel image can be as small as possible, since optional features and drivers can be provided in the form of modules.
    • The module initialization function must conform int my_init(void) to the form. Static is optional, in general, the initialization function is not directly called by the external function, so you can use the static tag; the INT function returns an int value (0 or not 0). The main functions of the INIT function are registering resources, initializing hardware, allocating data structures, and so on.
    • The module initialization function is the module entry point, and the Exit function is the Exit function of the module, which has a module_exit () routine registered to the system, which is called when the module is unloaded from memory. The function of exit functions is to clean up resources and ensure the consistency of hardware. It must conform void my_exit(void) to the form. It can also be marked as static.
Building blocks are placed in the kernel source tree

This way the modules you write are completely put into the Linux kernel, making them part of the kernel source tree. Modules of different functions are placed in different locations, and device drivers are stored in subdirectories under the root directory of the kernel source code/drivers.

Put it outside the kernel code

In addition to adding modules directly to the kernel tree this once and for all, it can also be placed outside the kernel code, loading modules into their own source code tree directory. This approach is to place the module source code somewhere in the home directory, and the previous way is to store the source code directly under/usr/src/linux!

Device model

Relationships between Kobject, Ktype, and Kset: Kobject introduces basic object props such as reference counting, parent-child relationships, and object names, and is a unified way to provide these features, which are associated with Ktype objects, ktype have struct kobj_ The type struct indicates that in Kobject, the Ktype field points to the object. The Kobject is also referred to as the set and the Kset, Kset set and represented by the struct kset struct.

Virtual file System (SYSFS)

SYSFS provides the user with an attempt to kobject the object hierarchy. Helps users to observe the topology of various devices in a system in a simple file system. With the property structure object, Kobject can provide a kernel variable to the user to read the write in the same way as the exported file.

Portability

Linux supports many architectures because there are code catalogs that are unique to different architectures in the Arch directory.

2017-2018-1 20179209 "Linux kernel Fundamentals and Analysis" Tenth week assignment

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.