在linux内核中,有一种通用的双向循环链表,构成了各种队列的基础。链表的结构定义和相关函数均在include/linux/list.h中,下面就来全面的介绍这一链表的各种API。
[cpp] view plaincopyprint? 1. struct list_head {
2. struct list_head *next, *prev;
3. };
这是链表的元素结构。因为是循环链表,表头和表中节点都是这一结构。有prev和next两个指针,分别指向链表中前一节点和后一节点。
[cpp] view plaincopyprint? 1. #define LIST_HEAD_INIT(name) { &(name), &(name) }
2.
3. #define LIST_HEAD(name) \
4. struct list_head name = LIST_HEAD_INIT(name)
5.
6. static inline void INIT_LIST_HEAD(struct list_head *list)
7. {
8. list->next = list;
9. list->prev = list;
10. }
在初始化的时候,链表头的prev和next都是指向自身的。
[cpp] view plaincopyprint? 1. static inline void __list_add(struct list_head *new,
2. struct list_head *prev,
3. struct list_head *next)
4. {
5. next->prev = new;
6. new->next = next;
7. new->prev = prev;
8. prev->next = new;
9. }
10.
11. static inline void list_add(struct list_head *new, struct list_head *head)
12. {
linux 内核分析之 list_head 双向链表结构本文详细分析了 2.6.x 内核中链表结构的实现,并通过实例对每个链表操作接口进行了详尽的讲解。 链表数据结构简介 一、 ...
深入浅出 linux 内核源代码之双向链表 list_head 原创文章,转载请注明出处,谢谢! 作者:清林,博客名:飞空静渡 范金宝 email:fjb2080@163.com blog:http://blog...
linux 内核部件分析(一)——连通世界的 list 内核部件分析( ——连通世界的在...static inline void __list_add(struct list_head *new, struct list_head *...
linux内核head.S分析_IT/计算机_专业资料。其中涉及到的文件有head.S head-...* * See linux/arch/arm/tools/mach-types for the complete list of ...
http://blog.csdn.net/hondrif82q/archive/2007/04/14/1564893.aspx linux 内核中的 list 详解 1 list_entry 作用就是通过 list_head 型指针 ptr 换算成其...
Linux内核链表list_head扩展---klist_互联网_IT/计算机_专业资料。linux kernel看SPI 驱动核心模块时,看到用到很多 klist,之前没多深入理解,现在来一步步分析源码...
Linux 内核源码分析-链表代码分析 分析人:余旭 分析时间:2005 年 11 月 17 ...static inline void list_add(struct list_head *new, struct list_head *...
linux内核中的等待队列分析... 22页 1财富值 Linux 等待队列 21页 免费 ...等待队列头 struct __wait_queue_head { wq_lock_t lock; struct list_head...
深入分析 Linux 内核链表... 9页 免费 Linux内核之list_head 23页 免费...内核代码赏析与应用( )-链表之实现 Linux 内核代码赏析与应用(二)-链表之实现...
下面我们将基于 Linux 2.4.21 分析 Linux 内核双循环链表的实现及应用。 声明和初始化 链表结构定义如下: struct list_head { struct list_head *next, *prev...
热门文档