18 内核开发-内核重点数据结构学习

课程简介:
Linux内核开发入门是一门旨在帮助学习者从最基本的知识开始学习Linux内核开发的入门课程。该课程旨在为对Linux内核开发感兴趣的初学者提供一个扎实的基础,让他们能够理解和参与到Linux内核的开发过程中。

课程特点:
1. 入门级别:该课程专注于为初学者提供Linux内核开发的入门知识。无论你是否具有编程或操作系统的背景,该课程都将从最基本的概念和技术开始,逐步引导学习者深入了解Linux内核开发的核心原理。

2. 系统化学习:课程内容经过系统化的安排,涵盖了Linux内核的基础知识、内核模块编程、设备驱动程序开发等关键主题。学习者将逐步了解Linux内核的结构、功能和工作原理,并学习如何编写和调试内核模块和设备驱动程序。

3. 实践导向:该课程强调实践,通过丰富的实例和编程练习,帮助学习者将理论知识应用到实际的Linux内核开发中。学习者将有机会编写简单的内核模块和设备驱动程序,并通过实际的测试和调试来加深对Linux内核开发的理解。

4. 配套资源:为了帮助学习者更好地掌握课程内容,该课程提供了丰富的配套资源,包括教学文档、示例代码、实验指导和参考资料等。学习者可以根据自己的学习进度和需求,灵活地利用这些资源进行学习和实践。

无论你是计算机科学专业的学生、软件工程师还是对Linux内核开发感兴趣的爱好者,Linux内核开发入门课程都将为你提供一个扎实的学习平台,帮助你掌握Linux内核开发的基础知识,为进一步深入研究和应用Linux内核打下坚实的基础。

这一讲,主要分享内核中的重点数据结构,并且以脑图的形式进行整理,后面如果有其他内核数据结构,会一同整理到这里。主要介绍内核中使用的4大数据结构:链表,队列,映射,二叉树。

以下是脑图主要内容。

需要脑图文件的可以私信或者评论留言,可以免费同步给你。文章后再贴下 list.h kfifo.h 相关文件定义

LXR linux/include/linux/klist.h 

  1/*2 *      klist.h - Some generic list helpers, extending struct list_head a bit.3 *4 *      Implementations are found in lib/klist.c5 *6 *7 *      Copyright (C) 2005 Patrick Mochel8 *9 *      This file is rleased under the GPL v2.10 */1112#ifndef _LINUX_KLIST_H13#define _LINUX_KLIST_H1415#include <linux/spinlock.h>16#include <linux/completion.h>17#include <linux/kref.h>18#include <linux/list.h>1920struct klist_node;21struct klist {22        spinlock_t              k_lock;23        struct list_head        k_list;24        void                    (*get)(struct klist_node *);25        void                    (*put)(struct klist_node *);26};272829extern void klist_init(struct klist * k, void (*get)(struct klist_node *),30                       void (*put)(struct klist_node *));3132struct klist_node {33        struct klist            * n_klist;34        struct list_head        n_node;35        struct kref             n_ref;36        struct completion       n_removed;37};3839extern void klist_add_tail(struct klist_node * n, struct klist * k);40extern void klist_add_head(struct klist_node * n, struct klist * k);4142extern void klist_del(struct klist_node * n);43extern void klist_remove(struct klist_node * n);4445extern int klist_node_attached(struct klist_node * n);464748struct klist_iter {49        struct klist            * i_klist;50        struct list_head        * i_head;51        struct klist_node       * i_cur;52};535455extern void klist_iter_init(struct klist * k, struct klist_iter * i);56extern void klist_iter_init_node(struct klist * k, struct klist_iter * i, 57                                 struct klist_node * n);58extern void klist_iter_exit(struct klist_iter * i);59extern struct klist_node * klist_next(struct klist_iter * i);6061#endif62

The original LXR software by the LXR community, this experimental version by lxr@linux.no.

LXR linux/include/linux/kfifo.h 

  1/*2 * A simple kernel FIFO implementation.3 *4 * Copyright (C) 2004 Stelian Pop <stelian@popies.net>5 *6 * This program is free software; you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation; either version 2 of the License, or9 * (at your option) any later version.10 *11 * This program is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the14 * GNU General Public License for more details.15 *16 * You should have received a copy of the GNU General Public License17 * along with this program; if not, write to the Free Software18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.19 *20 */21#ifndef _LINUX_KFIFO_H22#define _LINUX_KFIFO_H2324#ifdef __KERNEL__2526#include <linux/kernel.h>27#include <linux/spinlock.h>2829struct kfifo {30        unsigned char *buffer;  /* the buffer holding the data */31        unsigned int size;      /* the size of the allocated buffer */32        unsigned int in;        /* data is added at offset (in % size) */33        unsigned int out;       /* data is extracted from off. (out % size) */34        spinlock_t *lock;       /* protects concurrent modifications */35};3637extern struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,38                                gfp_t gfp_mask, spinlock_t *lock);39extern struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask,40                                 spinlock_t *lock);41extern void kfifo_free(struct kfifo *fifo);42extern unsigned int __kfifo_put(struct kfifo *fifo,43                                unsigned char *buffer, unsigned int len);44extern unsigned int __kfifo_get(struct kfifo *fifo,45                                unsigned char *buffer, unsigned int len);4647/**48 * __kfifo_reset - removes the entire FIFO contents, no locking version49 * @fifo: the fifo to be emptied.50 */51static inline void __kfifo_reset(struct kfifo *fifo)52{53        fifo->in = fifo->out = 0;54}5556/**57 * kfifo_reset - removes the entire FIFO contents58 * @fifo: the fifo to be emptied.59 */60static inline void kfifo_reset(struct kfifo *fifo)61{62        unsigned long flags;6364        spin_lock_irqsave(fifo->lock, flags);6566        __kfifo_reset(fifo);6768        spin_unlock_irqrestore(fifo->lock, flags);69}7071/**72 * kfifo_put - puts some data into the FIFO73 * @fifo: the fifo to be used.74 * @buffer: the data to be added.75 * @len: the length of the data to be added.76 *77 * This function copies at most 'len' bytes from the 'buffer' into78 * the FIFO depending on the free space, and returns the number of79 * bytes copied.80 */81static inline unsigned int kfifo_put(struct kfifo *fifo,82                                     unsigned char *buffer, unsigned int len)83{84        unsigned long flags;85        unsigned int ret;8687        spin_lock_irqsave(fifo->lock, flags);8889        ret = __kfifo_put(fifo, buffer, len);9091        spin_unlock_irqrestore(fifo->lock, flags);9293        return ret;94}9596/**97 * kfifo_get - gets some data from the FIFO98 * @fifo: the fifo to be used.99 * @buffer: where the data must be copied.100 * @len: the size of the destination buffer.101 *102 * This function copies at most 'len' bytes from the FIFO into the103 * 'buffer' and returns the number of copied bytes.104 */105static inline unsigned int kfifo_get(struct kfifo *fifo,106                                     unsigned char *buffer, unsigned int len)107{108        unsigned long flags;109        unsigned int ret;110111        spin_lock_irqsave(fifo->lock, flags);112113        ret = __kfifo_get(fifo, buffer, len);114115        /*116         * optimization: if the FIFO is empty, set the indices to 0117         * so we don't wrap the next time118         */119        if (fifo->in == fifo->out)120                fifo->in = fifo->out = 0;121122        spin_unlock_irqrestore(fifo->lock, flags);123124        return ret;125}126127/**128 * __kfifo_len - returns the number of bytes available in the FIFO, no locking version129 * @fifo: the fifo to be used.130 */131static inline unsigned int __kfifo_len(struct kfifo *fifo)132{133        return fifo->in - fifo->out;134}135136/**137 * kfifo_len - returns the number of bytes available in the FIFO138 * @fifo: the fifo to be used.139 */140static inline unsigned int kfifo_len(struct kfifo *fifo)141{142        unsigned long flags;143        unsigned int ret;144145        spin_lock_irqsave(fifo->lock, flags);146147        ret = __kfifo_len(fifo);148149        spin_unlock_irqrestore(fifo->lock, flags);150151        return ret;152}153154#else155#warning "don't include kernel headers in userspace"156#endif /* __KERNEL__ */157#endif158

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/3016582.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

Qt---day2-信号与槽

1、思维导图 2、 拖拽式 源文件 #include "mywidget.h" #include "ui_mywidget.h" MyWidget::MyWidget(QWidget *parent) : QWidget(parent) , ui(new Ui::MyWidget) { ui->setupUi(this); //按钮2 this->btn2new QPushButton("按钮2",th…

什么是多模态大模型,有了大模型,为什么还要多模态大模型?

随着人工智能技术的愈演愈烈&#xff0c;其技术可以说是日新月异&#xff0c;每隔一段时间就会有新的技术和理念被创造出来&#xff1b;而多模态大模型也是其中之一。 什么是多模态 想弄明白什么是多模态大模型&#xff0c;那么首先就要弄明白什么是多模态。 简单来说&#x…

【Git】Commit后进行事务回滚

起因 因为一直使用git add .&#xff0c;在学习pytorch中添加了一个较大的数据集后&#xff0c;导致git push失败&#xff0c;而这个大数据集并不是必须要上传到仓库的&#xff0c;但是因为自己在设置.gitignore前已经进行了git comit&#xff0c;所以&#xff0c;需要进行事务…

嵌入式linux学习第三天汇编语言点灯

嵌入式linux学习第三天汇编语言点灯 今天学习如何在linux板子上点灯。 I.MX6U GPIO 详解 我们发现I.MX6U GPIO是分为两类的&#xff0c;&#xff1a;SNVS 域的和通用的。在讨论i.MX6U或类似的复杂微处理器时&#xff0c;了解其GPIO&#xff08;通用输入输出&#xff09;引脚…

Windows环境编译 VVenC 源码生成 Visual Studio 工程

VVenC介绍 Fraunhofer通用视频编码器(VVenC)的开发是为了提供一种公开可用的、快速和有效的VVC编码器实现。VVenC软件基于VTM&#xff0c;其优化包括软件重新设计以减轻性能瓶颈、广泛的SIMD优化、改进的编码器搜索算法和基本的多线程支持以利用并行。此外&#xff0c;VVenC支…

深度学习之基于YOLOv5目标检测可视化系统

欢迎大家点赞、收藏、关注、评论啦 &#xff0c;由于篇幅有限&#xff0c;只展示了部分核心代码。 文章目录 一项目简介 二、功能三、系统四. 总结 一项目简介 一、项目背景与意义 随着深度学习技术的快速发展&#xff0c;目标检测在多个领域中的应用日益广泛&#xff0c;包括…

125.两两交换链表中的节点(力扣)

题目描述 代码解决及思路 /*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode() : val(0), next(nullptr) {}* ListNode(int x) : val(x), next(nullptr) {}* ListNode(int x, ListNode *next) : val(x), …

很快就可以试用Domino 15了

大家好&#xff0c;才是真的好。 前几天在比利时的安普卫特举办的Engage2024大会已经结束&#xff0c;流出的现场照片很多&#xff0c;主要是会议场地照片很多&#xff0c;说是令人震撼&#xff1b;可惜这次一手的PPT和会议内容不多.是的&#xff0c;本来我也是在等与会者写的…

VMware 虚拟机打开一段时间后卡死,VNX进程CPU占比高

一、问题描述 打开虚拟机后可以正常运行 运行几分钟后突然卡死 然后通过任务管理器可以观察到VMware Workstation VMX应用进程的CPU占比高&#xff0c;CPU也出现异常 关闭虚拟机重新开启&#xff0c;还是一样卡死 二、系统环境 系统: Windows10 VMware: Workstation 17 Pro …

如何提取视频二维码链接?二维码在线提取链接的方法

随着现在二维码用途的不断增多&#xff0c;很多不同的内容都可以生成二维码来展示&#xff0c;比如现在视频二维码就是比较常见的一种类型&#xff0c;一般用于产品介绍、教程演示、宣传推广等等。二维码的方式在某些情况下也有局限性&#xff0c;当无法扫码时就无法查看内容&a…

Linux信号捕捉

要处理信号&#xff0c; 我们进程就得知道自己是否收到了信号&#xff0c; 收到了哪些信号&#xff0c; 所以进程需要再合适的时候去查一查自己的pending位图 block 位图 和 hander表&#xff0c; 什么时候进行检测呢&#xff1f; 当我们的进程从内核态返回到用户态的时候&…

荷香堪筑梦,鸳鸯和月寻。(变相BFS搜索)

本题链接&#xff1a;登录—专业IT笔试面试备考平台_牛客网 题目&#xff1a; 样例&#xff1a; 输入 3 4 2 .... ***. ..a. 输出 yes 思路&#xff1a; 根据题意&#xff0c;这里 1 s 可以移动多次&#xff0c;我们将每次可以移动避开雪的的位置存储起来&#xff0c;判断当…

springboot3常用注解使用

组键注册注解 组件注册步骤总结 条件注解 演示示例 属性绑定注解 ConfigurationProperties进行绑定 EnableConfigurationProperties进行绑定 其他常用注解 EnableAutoConfiguration ComponentScan RequestMapping GetMapping PostMapping Autowired Resource Servi…

js浏览器请求,post请求中的参数形式和form-data提交数据时数据格式问题(2024-05-06)

浏览器几种常见的post请求方式 Content-Type 属性规定在发送到服务器之前应该如何对表单数据进行编码。 默认表单数据会编码为 "application/x-www-form-urlencoded" post请求的参数一般放在Body里。 Content-Type&#xff08;内容类型&#xff09;&#xff0c;一般…

25-ESP32-S3 内置的真随机数发生器(RNG)

ESP32-S3 内置的真随机数发生器&#xff08;RNG&#xff09;&#x1f60e; 引言 &#x1f4da; 在许多应用中&#xff0c;随机数发生器&#xff08;RNG&#xff09;是必不可少的。无论是在密码学&#x1f512;、游戏&#x1f3ae;、模拟&#x1f9ea;或其他领域&#xff0c;随…

【第6节课笔记】LagentAgentLego

Lagent 最中间部分的是LLM&#xff0c;即为大语言模型模块&#xff0c;他可以思考planning和调用什么action&#xff0c;再将其转发给动作执行器action executer执行。 支持的工具如下&#xff1a; Arxiv 搜索 Bing 地图 Google 学术搜索 Google 搜索 交互式 IPython 解释器 IP…

6.Nginx

Nginx反向代理 将前端发送的动态请求有Nginx转发到后端服务器 那为何要多一步转发而不直接发送到后端呢&#xff1f; 反向代理的好处&#xff1a; 提高访问速度&#xff08;可以在nginx做缓存&#xff0c;如果请求的是同样的接口地址&#xff0c;这样就不用多次请求后端&#…

【数据结构】C/C++ 带头双向循环链表保姆级教程(图例详解!!)

目录 一、前言 二、链表的分类 &#x1f95d;单链表 &#x1f95d;双链表 &#x1f95d;循环链表 &#x1f95d;带头双向循环链表 &#x1f34d;头节点&#xff08;哨兵位&#xff09;的作用 ✨定义&#xff1a; ✨作用&#xff1a; &#x1f347;总结 三、带头双向循环链表 …

一键解密,网络安全神器现已问世!

一、简介 当前版本V1.1这款工具是一款功能强大的网络安全综合工具&#xff0c;旨在为安全从业者、红蓝对抗人员和网络安全爱好者提供全面的网络安全解决方案。它集成了多种实用功能&#xff0c;包括解密、分析、扫描、溯源等&#xff0c;为用户提供了便捷的操作界面和丰富的功…

Python Dash库:一个Web应用只需几行代码

大家好&#xff0c;在数据科学领域&#xff0c;数据可视化是将数据以图形化形式展示出来&#xff0c;帮助我们更直观地理解数据。Python中有一个非常流行的数据可视化库叫做Dash&#xff0c;Dash以其简洁、高效和强大的功能而闻名&#xff0c;它允许开发者快速构建交互式Web应用…