next up previous contents
Next: Brent's Implementation of First Up: Memory Management Previous: The BuddyMemoryManager

The Segregated Storage Allocator

This method combines the basic ideas of buddy system and the first fit algorithm. It does not have the buddy systems disadvantage of being wasteful of space when requests are for sizes which are not powers of two. In the combined systems k lists of available space are kept. The ith list contains all available blocks whose sizes are greater than A(i-1) and less than or equal to A(i), where A(0) is zero and A(i) is the total amount of space available. The remaining A(i)'s can be chosen in anyway so long as A(i) > A(i-1) for 0 < i <= k. The current choice is A(1) = 1 and A(i) = 2A(i-1). When a block of size b is requested, the first block from the list i+1 is taken where i is chosen so that A(i) >= b > A(i-1). If list i+1 is empty then the next list is searched and so on. Once the block of atleast b cells is found, b cells are used to meet the original request, the remaining are returned to the appropriate list. When the block is freed then the neighbours of the block are check to see if they are also free, if so then the blocks are combined into one big block and returned to the appropriate list.

Allocate(size) searches the lists for the avalability of memory and returns the pointer to the starting address. It also manages allocation of multiple block of memory from system. SplitBlock performs the splitting of blocks if the block found is too big (defined by MaxExtraSize). DeAllocate(void *space) free's the memory and returns it to the appropriate list. It also check for possible coalescing and calls CollapseBlock to collapse multiple adjacent free blocks into one to reduce fragmentation of memory.


next up previous contents
Next: Brent's Implementation of First Up: Memory Management Previous: The BuddyMemoryManager
Philip A. Wilsey
1/26/1998