Prevalloc nextalloc case 3 size getsizehdrpprevblkpbp

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: cant of these bits (the allocated bit) to indicate whether the block is allocated or free. For example, suppose we have an allocated block with a block size of 24 ( 0x18) bytes. Then its header would be 0x00000018 | 0x1 = 0x00000019. Similarly, a free block with a block size of 40 (0x28) bytes would have a header of 530 header block size CHAPTER 10. VIRTUAL MEMORY 31 3 21 0 malloc returns a pointer to the beginning of the payload 00a a = 1: allocated a = 0: free payload (allocated block only) The block size includes the header, payload, and any padding. padding (optional) Figure 10.37: Format of a simple heap block. 0x00000028 | 0x0 = 0x00000028. The header is followed by the payload that the application requested when it called malloc. The payload is followed by a chunk of unused padding that can be any size. There are a number of reasons for the padding. For example, the padding might be part of an allocator’s strategy for combating external fragmentation. Or it might be needed to satisfy the alignment requirement. Given the block format in Figure 10.37, we can organi...
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