![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
kernel
文章平均质量分 86
wd_miracle
这个作者很懒,什么都没留下…
展开
-
Linux 内存管理简介
struct page :描述的是一个物理页, 内存管理的最小单元, 只描述的是物理页面本身, 程序和系统运行,存在数据的换入换出, 因此page中的数据和page无本质的联系. 数据结构定义在 : include/linux/mm_types.h 主要内容: (1) 页面状态(page-flags.h); (2) 页的类型: a. page cache/anonymous page; b. page_pool used by ne..原创 2021-11-11 22:31:00 · 1170 阅读 · 0 评论 -
[kernel][technical points] likely & unlikely
一. 定义#define likely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1))#define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0))__builtin_constant_p(x) : int __builtin_constant_p (exp) [Built-in Function]...原创 2021-02-11 00:28:21 · 151 阅读 · 1 评论 -
内核锁机制
一. 原子操作 原子操作,就是代码执行不会在执行完毕前被任何其他任务或事件打断. 原子操作需要硬件的支持,因此是架构相关的, 它们都使用内嵌汇编语言实现,因为C语言并不能实现这样的操作. 内核原子操作的理解: a. 资源的使用情况计数, atomic_t的counter是int型的,可以记录资源的使用情况; b. 资源使用的互斥, 当 atomic_t的counter的取值情况...原创 2019-11-21 10:34:57 · 441 阅读 · 0 评论 -
用户空间接收uevent示例
#include <stdio.h>#include <errno.h>#include <stdbool.h>#include <string.h>#include <strings.h>#include <sys/socket.h>#include <sys/un.h>#include <u...原创 2019-04-29 08:21:34 · 1444 阅读 · 0 评论 -
内核container_of原理及应用
一. 原理container_of的作用是已知一个结构体的成员变量名(memmber),成员变量指针(ptr),结构体类型(type),来获取结构体的首地址。核心原理是,成员变量的地址减去成员变量相对于结构体起始地址的偏移量,获得结构体的首地址。#define container_of(ptr, type, member) ( \ { ...原创 2019-05-22 22:44:57 · 412 阅读 · 0 评论