Memory Management in Computer Architecture
Memory Management in Computer Architecture
1.- (5.3 Patterson 2011) The following table shows a list of 32-bit memory address references:
a.- 1, 134, 212, 1, 135, 213, 162, 161, 2, 44, 41, 221
b.- 6, 214, 175, 214, 6, 84, 65, 174, 64, 105, 85, 215
1.1. Given a direct-mapped cache with 16 blocks of a single word, indicate for each
one of the references, the binary address, the tag, and the index. Also indicate whether it is a fault or a
Correct, assuming that the cache is initially empty.
Solution:
1.2. Given a direct-mapped cache with 8 blocks of 2 words, indicate for each of the
references, the binary address, the label, and the index. Also indicate if it is a failure or a success,
assuming that the cache is initially empty.
Label block Word
1.3. Be a direct mapping cache with a capacity of 8 words with a main memory
addressed with 32 bits. Optimize your design for the previous references. Consider three possible
cache designs: C1 with one-word blocks, C2 with two-word blocks, and C3 with blocks
of 4 words. Which one is the best in terms of failure frequency? If the failure stop is 25
C1 has an access time of 2 cycles, C2 of 3 cycles, and C3 of 5 cycles. Which is the best?
design?
___________________________________________________________________
with blocks of one word
Label block Word
a)
Miss hit
penalization
C1 25 cycles 2 cycles
C2 25 cycles 3 cycles
C4 25 cycles 5 cycles
2.3 What is the relationship between the total number of bits in the cache and the number of storage bits?
Data/cache ratio=128/141=0.907
90.7% of the cache stores data, while the other 9.3% stores tags and control.
4. It is a cache memory that stores 2048 words organized in 2 sets of blocks of 4 words. If
the main memory has a size of 128K x 32 bits. Indicate how the cache information is stored, and
What is the total size of the cache.
Solution:
In MC 2048 words / 4 words/block = 29bloques = 211words in MC
17 bits address MP, 14 tag field, 1 set field bit, and 2 word field bits
M Cache M Principal
Set 0 Block 0 Block 2 … Block 215-2
Of 256 blocks
Set 1 Block 1 Block 3 … Block 215-1
Of 256 blocks
5. Let there be a main memory of 64Kx16 bits, and a cache memory with direct mapping of 1K words.
If the block size is 4 words, indicate the format of the main memory addresses, and the
number of bits (and their function) in each cache entry.
Solution:
MP => 64K = 21616-bit words; 16-bit addresses; blocks in MP =216/4=214blocks
Cache Blocks 210/4=28
0000 00 00 0000 00 00
7. Using the reference chain from exercise 6, show the hits and misses and the final content of the cache.
direct correspondence with blocks of four words and a total size of 16 words.
M Cache
Ref Label [Link].
1 0000 0000 0000 0000 001
4 0000 0000 0000 0000 100 block Label Word
8 0000 0000 0000 0001 000 selected
5 0000 0000 0000 0000 101Hit 00 0000 0000 0000 000 000110 11
20 0000 0000 0000 0010 100 0000 0000 0000 001 00011011
17 0000 0000 0000 0010 001 01 0000 0000 0000 000 00 0110 11
19 0000 0000 0000 0010 011Hit 0000 0000 0000 001 0001 10 11
56 0000 0000 0000 0111 000 0000 0000 0000 000 00 01 1011
9 0000 0000 0000 0001 001 10 0000 0000 0000 000 0001 10 11
11 0000 0000 0000 0001 011Hit 0000 0000 0000 011 0001 10 11
4 0000 0000 0000 0000 100 0000 0000 0000 000 00011011
43 0000 0000 0000 0101 011 0000 0000 0000 010 00 01 1011
5 0000 0000 0000 0000 101Hit 0000 0000 0000 000 000110 11
6 0000 0000 0000 0000 110Hit 11
9 0000 0000 0000 0001 001
17 0000 0000 0000 0010 001Hit
Success rate=6/16
8. Using the reference string from exercise 6, show the hits and misses and the final content of the cache
for a two-block set associative cache of one word and a total size of 16 words.
Assuming LRU replacement policy.
Total number of sets = 16 blocks of one word / 2 blocks per set = 8 sets three bits to index the set
Ref Label Set M Cache
1 0000 0000 0000 0000001
4 0000 0000 0000 0000100 Conj. Label block1 Block2 label
8 0000 0000 0000 0001000 000 0000 0000 0000 0001 0000 0000 0000 0111
5 0000 0000 0000 0000101 001 0000 0000 0000 0000 0000 0000 0000 0010
20 0000 0000 0000 0010100 0000 0000 0000 0001
17 0000 0000 0000 0010001 010
19 0000 0000 0000 0010011 011 0000 0000 0000 0010 0000 0000 0000 0001
56 0000 0000 0000 0111000 0000 0000 0000 0101
9 0000 0000 0000 0001001 100 0000 0000 0000 0000 0000 0000 0000 0010
11 0000 0000 0000 0001011 101 0000 0000 0000 0000
4 0000 0000 0000 0000100 hit 110 0000 0000 0000 0000
43 0000 0000 0000 0101011 111
5 0000 0000 0000 0000101hit
6 0000 0000 0000 0000110
9 0000 0000 0000 0001001hit
17 0000 0000 0000 0010001
9. Using the reference chain from exercise 6, show the hits and misses and the final content of the cache.
for a fully associative cache with word-sized blocks and a total size of 16 words. Assume
LRU replacement.
10. Using the reference chain from exercise 6, show the hits and misses and the final content of the cache.
for a fully associative cache with blocks of four words and a total size of 16 words.
Assume LRU replacement.
11. A single-processor computer with a main memory of 1M word has a cache memory of
direct correspondence of 4K words with blocks of 16 words. Assuming that the cache memory is
initially empty, indicate the number of cache misses that occur if the processor generates the
memory access sequence:
ABC13h, CDC14h, ABC1Fh, AB305h, ABC14h, CDC1Fh, AB306h, CAC13h, CDC1Ah, CA00h, CAC1Fh.
For that same sequence, indicate the cache block frames in which each position is loaded.
main memory to which it is intended to access.
12. Consider a virtual memory system with a 40-bit virtual address, 16KB pages, and address
36-bit physics. What is the total size of the page table for each process of this machine?
assuming that the validity, protection, occupation, and use bits require a total of 4 bits and that they are used
all virtual pages? Assuming that the disk addresses are not stored in the page table.
13. Cache C1 is direct-mapped with 16 one-word blocks. Cache C2 is direct-mapped
directly with 4 blocks of four words. Assume that the penalty for failures for C1 is 8 clock cycles
and for C2 it is 11 clock cycles. Assuming that the caches are initially empty, find a chain
for reference so that C2 has a lower failure rate but uses more cycles in cache failures than
C1. Use word addresses.
14. Consider three machines with different cache configurations and different failure rate measurements:
Cache 1: Direct correspondence with single word blocks. The instruction failure rate is 4.
for 100 and the data failure rate of 8 percent. The clock period is 10 ns.
[Link] 2: Direct correspondence with blocks of four words. The instruction failure rate is
of 2 percent and the data failure rate of 4 percent. The clock frequency is 10 ns.
[Link] 3: Two-way set associative with four-word blocks. The failure rate of
Instructions are at 2 percent and the data failure rate is at 4 percent. The clock frequency is 12 ns.
For these machines, half of the instructions contain a data reference. Assume that the penalty
Cache misses is 6+Block size. The CPI for this workload was measured on a machine with
cache 1 and found it was 2.0. Determine which machine uses more cycles on cache misses. Determine
Which machine is faster and which is slower.
Solution:
Cache 1
Penalty decision=6+1 cycles=7 cycles
For every N instructions with their N/2 data references, the following penalties are incurred.
Penalty cycles mem = N * (0.04*7 + 0.08*7*0.5) = 0.56 * N 56% of the execution time is spent on
memory accesses
Cache2
Penalty cycles = 7 + 4 = 11
Penalty cycles = N * (0.02 + 0.04 * 0.5) * 11 = 0.44N
CPI=1.44+0.44=1.88
Execution time2 = 1.88 * N * 10ns = 18.8 N ns the fastest
Cache3
Penalty cycles = 7 + 4 = 11
Penalty cycles = N*(0.02 + 0.04*0.5)*11 = 0.44N
CPI=1.44+0.44=1.88
Execution time2 = 1.88 * N * 12ns = 22.56 N ns