内核如何管理你的内存.docx

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
内核如何管理你的内存

 HYPERLINK "/gustavo/blog/post/how-the-kernel-manages-your-memory" How The Kernel Manages Your Memory 内核如何管理你的内存 After examining the? HYPERLINK "/gustavo/blog/post/anatomy-of-a-program-in-memory" virtual address layout?of a process, we turn to the kernel and its mechanisms for managing user memory. Here is gonzo again: 在上一篇关于一个进程的虚拟地址布局之后,是时候来看看内核和它管理用户内存的机制了。下面还是以上一篇提到到的gonzo为例: Linux processes are implemented in the kernel as instances of? HYPERLINK "http://lxr.linux.no/linux+v/include/linux/sched.h" \l "L1075" task_struct, the process descriptor. The? HYPERLINK "http://lxr.linux.no/linux+v/include/linux/sched.h" \l "L1129" mm?field in task_struct points to the?memory descriptor,? HYPERLINK "http://lxr.linux.no/linux+v/include/linux/mm_types.h" \l "L173" mm_struct, which is an executive summary of a program’s memory. It stores the start and end of memory segments as shown above, the? HYPERLINK "http://lxr.linux.no/linux+v/include/linux/mm_types.h" \l "L197" number?of physical memory pages used by the process (rss?stands for Resident Set Size), the HYPERLINK "http://lxr.linux.no/linux+v/include/linux/mm_types.h" \l "L206" ?amount?of virtual address space used, and other tidbits. Within the memory descriptor we also find the two work horses for managing program memory: the set of?virtual memory areas?and thepage tables. Gonzo’s memory areas are shown below: Linux的进程在kernel中是由task_struct来实现的。其中有一个mm域指向这个进程所使用的内存的描述符,mm_struct。它包含了如上所示的各个段的开始和结束的地址(使用的是unsigned long类型来表示),被这个进程所使用的物理内存页的个数,各种被使用到的虚拟地址空间(total_vm, shared_vm,...)和其它一些内容。从这个结构体中我们能看到两块主要的用来管理程序内存的成员:虚拟内存空间(vm_area_struct)和页表(pgd,这是一个平台相关的结构)。下图是Gonzo的虚拟内存的布局。 Each virtual memory area (VMA) is a contiguous range of virtual addresses; these areas never overlap. An instance of? HYPERLINK "http://lxr.linux.no/linux+v/include/linux/mm_types.h" \l "L99" vm_area_struct?fully describes a memory area, including its start and end addresses,? HYPERLINK "http://lxr.linux.no/linux+v2.6.28/inc

文档评论(0)

haihang2017 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档