Discussion:
The Doe Library Cache Metaphor
(too old to reply)
[TA] Matt Johnson
2007-04-11 14:58:15 UTC
Permalink
Here's one way to establish the analogy:

stacks of books <-> main RAM
books at table <-> cache
book(s) open <-> registers

The open books are the ones you are working with directly, and so you
could think of those as the CPU registers. Then the analogy doesn't
quite reflect the size difference between registers and cache, but it's
the right idea.

You can tweak that analogy to represent multiple levels of cache and
even disk (virtual memory, not yet covered). I think the thing to keep
in mind is that the "most active material" in the analogy should be the
registers, and each step removed from the registers would be one step
down in the memory hierarchy, from registers to caches (possibly
multiple levels of caches) to memory (and later, to disk!).


Hope that helps.


Matt
So I go to Doe Library to do my research paper, and I get the books I think
I'll need, and carry them back to the table at which I'm sitting. I open a
subset of the books so that I can quickly go from one open book to another. As
the open books fill up my whole table, and I need to open one of the closed
books, I close one or more of the open books so that I can open one or more of
the closed books...
ok, so the part I don't get here is, is the cache *all of the books at my
library table*, or is it *only the open books*? If it's *only the open books*,
then what do the closed books at my table represent (as they no longer live on
the library shelves, but I'm not accessing them right now either)?
Thanks.
Andrew Toulouse
2007-04-11 16:50:26 UTC
Permalink
Perhaps it would clarify things to make another analogy.

Let's say Bubba's watching the Super Bowl. The table in front of him are
his registers, the fridge is cache, and the corner shop a quick walk
away is memory.

He looks and see he doesn't have any beer on the table. So he goes to
the fridge and gets what he wants, and comes back to the couch. Later,
Bubba runs out of beer (useful data). This is a cache miss, so he has to
go down to the corner store and get some beer. Instead of just getting
what he wants, maybe he gets some Hungry-Man frozen dinners, in case
he'll want some later. He goes back, puts the beer and TV dinner in the
fridge, and brings some beers with him to the table. Next time he runs
out of beer, he goes to the corner store, but they're all out of beer.
So he buys some seed, tills the fields, and grows his own barley. This
is disk access.



Now, if someone wants to remake this analogy so there's five people on
the couch....

-Andy
So I go to Doe Library to do my research paper, and I get the books I think
I'll need, and carry them back to the table at which I'm sitting. I open a
subset of the books so that I can quickly go from one open book to another. As
the open books fill up my whole table, and I need to open one of the closed
books, I close one or more of the open books so that I can open one or more of
the closed books...
ok, so the part I don't get here is, is the cache *all of the books at my
library table*, or is it *only the open books*? If it's *only the open books*,
then what do the closed books at my table represent (as they no longer live on
the library shelves, but I'm not accessing them right now either)?
Thanks.
Loading...