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
11 min read Oct 17, 2018 -- Table of Contents Introduction Creating a doubly linked-list Looping it up ! Accessing the addresses of linked-list Where are other elements, “container_of ” to Rescue ? Demystifying “container_of” ! Finally bringing it all together. Wow ! Our little example now reads References History License Introduction Ordinary world 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…
related reading
- Intrusive linked lists - Data structures in practicedata-structures-in-practice.com
- Linked list - Wikipediaen.wikipedia.org
- CS106B Linked Structuresweb.stanford.edu
- The Linux Kernel Module Programming Guidesysprog21.github.io
- Introduction - Learning Rust With Entirely Too Many Linked Listsrust-unofficial.github.io
- list - C++ Referencecplusplus.com
- how I think when I think about programming - alice mazalicemaz.com
- Kernel modules - The Linux Kernel documentationlinux-kernel-labs.github.io
- Memory allocatorcs162.org
- The true cost of linked lists · YKarroumykarroum.com
- The Lost Art of Structure Packingcatb.org
- Introductioncs162.org