Question 1
A bike-share docking station's processor runs a loop millions of times a day. Each time round, it reads the same few instructions and the same few variables (such as the number of free docks) from memory.
Explain how CPU cache memory speeds up this loop, referring to a cache hit and a cache miss. [3]
- p1 [1]
Cache is a small amount of very fast memory close to (or on) the CPU that holds copies of data or instructions that are used often.
- p2 [1]
A cache hit is when the data the CPU needs is found in the cache, so it is read quickly without going to the slower main memory (RAM).
- p3 [1]
A cache miss is when the data is not in the cache, so it must be fetched from main memory (slower), and it is usually copied into the cache so the next request for it is a hit.
Also accept
- For p1, "faster than RAM but smaller" earns the mark when linked to holding frequently used data.
- For p3, linking the loop's repeated reads to a high hit rate earns the mark if a miss is also described.
No marks for
- Describing cache as a part of the hard drive or SSD.
- Saying a cache miss causes an error or crashes the program. It only makes that access slower.
- Saying cache is bigger than RAM.
A full-marks answer
Cache is a small, very fast memory on or next to the CPU that keeps copies of instructions and data that are used often, such as the loop's instructions and the free-docks count. When the CPU needs one of these and it is already in the cache, that is a cache hit, and it is read much faster than from main memory. When it is not in the cache, that is a cache miss: it has to be fetched from the slower main memory, and a copy is put into the cache so the next read is a hit. Because the loop reads the same few items again and again, almost every read after the first time round is a hit.