A system has a level 1 cache and a level 2 cache. The hit rate of the level 1 cache is 90% and the hit rate of the level 2 cache is 80%. An access to level 1 cache requires 1 cycle, an access to level 2 cache requires 4 cycles, and an access to main memory requires 50 cycles. What is the average access time? (A) 1.32 (B) 2.22 (C) 5.26 (D) 19.32

Engineering · College · Tue Nov 03 2020

Answered on

To calculate the average access time for a hierarchical memory system with multiple levels of caches, we need to consider the hit rates and access times for each cache level as well as the access time to the main memory. For each memory access, the following steps are taken:

1. First, the system checks if the data is in the level 1 (L1) cache. 2. If the L1 cache misses (the data is not there), then the system checks the level 2 (L2) cache. 3. If the L2 cache also misses, then the system has to access the main memory to retrieve the data.

We are given: - L1 cache hit rate = 90% or 0.9 - L2 cache hit rate = 80% or 0.8 - L1 cache access time = 1 cycle - L2 cache access time = 4 cycles (including the time already spent checking the L1 cache) - Main memory access time = 50 cycles (including the time already spent checking both the L1 and L2 caches)

The average access time (AAT) can be calculated using the formula: \[ AAT = (Hit Rate_{L1} \times Access Time_{L1}) + (Miss Rate_{L1} \times Hit Rate_{L2} \times Access Time_{L2}) + (Miss Rate_{L1} \times Miss Rate_{L2} \times Access Time_{MM}) \]

Where: - \( Hit Rate_{L1} \) = 0.9 - \( Access Time_{L1} \) = 1 cycle - \( Miss Rate_{L1} \) = 1 - \( Hit Rate_{L1} \) = 0.1 - \( Hit Rate_{L2} \) = 0.8 - \( Access Time_{L2} \) = 4 cycles - \( Miss Rate_{L2} \) = 1 - \( Hit Rate_{L2} \) = 0.2 - \( Access Time_{MM} \) = 50 cycles

Now we substitute these values into the formula:

\[ AAT = (0.9 \times 1) + (0.1 \times 0.8 \times 4) + (0.1 \times 0.2 \times 50) \] \[ AAT = (0.9 \times 1) + (0.08 \times 4) + (0.02 \times 50) \] \[ AAT = 0.9 + 0.32 + 1 \] \[ AAT = 2.22 \]

So the correct answer is (B) 2.22 cycles.

Extra: Cache memory is a smaller, faster type of volatile computer memory that provides high-speed data access to the processor and stores frequently used computer programs, applications, and data. Cache memory is used to reduce the average time to access data from the main memory. The cache memory is closer to the CPU than RAM, and the data which is most frequently used by the CPU can be stored in the cache.

Multiple levels of cache (L1, L2, and sometimes L3) are present in modern computers. L1 is the fastest cache but has the smallest capacity, while L2 has more capacity but is slower, and so on. Each level of cache has its own hit rate, which is the percentage of times that the requested data is found in that level of cache.

When a cache miss occurs at one level, the next level of cache is checked, and this process continues down the memory hierarchy until the data is found. If all levels of cache miss, then the data must be retrieved from the main memory, which is much slower than accessing data from caches. The process of checking multiple levels of cache adds latency, hence the access times for L2 cache and main memory are cumulative, including the time spent on the previous checks.

Related Questions