Skip to content
Tech News
← Back to articles

Intrusive linked lists (2019)

read original more articles
Why This Matters

Intrusive linked lists are a memory-efficient variation where list pointers are embedded within the data structures themselves, enabling faster and more direct access to linked objects. This technique is particularly useful in operating systems like Linux for process management, offering performance benefits by reducing memory overhead and improving cache locality. Understanding intrusive linked lists is essential for developers working on low-level system programming and performance-critical applications.

Key Takeaways

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