In: Computer Science
A direct-mapped cache consists of 8 blocks. Byte-addressable
main memory contains 4K blocks of 8 bytes each. Access time for the
cache is 22ns, and the time required to fill a cache slot from main
memory is 300ns. (This time allows us to determine the block is
missing and bring it into cache.) Assume a request is always
started in parallel to both cache and to main memory(so if it is
not found in cache, we do not have to add this cache search time to
the memory access). If a block is missing from cache, the entire
block is brought into the cache and the access is restarted.
Initially, the cache is empty.
-Compute the hit rate for a program that loops 4 times from
locations 0x0 to 0x43 (address 0 hex to address 43 hex).
-Compute the effective access time for this program.
Compute the hit rate for a program that loops 4 times from
locations 0x0 to 0x43 (address 0 hex to address 43 hex)
.Answer:-----------
( 0x0 to 0x43 )16 = ( 0 to 67 )10
Block 0 of main memory (addresses 0 - 7) and Block 8 of main memory
(addresses 64 - 67) must share a cache block. The remaining blocks
are brought in and are not replaced. So for each access to Block 0,
there is one miss and 7 hits. For each access to Block 8, there is
one miss and 3 hits. The remaining blocks have one miss each, with
all other accesses being hits.
If we loop 4 times, we have:
Block 0: 4 misses, 28 hits
Block 1: 1 miss, 31 hits
Block 2: 1 miss, 31 hits
Block 3: 1 miss, 31 hits
Block 4: 1 miss, 31 hits
Block 5: 1 miss, 31 hits
Block 6: 1 miss, 31 hits
Block 7: 1 miss, 31 hits
Block 8: 4 misses, 12 hits
A total of 15 misses, 257 hits,
or a hit ratio of 257 / (15 + 257 ) = 94.49%.
Compute the effective access time for this program?
Answer:------
The effective access time is ==
==>.9449 (22ns) + .0551(300ns + 22ns)
==> 20.7878 + .0551 x 322
==> 20.7878 + 17.7422
==> 38.53 ns