Skip to content

Commit

Permalink
修改
Browse files Browse the repository at this point in the history
  • Loading branch information
arkingc committed Jun 20, 2018
1 parent 9f01abd commit 8c8012a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Binary file added interview/temp/pic/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions interview/temp/内存管理.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

为了避免这种情况,Linux内核中引入了伙伴算法(buddy system),把所有的空闲页框分组为11个块链表,每个块链表包含大小为1,2,4,8,16,32,64,128,256,512和1024个连续页框的页框块,最大可以申请1024个连续页框块,对应4MB大小的连续内存。每个页框块的第一个页框的物理地址是这块大小的整数倍

<div align="center"> <img src="pic/5.png"/> </div>

* 假设要申请256个页框的块,先从256个页框的链表中查找空闲块,如果没有,就去512个页框的链表中查找,找到了则将页框分为2个256个页框的块,一个分配给应用,一个移动到256个页框的链表中,如果512个页框的链表中没有空闲块,则继续从1024个页框的链表中查找
* 页框块在释放的时候,会主动将两个连续的页框快合并为一个较大的页框块

[伙伴分配器的一个极简实现](https://coolshell.cn/articles/10427.html)

<br>
<br>

Expand Down

0 comments on commit 8c8012a

Please sign in to comment.