You are on page 1of 3

CS 354 - Machine Organization

Wednesday, October 5, 2016

Project p2 (6%) due 10 pm THIS Friday, October 7th

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

Copyright 2016 Jim Skrentny

CS 354 (F16): L13 - 1

Ordering Free Blocks by Address



0x_00

0x_08

0x_04 16/0

0x_10

0x_18

0x_20

0x0 0x_24 16/0 16/1

0x_28

0x_30

0x_38

0x_40

16/0 0x_04 0x_5C 16/0 16/1

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.

Copyright 2016 Jim Skrentny

CS 354 (F16): L13 - 2

Ordering Free Blocks by LIFO



0x_00

0x_08

0x_10

0x_18

0x_20

0x_24 16/0 0x_24 0x_5C 16/0 16/1

0x_28
16/0

0x_30

0x_38

0x_40

0x0 0x_04 16/0 16/1

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.

Copyright 2016 Jim Skrentny

CS 354 (F16): L13 - 3

You might also like