Datasheet
Mauerer runc01.tex V2 - 09/04/2008 4:13pm Page 21
Chapter 1: Introduction and Overview
next
prev
next
prev
next
prev
next
prev
Figure 1-11: Doubly linked standard list.
struct list_head
is called a list element when it is held in a data structure. An element that serves as the
starting point for a list is called a list head.
Pointers that connect head and t ail 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 usually omit the connection
between list head and list tail in figures. The above list is in t he 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 is not displayed, 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 is
struct list_head
).
❑
list_add(new, head)
inserts
new
right after the existing
head
element.
❑
list_add_tail(new, head)
inserts
new
right before the element specified by
head
. If the list head
is specified for
head
, 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 in
list
after the
head
element
of an existing list.
❑
list_entry
must be used to find a list element; at first glance, its call syntax appears to be quite
complicated:
list_entry(ptr, type, member)
.
ptr
is a pointer to the
list_head
instance of the
21