This post will teach you what intrusive linked lists are and how they are used to manage processes in Linux.
What are intrusive linked lists?
Intrusive linked lists are a variation of linked lists where the links are embedded in the structure that’s being linked.
In a typical linked list implementation, a list node contains a data pointer to the linked data and a next pointer to the next node in the list.
Figure 1: A linked list
In an intrusive linked list implementation, the list node contains next pointer to the next list node, but no data pointer because the list is embedded in the linked object itself.
Figure 2: An intrusive linked list
A list structure for an intrusive singly linked list contains a single next pointer to another list node:
typedef struct list { struct list * next; } list;
The list structure is then embedded in the structure that will be linked. For example, you might have a item structure with a val member:
... continue reading