内核学习——1、list_head

双向循环链表:list_head

头节点head是不使用的:

struct list_head {

struct list_head *next, *prev;

};

结构体中没有数据域,所以一般把list_head嵌入到其他结构中使用

struct file_node {

char c;

struct list_head node;

};

此时,list_head就作为它父结构体中的一个成员了,我们知道list_head的地址(指针)时,就可以通过list_entry来获得它的父结构的地址

#define list_entry(ptr, type, member) container_of(ptr,type,member)

通过结构体成员地址来求得结构体地址:ptr是所求结构体中的list_head成员指针,type是所求结构体类型,member是结构体list_head成员名

list_for_each:遍历双向链表

LIST_HEAD():生成双向链表头节点

list_add():插入操作

list_del():删除操作

list_empty():判断是否为空

相关推荐
Logintern091 小时前
【每天学习一点点】超参数是什么?
学习·sklearn
Z5998178411 小时前
c#软件开发学习笔记--WPF(控件、样式)
笔记·学习·c#
Zguigo2 小时前
【DL】神经网络学习目标|prediction|Loss|Gradient
人工智能·神经网络·学习
paopaokaka_luck2 小时前
基于springboot3+vue3+uniapp的剧本杀预约小程序(AI角色对话、协同过滤算法、地图Api、Echarts图形化分析)
java·前端·spring boot·学习·echarts
Logintern092 小时前
sklearn中pipeline学习
人工智能·学习·sklearn
math_hongfan2 小时前
鸿蒙ArkTS手势交互:拖拽、缩放、旋转与组合手势
学习·华为·交互·harmonyos·鸿蒙
又见情义2 小时前
RK3568 Android 13 移植 EC20-CE 4G 模块全记录
android·arm开发·驱动开发
~kiss~2 小时前
Agent Memory System 之 Recent Advance
学习
艾莉丝努力练剑3 小时前
【AI大模型接入SDK】C++日志体系与spdlog封装的理论部分
开发语言·c++·ide·人工智能·学习·面试·trae
超爱西西鸭3 小时前
鸿蒙ArkTS文件管理:fileIo 文件读写与目录操作
学习·华为·harmonyos·鸿蒙