A.1#【内存管理】——5 引导期内存分配器

在编译期静态初始化所有的内核内存结构体是不现实的,因为硬件配置有太多的排列。尽管只是建立基本的结构体,也是需要内存的,就是后边说的物理页分配器都需要内存初始化自己。但是物理页分配器是如何分配内存初始化自己的呢?

所以Boot Memory Allocator 登场了

To address this, a specialized allocator called the Boot Memory Allocator is used.
It is based on the most basic of allocators, a First Fit allocator, which uses a bitmap
to represent memory [Tan01] instead of linked lists of free blocks. If a bit is 1, the
page is allocated, and if the bit is 0, it is unallocated. To satisfy allocations of sizes
smaller than a page, the allocator records the Page Frame Number (PFN) of the
last allocation and the offset the allocation ended at. Subsequent small allocations
are merged together and stored on the same page.
The reader may ask why this allocator is not used for the running system. One
compelling reason is that, although the first fit allocator does not suffer badly from
fragmentation [JW98], memory frequently has to be linearly searched to satisfy
an allocation. Because this is examining bitmaps, it gets very expensive, especially
because the first fit algorithm tends to leave many small free blocks at the beginning
of physical memory that still get scanned for large allocations, thus making the
process very wasteful [WJNB95].
There are two very similar but distinct APIs for the allocator. One is for UMA
architectures listed in Table 5.1, and the other is for NUMA listed in Table 5.2. The
principal difference is that the NUMA API must be supplied with the node affected
by the operation, but, because the callers of these APIs exist in the architecturedependent layer, it is not a significant problem.
This chapter begins with a description of the structure that the allocator uses
to describe the physical memory available for each node. I then illustrate how the
limits of physical memory and the sizes of each zone are discovered before talking
about how the information is used to initialize the boot memory allocator structures.
The allocation and free routines are then discussed before finally talking about how
the boot memory allocator is retired
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值