Linux驱动开发10——内核环形双向链表
2024-09-08 14:11:31
Linux内核环形双向链表本身不实现锁机制,需要驱动本身完成锁机制实现。
1.1、list_head结构体
#include <linux/list.h> struct list_head {
struct list_head *next;
struct list_head *prev;
}; list_head结构体本身只包含next和prev两个节点,实际使用时需要自定义结构体包含list_head结构体,如: struct user_struct
{
struct list_head list;
int flags; /* user own data */
};
1.2、初始化
INIT_LIST_HEAD(struct list_head *list_head);
或者
LIST_HEAD(struct list_head list_head);
1.3、操作函数
#include <linux/list.h> 在链表头添加链表节点
list_add(struct list_head *new, struct list_head *head); 在链表尾添加链表节点
list_add_tail(struct list_head *new, struct list_head *head); 删除链表节点
list_del(struct list_head *entry);
list_del_init(struct list_head *entry); 移动链表节点
list_move(struct list_head *entry, struct list_head *head);
list_move_tail(struct list_head *entry, struct list_head *head); 检查链表是否为空,如果为空,返回非零值
list_empty(list_move(struct list_head *head); 遍历链表
list_for_each(struct list_head *cursor, struct list_head *list);
最新文章
- python获取绝对路径
- Python安装mysql-python错误提示python setup.py egg_info
- Windows Store App 控件动画
- 用于json的 .ashx 小细节
- 我的android学习经历29
- JQuery POST请求乱码...
- Android+struts2+JSON方式的手机开发(Login)
- sql加强练习
- ios打包应用程序,生成ipa文件
- 给图片使用border-radius 图片会变成圆的。
- 2.css字体单位
- 【一天一道LeetCode】#117. Populating Next Right Pointers in Each Node II
- 解决Android编译时出现aapt.exe finished with non-zero exit value 1(第二篇)
- 使用ant编译zookeeper源码
- Git 简单入门(一)
- $(";";).append无反应
- logback框架之——日志分割所带来的潜在问题
- vue中父子组件之间的传值、非父子组件之间的传值
- PTA寒假二
- TensorFlow中的优化算法