This preview shows page 1. Sign up to view the full content.
Unformatted text preview: the type system, relying on the error-prone pointer casting and pointer arithmetic that is typical of low-level systems programming. While allocators do not require enormous amounts of code, they are subtle and unforgiving. Students familiar with higherlevel languages such as C++ or Java often hit a conceptual wall when they ﬁrst encounter this style of programming. To help you clear this hurdle, we will work through the implementation of a simple allocator based on an implicit free list with immediate boundary-tag coalescing. General Allocator Design
Our allocator uses a model of the memory system provided by the memlib.c package shown in Figure 10.43. The purpose of the model is to allow us to run our allocator without interfering with the existing system-level malloc package. The mem init function models the virtual memory available to the heap as a large, double-word aligned array of bytes. The bytes between mem start brk and mem brk represent allocated virtual memory. The bytes following mem brk represent unallocated virtual memory. The allocator requests additional heap memory by calling the mem sbrk function, which has the same interface as the system’s sbrk function, and the...
View Full Document
- Spring '10
- The American