Analysis of commonly used list in Linux (1)

Source: Internet
Author: User
In Linux, list is a universal system linked list, which is widely used in various places of the system, such as system message queues and process lists. It can be said that this list will be used as long as there is a table.
Http://download1.csdn.net/down3/20070530/30164350798.h

Today, we will first parse the information related to initialization.Code:

1. header node Structure
Struct list_head {
Struct list_head * Next, * Prev;
};
This is the same as writing a linked list to define a header node.
We can see from next and Prev that this is a two-way linked list.
However, the difference is that there is no content in this node structure, that is, the type data we often say;
This is the embodiment of "General.

2. # define list_head_init (name) {& (name), & (name )}
Define a macro initialized by list_head. The content in the braces below does not seem to be readable currently.

# Define list_head (name )/
Struct list_head name = list_head_init (name)

In this way, we can understand the combination of the two nodes. When we execute the list_head (name) Macro, we will create a header node and use & name to initialize the two member pointers of this node.

3. static inline void init_list_head (struct list_head * List)
{< br> list-> next = List;
list-> Prev = List;
}< br> This Is An initialization header node function that points next and Prev to itself.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.