Malloc Lab
(Dynamic Storage Allocators)
07300720035 电子信息科学与技术 王泮渠
(Department of Electrical Engineering, Chris Wang)
2010.01.02
INTRODUCTION
In this lab you will be writing a dynamic storage allocator for C program,i.e.,your own version of the malloc, free and realloc routines. You are encouraged to explore the design space creatively and implement an allocator that is correct, efficient and fast.
PREPARATIONS
Read the introduction of malloc_lab carefully and think about it in depth. It shows us how to on the program, how to check our syntax and grammars, and how to evaluate our performance and find how to improve it.
The text book CSAPP is always your best instructor and helper. It provide with an original version of Implicit Free List. Although its performance is relatively low, it shows the basic program structure and algorithm about dynamic memory allocators. Also, we can get familiar with all functions, libraries, pointers and variables used in the gigantic program.
We should cautiously select our algorithm and data structure used in the program to meet with the request and evaluation system of malloc_lab. The most important, our program must be run on the server successfully, smoothly and efficiently without any errors, bugs or leaks.
ABOUT MY PROGRAM
DATA STRUCTURE
As mentioned above, the original version of implicit free list introduced in the text book is a good gateway program, but it can be only the gateway, cannot be the summit. As we all know, although implicit free list is simple, a significant disadvantage is that the cost of any operation, such as placing allocated blocks, that requires a search of the free list will be linear in the total number of allocated free blocks in the heap. As a result, implicit free list is not appropriate for a general-purpose allocator.
So I turned to the Explicit Free List. Since by definition the body of a free block is not needed by the program, the pointers that