内存mmap实现原理.docVIP

  • 4
  • 0
  • 约3.6万字
  • 约 36页
  • 2017-07-06 发布于湖北
  • 举报
内存mmap实现原理

内存mmap实现原理内存mmap实现原理 谨以此文纪念过往的岁月。 结构体列表 1. struct rb_node_s 2 struct page 3. struct vm_area_struct 4. struct mm_struct 函数列表 do_mmap do_mmap2 红黑树结构 ? ???Linux内核从2.4.10开始,对虚拟区的组织不再采用AVL树,而是采用红黑树,这也是出于效率的考虑,虽然AVL树和红黑树很类似,但在插入和删除节点方面,采用红黑树的性能更好一些,下面对红黑树给予简单介绍。 ? ?一颗红黑树是具有以下特点的二叉树: (1)? ?每个节点着有颜色,或者为红,或者为黑 (2)? ?根节点为黑色 (3)? ? 如果一个节点为红色,那么它的子节点必须为黑色 (4)? ? 从一个节点到叶子节点上的所有路径都包含有相同的黑色节点数? ? 红黑树的结构在include/linux/rbtree.h中定义如下: typedef struct rb_node_s { ? ?? ?? ?struct rb_node_s * rb_parent; ? ?? ?? ?int rb_color; #define RB_RED? ?? ?? ? 0 #define RB_BLACK? ?? ???1 ? ?? ???struct rb_node_s * rb_right; ? ?? ???struct rb_node_s * rb_left; } rb_node_t; O(∩_∩)O~ struct page { ? ?? ?? ?unsigned long flags;? ?? ?? ?? ?/* Atomic flags, some possibly ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?* updated asynchronously */ ? ?? ?? ?atomic_t _count;? ?? ?? ? /* Usage count, see below. */ ? ?? ?? ?union { ? ?? ?? ?? ?? ?? ? atomic_t _mapcount;? ?/* Count of ptes mapped in mms, ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?* to show when page is mapped ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?* limit reverse map searches. ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?*/ ? ?? ?? ?? ?? ?? ? struct {? ?? ?? ?? ?? ?/* SLUB */ ? ?? ?? ?? ?? ?? ?? ?? ?? ? u16 inuse; ? ?? ?? ?? ?? ?? ?? ?? ?? ? u16 objects; ? ?? ?? ?? ?? ?? ? }; ? ?? ?? ?}; ? ?? ?? ?union { ? ?? ?? ?? ? struct { ? ?? ?? ?? ?? ?? ? unsigned long private;? ?? ?? ?? ?? ???/* Mapping-private opaque data: ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ???* usually used for buffer_heads ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?* if PagePrivate set; used for ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?* swp_entry_t if PageSwapCache; ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?* indicates order in the buddy ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?* system if PG_buddy is set. ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?*/ ? ?? ?? ?? ?? ?? ? stru

文档评论(0)

1亿VIP精品文档

相关文档