【Linux 内核 内存管理】虚拟地址空间布局架构 ③ ( 内存描述符 mm_struct 结构体成员分析 | mmap | mm_rb | task_size | pgd | mm_users )
文章目录
- 一、mm_struct 结构体成员分析
- 1、mmap 成员
- 2、mm_rb 成员
- 3、get_unmapped_area 函数指针
- 4、task_size 成员
- 5、pgd 成员
- 6、mm_users 成员
- 7、mm_count 成员
一、mm_struct 结构体成员分析
mm_struct 结构体 在 Linux 源码 linux-4.12\include\linux\mm_types.h#359 位置 ;
参考 【Linux 内核 内存管理】虚拟地址空间布局架构 ② ( 用户虚拟地址空间组成 | 内存描述符 mm_struct 结构体源码 ) 博客 ;
下面开始分析 mm_struct 结构体 的重要 成员 ;
1、mmap 成员
struct vm_area_struct *mmap , 表示 虚拟内存区域 的 " 链表 " 数据结构 ;
struct vm_area_struct *mmap; /* list of VMAs */2、mm_rb 成员
struct rb_root mm_rb , 表示 虚拟内存区域 的 " 红黑树 " 数据结构 ;
struct rb_root mm_rb;3、get_unmapped_area 函数指针
get_unmapped_area 函数指针 , 该函数表示 在 " 内存映射区域 " 找到 " 未被映射区 " ;
#ifdef CONFIG_MMUunsigned long (*get_unmapped_area) (struct file *filp,unsigned long addr, unsigned long len,unsigned long pgoff, unsigned long flags); #endif4、task_size 成员
unsigned long task_size , 表示 " 用户虚拟地址空间 " 大小 ;
unsigned long task_size; /* size of task vm space */5、pgd 成员
pgd_t * pgd , 该指针指向 " 内存页 " 全局目录 , 第一级的页表 ;
pgd_t * pgd;6、mm_users 成员
atomic_t mm_users , 表示有多少个 " 进程 " 共享 " 用户虚拟地址空间 " , 即 线程组 的 进程 数量 ;
/*** @mm_users: The number of users including userspace.** Use mmget()/mmget_not_zero()/mmput() to modify. When this drops* to 0 (i.e. when the task exits and there are no other temporary* reference holders), we also release a reference on @mm_count* (which may then free the &struct mm_struct if @mm_count also* drops to 0).*/atomic_t mm_users;7、mm_count 成员
atomic_t mm_count , 表示 内存描述符 引用计数 ;
/*** @mm_count: The number of references to &struct mm_struct* (@mm_users count as 1).** Use mmgrab()/mmdrop() to modify. When this drops to 0, the* &struct mm_struct is freed.*/atomic_t mm_count;总结
以上是生活随笔为你收集整理的【Linux 内核 内存管理】虚拟地址空间布局架构 ③ ( 内存描述符 mm_struct 结构体成员分析 | mmap | mm_rb | task_size | pgd | mm_users )的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 【Linux 内核 内存管理】虚拟地址空
- 下一篇: Linux-鸟菜-0-计算机概论