Professional Documents
Culture Documents
Last Time
Placement Policy
Free Block - Too Much/Too Little
Coalescing Free Blocks
Footers
Today
Footers (from last time)
Explicit Free List (from last time)
Ordering Free Blocks by Address
Ordering Free Blocks by LIFO
Next Time
Read: B&O 9.1 & 9.2
Heap Caveats
Three Faces of Memory
0x_08
0x_04 16/0
0x_10
0x_18
0x_20
0x_28
0x_30
0x_38
0x_40
24/0 ...
head
p3
p7
p9
Freeing
If coalescing done:
Show the changes in the heap above resulting from: free(p7);
If coalescing NOT done:
Must link the freed block into the free list.
0x_04
0x_24
0x_94
16/0
16/0
24/0
160
16/0
24/0
header
pred
succ
footer
head
What changes are require to link a freed block into the free list above?
1.
2.
3.
4.
Allocating
FF only needs to search through free blocks.
Must unlink the allocated free block from free list.
0x_04
0x_24
0x_5C
0x_94
16/0
16/0
32/0
24/0
160
16/0
32/0
24/0
head
header
pred
succ
footer
What changes are require to unlink the 32 byte block from the free list above?
1.
2.
0x_08
0x_10
0x_18
0x_20
0x_28
16/0
0x_30
0x_38
0x_40
32/0 ...
head
p3
p7
p9
Freeing
If coalescing done:
Show the changes in the heap above resulting from: free(p7);
If coalescing NOT done:
Must link freed block to front of free list.
0x_24
0x_04
0x_94
16/0
16/0
24/0
160
16/0
24/0
header
pred
succ
footer
head
What changes are required to link a freed block into the free list above?
1.
2.
3.
4.
Allocating
FF also only needs to search through free blocks.
BUT
Must also unlink the allocated free block from free list.