017outlinel17 w6F PDF
017outlinel17 w6F PDF
017outlinel17 w6F PDF
Cache memory is much, much smaller than the address space of the processor.
Implications?
32-bit Address
24
bit 31
16
Using a random placement policy makes finding a block in the cache SLOW!
Why?
32-bit Address
24
bit 31
16
b bits
How many blocks of memory map to each set for a 32-bit AS with 256 sets? 1024?
Implications?
32-bit Address
24
bit 31
16
s bits
b bits
SET 0 (s bits)
TAG (t bits)
TAG
BLOCK OF MEMORY
SET 1
...
SET S-1 (size S = 2s)
TAG
BLOCK OF MEMORY
SET 0
V
TAG
BLOCK OF MEMORY
SET 1
V
...
SET 1023 = 210 - 1
V
TAG
BLOCK OF MEMORY
2. Line Matching
32-bit Address
24
bit 31
t bits
16
s bits
b bits
if no match
if match
Project p3
Directory Structure
p3 Directory
mem.c, mem.h, mem.o, Makefile
tests Subdirectory
align2.c, ..., Makefile, ..., testlist.txt, ...
Implicit Free List Structure
word (4 bytes) aligned NOT double word
singly linked list of free and allocd blocks NOT just free blocks
list_head global stores address of first block
block layout: next, size_status, payload, possibly padding
NOTE: size excludes header, status is 0 = free, 1 = allocd
For example: if payload is 1 character (1 byte)
size is 4 bytes = payload 1 byte + 3 bytes padding
block total is 12 bytes with header (next and size_status)
if free then size_status is 4, if allocated then size_status is 5 = size 4 + 1 for allocd
Operations
Mem_free() must verify pointer is to an allocated block (search required)
splitting adds blocks to linked list
coalescing removes 1 or 2 blocks from linked list
Debugging
develop code incrementally using our tests
see testlist.txt (if test fails - add Mem_dump() to our test code)
our tests are not exhaustive!
use printf within your mem.c
Use gdb to Find Segmentation Faults
make
gdb alloc
help
run
kill
where
frame...
list
print...
break...
quit