The kobject of the Linux device model

Source: Internet
Author: User

Kobject structure


In the Linux kernel, Kobject is the basis for composing the Linux device model, and a kobject corresponds to the SYSFS
A directory. From an object-oriented perspective, Kobject can be seen as the base class for all device objects, because C
Language does not have object-oriented syntax, so it is common to embed kobject into other constructs to achieve similar
, the other structures here can be thought of as kobject derived classes. Kobject for the Linux device model
Useful features such as reference counting, interface abstraction, parent-child relationships, and so on. Reference counting is essentially
is realized by using Kref.
In addition, the Linux device model has an important data structure kset. Kset itself is also a kobject,
It behaves as a directory in Sysfs, but it differs from kobject in that Kset can be seen as
A container, if you compare it to a C + + container class such as List is not. Kset can be used as a capacity
is built into a doubly linked list structure struct list_head.
The devices in the nucleus are organized in a tree form, in which the nodes in the hierarchy are compared to the parent nodes of the lower nodes, reflecting the relationship between the parent directory and the subordinate directory in the SYSFS, in the kernel
, it is kobject to help us achieve this kind of parent-child relationship. In the definition of kobject, name means
The name of Kobject in SYSFS; the pointer parent is used to point to kobject ; kref people should be better than
More familiar, kobject through it to implement the reference count; The Kset pointer is used to point to the Kobject
Kset, the use of Kset is described in detail below, and for Ktype, if it is only words too literally, it should be
The type information used to describe the kobject.


The kobject of the Linux device model

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.