Home Topic 2 Last Next


Explain the use of cache memory.


Teaching Note:

Students should be able to explain the effect of cache memory in speeding up the system as well as being able to explain how it is used.


Sample Question:


JSR Notes:



Cache is the part of the computer, most often right within the CPU itself, which can store data and commands that are used over and over again.

With CPU cache we speak of different "levels" of cache: L1, L2, L3. The L1 is right in the middle of the CPU, and the L2 more peripheral to the main action of the CPU, and L3 can even be not on CPU chip itself, but be right next to it - though it's still a lot closer than RAM is. (You'll note that now-a-days, all levels of cache are almost always integrated right in the CPU.)



Cafeteria Kitchen as a CPU analogy & Cache

In a field trip to a school cafeteria, the cache would be all the places in the kitchen close to where the action is happening, where various things are stored.

So the stuff right on or next to the cutting boards or mixing bowls would be the L1 cache: the knives and forks and spoons and pepper and salt and so on, right there for the assistant chef to grab very conveniently whenever he/she wants.

The L2 cache, we could say is stuff on the main preparation tables, but not necessarily right next to the cutting boards/mixing bowls - so a bit of a reach for the assistant chef, but only a reach; no walking is required to go get them.

And L3 cache would be all the stuff on the tables behind the preparation tables; not quite all the way back in the storage room or refrigerators, but just a step or two to get to to grab.


Technical Description of Cache

Primary, but not the prime primary

Note that cache memory is certainly a category of primary memory; it functions almost continually when the computer is operating, and interacts directly with the CPU. And it is for sure not secondary storage. But in terms of it's "primacy", it actually is not required, so it is not ***the*** primary memory. That is likely why this curriculum does not include it with the two "real" primary memory categories of RAM and ROM. Never-the-less in normal circumstances, RAM and cache usually do work together very intimately within a computer.

"Explain the
use of cache memory", its' "effect in speeding up the system" and "how it is used"

Cache memory is really fast RAM memory located close to the CPU. That which makes it fast, also makes it expensive, and so it is limited in size compared to RAM. It's not just the way it is made that makes it fast, but it is the fact that it is located right within the CPU; not some distance away on the memory bus, like RAM.

The function of cache is to keep track of all the commands that are going from the RAM to the CPU, and to store those that are going most frequently. That way, instead of the CPU having to go, repeatedly, to the (relatively slow and distant) RAM, it just needs to go to the (relatively fast and close) cache. This speeds things up significantly, particularly if there are a lot of instructions that are being repeated over and over again.

Repetitive Tasks - the specialty of cache

Among the things that are most likely to be sped up by cache are multimedia operations, since they repeat, basically, the same thing over and over again. Consider applying a filter to a Photoshop image 1000 by 1000 pixels big. Each of the 1,000,000 pixels needs to be changed in exactly the same way, using exactly the same method - why go back to RAM and fetch that instruction 1,000,000 times when it can leave that method in the fast-access cache. Or re-drawing the triangles of a polygon 3d model when being animated at 24 frames a second. The same sorts of calculation are done over and over and over again, so the instructions for those calculations would be kept "at the ready" in the cache.

Cache Size

Ryzen 7 Cache Specifications (Ryzen 7 is one of AMD's latest CPUs):

Level 1 cache size 

768 KB total
(512 KB, 8 x 64 KB 4-way set associative instruction caches
256 KB, 8 x 32 KB 8-way set associative data caches)

Level 2 cache size 4 MB (8 x 512 KB inclusive 8-way set associative unified caches)
Level 3 cache size 16 MB (2 x 8 MB exclusive 16-way set associative shared caches)





It is interesting to take a look at where and what is produced around the world in terms of semiconductors, including cache memory. Here is an complete list of all semiconductor plants around the world; keep in mind that one physical factory may be represented on this list by several different "Plants", and this includes everything semiconductor, from CPUs to RAM to LEDs. Certain countries, notably Taiwan for RAM, figure prominently.