linux内核中的进程列表

Linux链表数据结构及相关操作 定义 /include/linux/types.hstruct list_head { struct list_head *next, *prev; };与响应的结构组成双向链表。 初始化 /include/linux/list.h#define LIST_HEAD_INIT(name) { &(name), &(name) } #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) 方法 插入 static inline void list_add(struct list_head *new, struct list_head *head)static inline void list_add_tail(struct list_head *new, struct list_head *head) 删除 static inline void list_del(struct list_head *entry) 替换 static inline void list_replace(struct list_head *old, struct list_head *new) 交换 static inline void list_swap(struct list_head *entry1, struct list_head *entry2) 删除 static inline void list_move(struct list_head *list, struct list_head *head) 遍历 #define list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) 获取节点某一成员 #define list_entry(ptr, type, member) \ container_of(ptr, type, member) 以上是基于2.4内核版本的宏, 2.6版本后引入RCU新的锁机制,相关宏定义后新增_rcu. ...

2019-05-26 · 3 min · 535 words