What is a Kset in Linux?

Embedded linux






In this article, we explain what a kset is in linux.

A Kset is a set of kobjects of the same type and belongs to a specific subsystem.

Basically, a kset is a higher-level structure which collects all lower level kobjects which belong to the same type.

The diagram below illustrates this concept.


Kset in linux


So all the parent objects of the kobjects are linked together and are part of the same kset.

This helps linux form the hierarchy in the system of the kobjects and the kset parent container.

Let's now look at the code representing the kset structure.

This is shown below.


struct kset in linux


Looking at the structure above, the list field is the head of the doubly linked circular list of kobjects included in the kset.

The kset can be thought of as a parent structure to kobjects, which groups all the kobjects together according to a specific subsystem.

Let's go to the linux terminal and go to the directory, /sys/bus/platform/devices/

When you type this in, you should see output similar to that shown below.


Kset and kobjects in linux terminal


So the kset for all of the contents of this directory is platform.

platform contains all of the devices seen in this directory.

All the contents of the directory are devices, which are kobjects.

So with this hierarchy, you can see that all the different buses in linux represent different ksets.

platform is just one kset that groups kobjects together, which are platform devices. But there are several others.

If we go into the bus directory of the sys directory, we can see several other ksets in linux hierarchy.


Ksets in linux terminal


You can see that all these different buses represent ksets in linux.

They would be the ksets for various kobjects found within their directories.

This includes buses such as spi, usb, i2c, etc.

The bus directory itself is a subsystem.

All of the buses themselves belong to the bus subsystem in linux.

Remember the hierarchy for linux is shown below.


Kset hierarchy in linux


So you see that the kset is the overlying parent structure of the device.

Devices belong to a particular bus. Every device connected in a system must be connected to a bus in order for the CPU to interact with it.

Thus, every device is connected to a bus.

The bus really represents the kset of kobjects of devices connected to the bus, because it groups all the devices connected to it.

This is the hierarchy you see when you're navigating the linux terminal.

And this is what a kset is and represents.



Related Resources





HTML Comment Box is loading comments...