diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-12-27 18:24:10 +0100 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-12-27 18:24:10 +0100 |
commit | ca5bcc5b4783b8380c05ca45b35690c045ba70f4 (patch) | |
tree | 7e9fa190819ff45a81a73f85bc033d02a65b6490 | |
parent | 2e2b93ebf70f1beec09ac1bb9d51ba06a45ffd8d (diff) |
Description extended
-rw-r--r-- | mm.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -7,6 +7,23 @@ * TL;DR: optimised boundary tags and splay tree of free blocks with eager * coalescing. * + * --=[ APPROACH TO THE PROBLEM ]=-- + * + * This is the list of steps I did in order to implement this solution: + * 1. Implemented implicit list of free and used blocks, made it work with + * simple first-fit policy. + * 2. Implemented doubly linked list and many policies of inserting and + * searching for the block. + * 3. Debuged allocator functions, optimised realloc. + * 4. Abstracted functions related to free block management. + * 5. Now, when I had a working allocator code I could just implement the + * interface for free block management with splay trees. It worked almost + * instantly after implementing. It made the code work 10 times faster. + * 6. Further micro optimisations. + * + * Along the way I've implement a lot of auxilary debug functions. I tried my + * best to keep the code as clean as possible. + * * --=[ MANAGING USED AND FREE BLOCK ]=-- * * Used blocks structure: @@ -658,11 +675,11 @@ static free_block_t *coalesce_prev(free_block_t *block) { static void coalesce_next(free_block_t *block) { if (is_next_free(block)) { free_block_t *next = next_block(block); + erase_fb(next); if (next == last) last = block; /* Can set PREVFREE to 0, because we coalesed with previous already */ make_free(block, get_size(block) + get_size(next), 0); - erase_fb(next); } } |