Logout

2.1.3

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:

sdfsdfsf

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. But before getting into a bit more of a technical description...

...back to the Cafeteria Kitchen as a CPU analogy:

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. 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.)

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 refridgerators, but just a step or two to get to to grab.

 

 

Now on to a bit more technical description

Note that cache memory is certainly a category of primary memory; it functions almost continually when the computer is operating, and it is for sure not secondary storage. But in terms of it's "primacy", it's actually not required, so it is certainly 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 it is worthy to note is how intimately RAM and cache usually do work together within a computer.


In terms of "explain the use of cache memory", its' "effect in speeding up the system" and "how it is used" here it goes:

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 that 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.

Among the things that are most likely to be speeded 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.

In terms of size, the newest iMacs have the following:

Each of the four cores has a dedicated 256k level 2 cache and all processor cores share a single 8 MB level 3 cache.

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

Level 1 cache sizeĀ  8 x 64 KB 4-way set associative instruction caches
8 x 32 KB 8-way set associative data caches
Level 2 cache size 8 x 512 KB inclusive 8-way set associative unified caches
Level 3 cache size 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. Here is an exhastive list of all semiconductor plants; keep in mind that one physical factory may be represented on this list by several differnt "Plants", and this includes everything semiconductor, from CPUs to RAM to LEDs. Certain countries, notably Taiwan for RAM, figure prominantly.)