1 / 17

Linux Kernel Development

Linux Kernel Development. Chpt17: kobjects and sysfs. Tao Yang 2007-06-01. Overview. Device model Kobject Ktypes Ksets Subsystems Reference Counts Sysfs The Kernel Events Layer. device model. Representing devices & describing topology Benefits: Minimization of code duplication

tommiee
Télécharger la présentation

Linux Kernel Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux Kernel Development Chpt17: kobjects and sysfs Tao Yang 2007-06-01

  2. Overview • Device model • Kobject • Ktypes • Ksets • Subsystems • Reference Counts • Sysfs • The Kernel Events Layer

  3. device model • Representing devices & describing topology • Benefits: • Minimization of code duplication • providing common facilities • enumerate all the devices • generate a complete tree of the entire device structure • link devices to their drivers • categorize devices by their class • The ability to walk the tree of devices from the leaves up to the root, poweringdown devices in the correct order

  4. kobjects • Kobject: the heart of the device model

  5. ktype • which the kobjects are associated with • describing default behavior for a family of kobjects • define default properties: deconstruction behavior, sysfs behavior, and default attributes

  6. ksets • Collections of kobjects • Distinction of ksets and ktypes: • ksets collect kobjects into a set • ktypes describe properties shared by kobjects of a related type • allow kobjects of identical ktypes to be grouped into different ksets

  7. Subsystem • high-level concepts in the kernel • a collection of one or more ksets • Ksets contain kobjects • subsystems contain ksets

  8. Same ktype Relationship of these Structure • Kobject: the basic unit • Ktype: describe default properties • Ksets: Collections of kobjects

  9. Managing and Manipulating kobjects • declaring and initializing • Before calling this function, the kobject must be zeroed • set the kobject's name

  10. Reference Counts • To keep the kobject in memory or destroy it • Incrementing the reference count: • Decrementing the reference count: • Kref: provide the kobject reference counting

  11. sysfs • In-memory virtual filesystem • View the kobject hierarchy • View the device topology as a simple filesystem

  12. Adding and Removing kobjects from sysfs • Export a kobject to sysfs • Initializes the given kobject and adds to the object hierarchy • Removing a kobject's sysfs • Both kobject_del() and kobject_put():

  13. Adding Files to sysfs • Default Attributes: • ktype field in kobjects and ksets provide default set of files • Attribute structures: map kernel data to files in sysfs • Creating New Attributes • Destroying New Attributes

  14. sysfs Conventions • To keep sysfs clean and intuitive, conventions must be followed: • First, sysfs attributes should export one value per file • Second, organize data in sysfs in a clean hierarchy • Finally, keep in mind that sysfs provides a kernel-to-user service

  15. The Kernel Events Layer • Implements a kernel-to-user notification system • Hard drive full • Processor is overheating • Partition mounted • send events out to user-space from kernel code:

  16. Conclusion • Subject : device model, sysfs, kobjects, and the kernel event layer • Driver writers need only a peripheral view of these topics • Developers of kernel need a more in-depth understanding of kobjects

  17. Thank you Q & A

More Related