Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 1: Introduction and Overview


next
prev

next
prev

next
prev

next
prev

Figure 1-11: Doubly linked standard list.

struct list_headis called alist elementwhen it is held in a data structure. An element that serves as the
starting point for a list is called alist head.


Pointers that connect head and tail elements of a list tend to clutter up images and
often obstruct the principal intention of a figure, namely, to briefly summarize the
connections of various kernel data structures. I thus usuallyomitthe connection
between list head and list tail in figures. The above list is in the remainder of this
book therefore represented as shown in Figure 1-12. This allows for concentrating
on the essential details without having to waste space for irrelevant list pointers.

Figure 1-12: Simplified illustration of a doubly
linked list. Notice that the connection between
list head and list tail isnotdisplayed, although
it is present in kernel memory.

There are several standard functions for handling and processing lists. We will come across them again
and again in the following chapters (the data type of their arguments isstruct list_head).


❑ list_add(new, head)insertsnewright after the existingheadelement.
❑ list_add_tail(new, head)insertsnewright before the element specified byhead. If the list head
is specified forhead, this causes the new element to be inserted at the end of the list because of
the cyclic nature of the list (this gives the function its name).
❑ list_del(entry)deletes an entry from a list.
❑ list_empty(head)checks if a list is empty, that is, if it does not contain any elements.
❑ list_splice(list, head)combines two lists by inserting the list inlistafter theheadelement
of an existing list.
❑ list_entrymust be used to find a list element; at first glance, its call syntax appears to be quite
complicated:list_entry(ptr, type, member).ptris a pointer to thelist_headinstance of the
Free download pdf