Kernel Data Structures Linkedlist | by Uraj singh | Medium
Working as a kernel developer is interesting , you never know when you will encounter a macro or data structure that is subtle. One of these in my journey was how linked list abstraction is done in kernel. So lets start with how a programmer will generally use linked list and then move forward about doing it in kernel world. To be able to link each element of type struct mystruct to others, we need to add a struct mystruct *(next) field: Then you create structures , initialise the values and link those structures. This in nutshell will have structures and pointers to similar structure element. Let’s take a look at the kernel’s linked list API from the perspective of “how would I use it in my own code?” (e.g. a Loadable Kernel Module). Let’s start by defining a data structure in which we will embed kernel linked list: To be able to link each element of type struct mystruct to others, we need to add a struct list_head field: Well struct list_head is defined in include/linux/types.h as: I
Working as a kernel developer is interesting , you never know when you will encounter a macro or data structure that is subtle. One of these in my journey was how linked list abstraction is done in kernel. So lets start with how a programmer will generally use linked list and then move forward about doing it in kernel world. To be able to link each element of type struct mystruct to others, we need to add a struct mystruct *(next) field: Then you create structures , initialise the values and link those structures. This in nutshell will have structures and pointers to similar structure element.
Explore this link on the map →