【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 内核 内存管理】虚拟地址空
- 下一篇: visual studio 汇编 创建