Chinaunix首页 | 论坛 | 博客
  • 博客访问: 603367
  • 博文数量: 113
  • 博客积分: 2554
  • 博客等级: 少校
  • 技术积分: 1428
  • 用 户 组: 普通用户
  • 注册时间: 2011-12-21 19:53
文章分类

全部博文(113)

文章存档

2014年(1)

2013年(2)

2012年(94)

2011年(16)

分类: LINUX

2011-12-21 20:06:55

  1. Buddy系统的另一个核心函数,expand:当指定的order,low无页面可以分配的时候
  2. 从oredr为high的area分配,将high中一个页面组依次向低order的area拆分,一次一
  3. 半,直至order为low的那个area为止.如,我们要order为1的页面组,从order为3的开
  4. 始分配, 8=4+2+(2),(2)代表我们所要的页面组.
  5. static inline struct page * expand (zone_t *zone, struct page *page,
  6. unsigned long index, int low, int high, free_area_t * area)
  7. {
  8. //low :目标order high: 从此order的area分配
  9. //page: order为high 的页面组
  10. //index:page组在order为high的area中的位图索引
  11. unsigned long size = 1 << high;
  12. while (high > low) {//分解到low
  13. if (BAD_RANGE(zone,page))
  14. BUG();
  15. area--; //lower area
  16. high--; //lower order
  17. size >>= 1;//size 减半
  18. memlist_add_head(&(page)->list,&(area)->free_list);//将拆分的头一个组
  19. //入低级别的area
  20. MARK_USED(index, high, area);color=blue>//在此低级别的area中反转状态
  21. index += size;//低一个order的位图索引
  22. page += size; //留下同一对的后一个组分配给用户
  23. }
  24. if (BAD_RANGE(zone,page))
  25. BUG();
  26. return page;
  27. }
阅读(2639) | 评论(0) | 转发(1) |
0

上一篇:alloc_page

下一篇:rmqueue

给主人留下些什么吧!~~