There is no way for the collector to infer that the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ces: (1) when the heap is initialized, and (2) when mm malloc is unable to find a suitable fit. To maintain alignment, extend heap rounds up the requested size to the nearest multiple of 2 words (8 bytes), and then requests the additional heap space from the memory system (lines 7–9). The remainder of the extend heap function (lines 12–17) is somewhat subtle. The heap begins on a double-word aligned boundary, and every call to extend heap returns a block whose size is an integral number of double-words. Thus, every call to mem sbrk returns a double-word aligned chunk of memory immediately following the header of the epilogue block. This header becomes the header of the new free block (line 12), and the last word of the chunk becomes the new epilogue block header (line 14). Finally, in the likely case that the previous heap was terminated by a free block, we call the coalesce function to merge the two free blocks and return the block pointer of the merged blocks (line 17). 540 CHAPTER 10. VIRTUAL MEMORY code/vm/malloc.c 1 2 3 4 5...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online