Week 1 - Memory and Cache Flashcards

1
Q

What is the primary purpose of memory and cache in a computer system?

A

To store data and instructions temporarily, allowing faster access by the CPU, improving processor performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the key performance metrics for cache memory?

A

Hit rate: Percentage of memory accesses found in the cache.
Miss rate: Percentage of memory accesses not found in the cache.
Average Memory Access Time (AMAT): A measure of the average time required to access memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you calculate Average Memory Access Time (AMAT)?

A

AMAT = Hit time + (Miss rate × Miss penalty)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a cache hit and a cache miss?

A

Cache hit: When the data requested by the CPU is found in the cache.
Cache miss: When the data requested is not in the cache, and it must be fetched from main memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the hit rate formula for cache memory?

A

Hit rate = (Number of cache hits) / (Total number of data requests)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the miss penalty in cache memory?

A

The additional time required to fetch data from main memory when a cache miss occurs, usually measured in clock cycles.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are temporal locality and spatial locality in the context of caching?

A

Temporal locality: Recently accessed data is likely to be accessed again soon.
Spatial locality: Data located near recently accessed data is likely to be accessed soon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does direct mapping work in cache memory?

A

Each memory location is mapped to exactly one cache location using modulo division based on the cache size.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the formula for determining the cache index using direct mapping?

A

Cache index = Memory address mod Cache size (2^k)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the role of the valid bit in cache memory?

A

The valid bit indicates whether the data stored in a cache block is valid (1) or invalid (0).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What happens during a cache miss?

A

The data is fetched from the main memory.
The data and corresponding tag are copied into the cache.
The valid bit for the cache block is set to 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does the CPU find data in the cache?

A

The memory address is divided into tag, index, and offset bits.
The index is used to locate a specific cache block.
The tag is compared with the stored tag in the cache.
If the tag matches and the valid bit is set, the data is retrieved from the cache.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a cache tag?

A

A cache tag is a part of the memory address that helps identify whether the data stored in a cache block corresponds to the requested memory address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between direct-mapped cache and fully associative cache?

A

Direct-mapped cache: Each memory block maps to exactly one cache location.
Fully associative cache: Any memory block can be placed in any cache block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does set-associative cache work?

A

A set-associative cache is a compromise between direct-mapped and fully associative caches. Memory is divided into sets, and each block can be placed in any location within a specific set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does it mean when a cache has larger block sizes?

A

Increasing the block size in the cache allows more data to be stored per block, improving spatial locality by fetching multiple adjacent data values with a single memory access.

17
Q

What is the primary trade-off in using fully associative cache?

A

Fully associative caches offer flexibility in placing data but require checking the tags of every cache block, which increases the complexity and size of the cache hardware.

18
Q

How can cache performance be improved?

A

Cache performance can be improved by increasing the hit rate, which is achieved by exploiting temporal and spatial locality, optimizing block sizes, and using set-associative or fully associative cache designs.

19
Q

What happens when a cache block is replaced?

A

When a cache block is replaced, the data from the old block is removed, and new data is written into the block. This typically happens when the cache is full and a new memory block needs to be cached.

20
Q

What are the three steps to handle a cache hit?

A

Index the correct cache block.
Check the valid bit.
Match the tag to the memory address. If it matches, the data is sent to the CPU.