Imagine you have a driver that manages more than one device, let's say five devices. You may need to keep a track of each of them in your driver. What you need here is a linked list. Two types of linked list actually exist:
- Simply linked list
- Doubly linked list
Therefore, kernel developers only implement circular doubly linked lists because this structure allows you to implement FIFO and LIFO, and kernel developers take care to maintain a minimal set of code. The header to be added in the code in order to support lists is <linux/list.h>. The data structure at the core of list implementation in the kernel is the struct list_head structure, defined as the following:
struct list_head { struct list_head *next, *prev; };
The struct list_head is used in both the head of the list and each node. In the world of the kernel, before a data structure...