Allocator Designs
This post explains how to implement heap allocators from scratch. It presents and discusses different allocator designs, including bump allocation, linked list allocation, and fixed-size block allocation. For each of the three designs, we will create a basic implementation that can be used for our kernel.
This blog is openly developed on GitHub. If you have any problems or questions, please open an issue there. You can also leave comments at the bottom. The complete source code for this post can be found in the post-11
branch.
Table of Contents
πIntroduction
πDesign Goals
πBump Allocator
πIdea
πImplementation
πGlobalAlloc
and Mutability
πA Locked
Wrapper Type
πImplementation for Locked<BumpAllocator>
πAddress Alignment
πDiscussion
πThe Drawback of a Bump Allocator
πSummary
πWhat's next?
With this post, we conclude our memory management implementation for now. Next, we will start exploring multitasking, starting with threads. In subsequent post we will then explore multiprocessing, processes, and cooperative multitasking in the form of async/await.