next up previous contents
Next: The BuddyMemoryManager Up: Memory Management Previous: Memory Management

The GlobalMemoryManager

The GlobalMemoryManager is our implementation of the CustoMalloc algorithm. The algorithm is dsimple. Maintain a hash table (say HASHTABLESIZE equal to 1024) and each hash table entry contains a list of memory blocks of a particular size. Whenever the application requests memory, allocate EXTRABLOCKS (a big chunk of memory equal to EXTRABLOCKS*(SIZE + USERSIZE), where USERSIZE is the size of a block requested by the user and SIZE is the administrative space needed, probably 16 bytes is size and EXTRABLOCKS is the number of extra blocks to allocate with the one the user requested). The memory configuration is illustrated in Figure [*].


  
Figure: 16 Bytes of administrative space used by the Global Memory Mananger
\begin{figure}
\centerline{
\psfig {figure=figures/gMemMgr.ps,angle=270,width=4in,silent=}
}\end{figure}

The next ptr is needed so that we can chain memory blocks together to form a single linked list. The masterblock ptr is needed to chain the head blocks of the big chucks of memory that is allocated. For example, assume the application requests a block of size 40 bytes, then allocate a big block of size equal to 20 * (40 + 16 )bytes. Then chain the basic blocks (of size 40+16 bytes) together and put this list in the hash table and insert the head block of this 20 piece memory into a separate linked list, called the MasterList. So at the end of the simulation, we can walk the MasterList (and note not the hash table of lists) and delete the chunks we have allocated.


next up previous contents
Next: The BuddyMemoryManager Up: Memory Management Previous: Memory Management
Philip A. Wilsey
1/26/1998