As you can see from the figure, we now have a big mess! Why? Simple, we forgot to coalesce the list. Although all of the memory is free, it is chopped up into pieces, thus appearing as a fragmented memory despite not being one. The solution is simple: go through the list and merge neighboring chunks; when finished, the heap will be whole again...
伙伴系统的 amazing point 在于,如果将 8kb 块释放,会检查 另一个 8kb 是否空闲,如果是,就合并,变成16kb 继续递归上溯下去!
良好 operation
因为很容易确定某个块的伙伴,这是固定的,可以写进 address 中!
4.3. 其他想法
上述所有想法都缺乏可扩展性 scaling,我们可以用复杂的 data structure 来换取性能
平衡二叉树 伸展树 偏序树
考虑到现代 OS 是多核的,通常运行 multi threads 的程序...所以会做出更多的工作
优化内村分配程序
5. 作业(模拟作业)
The program, malloc.py, lets you explore the behavior of a simple free-space allocator as described in the chapter. See the README for details of its basic operation.