previous | start | next

Memory Allocation Problem

The following problem concerns dynamic storage allocation.

Consider an allocator that uses an implicit free list. The layout of each allocated and free memory block is as follows:

               31                            2 1 0
                __________________________________
     Header    |    Block Size (bytes)      |     |
               |____________________________|_____|
               |                                  |
               |                                  |
               |                                  |
               |                                  |
               |                                  |
               |__________________________________|
     Footer    |    Block Size (bytes)      |     |
               |____________________________|_____|

        
     

Each memory block, either allocated or free, has a size that is a multiple of eight bytes. Thus, only the 29 higher order bits in the header and footer are needed to record block size, which includes the header and footer. The usage of the remaining 3 lower order bits is as follows:

Given the contents of the heap shown on the left, show the new contents of the heap (in the right table) after a call to free(0x600a010) is executed. Your answers should be given as hex values. Note that the address grows from bottom up. Assume that the allocator uses immediate coalescing, that is, adjacent free blocks are merged immediately each time a block is freed.

Address  
0x600a028 0x00000016
0x600a024 0x600b611c
0x600a020 0x600b512c
0x600a01c 0x00000016
0x600a018 0x00000011
0x600a014 0x600b511c
0x600a010 0x600b601c
0x600a00c 0x00000011
0x600a008 0x00000016
0x600a004 0x600b601c
0x600a000 0x600b511c
0x6009ffc 0x00000016
Address  
0x600a028
0x600a024 0x600b611c
0x600a020 0x600b512c
0x600a01c
0x600a018
0x600a014 0x600b511c
0x600a010 0x600b601c
0x600a00c
0x600a008
0x600a004 0x600b601c
0x600a000 0x600b511c
0x6009ffc


previous | start | next