🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: k12.ed.comp.literacy
1 messages
1 total messages Started by Andrew Daviel Tue, 30 May 1995 00:00
Cache analogy
#858
Author: Andrew Daviel
Date: Tue, 30 May 1995 00:00
83 lines
4871 bytes
I had this neat idea for an analogy of cacheing I thought I'd share.

 * * *

You may know that inside your computer is a CPU, such as a 80486, which
has "on-chip cache". Your computer probably also has "cache memory",
and of course RAM and a hard drive.

The CPU is like a man sitting at a table working out sums. He does all
the sums on a calculator. All the numbers that are in the calculator
are in the CPU's registers. He can add these numbers really fast.
A CPU like a Pentium can add two pairs of numbers every clock cycle, so
it can add numbers in 5ns.

Sometimes the right number isn't in the calculator, so he has a stack of
paper in front of him, where he writes down answers and reads questions.
This stack of paper is the on-chip cache, and he can write numbers down
almost as fast as he can do calculations. In the CPU, the cache is an array
of memory elements, with an access time of one or two clock cycles, perhaps 
as little as 10ns.

Sometimes, the right numbers aren't written down on the papers. At one side
of the table is a stack of books. When he can't find the numbers in the paper,
he looks in the books. It takes him longer to look stuff up in the books
than to look through the papers. The stack of books is the on-board cache,
which in a modern computer is probably made of static RAM with an access
time of perhaps 20ns.

If the numbers aren't in the stack of books, he has to get a different
book from the bookshelf. It takes him quite a time to get books down,
so he tends to get several books at once. The bookshelf is the main RAM,
probably made from dynamic RAM with an access time of 70ns.

If the right books aren't on the bookshelf, he has to get them from the 
library.  The library is the hard drive, with a seek time of maybe 10ms. If
the computer has virtual memory, the programs think they have a huge
amount of memory, but really most of it is on the hard drive. It takes
an enormous amount of time to get stuff from the hard drive compared
to getting it from RAM.

If the computer is on a network, then sometimes the books come from 
a different library by inter-library loan.

Sometimes, the man writes numbers into the books. Eventually, all numbers
from the papers are written in the books, the books go back on the shelf,
and all the books from the shelf are returned to the library. If this
doesn't happen, due to a power failure, then the numbers are lost.

Some more powerful computers have more than one CPU. Now, there are
two men working at different tables, but they only have one bookshelf.
Sometimes, one man needs a particular book, but the other man has taken
it out, so he has to wait. If he only needs to read a book, not write
in it, he can copy the book (he's got an incredibly fast photocopier).
Then both men can work with copies of the same book. If one man writes
in a book, then he must make sure that the other man gets a new copy,
otherwise he will be working with old numbers and get the wrong answer.

Sometimes, when the men want a book by inter-library loan, it's 
already been taken out and they have to wait. Again, if they only want
to read it, they may get the library to send them a photocopy.

This whole business of making sure the two men are always working
with the latest numbers is called "cache coherence", and is going
to become more and more important in the next few years, as CPUs are
getting faster faster than RAM is getting faster. Some computers,
like the Silicon Graphics machines used in Jurasssic Park, have as many as
sixteen CPUs, and some special-purpose computers may have a thousand or
more. Sometimes programs are written so they can run on several CPUs
at once, but more often each CPU just does something different.

--
Andrew Daviel         email: advax@triumf.ca 
TRIUMF                voice: 604-222-7376 
4004 Wesbrook Mall    fax:   604-222-7307 
Vancouver BC          http://andrew.triumf.ca/~andrew 
Canada   V6T 2A3      49D14.7N 123D13.6W

--
Andrew Daviel         email: advax@triumf.ca 
TRIUMF                voice: 604-222-7376 
4004 Wesbrook Mall    fax:   604-222-7307 
Vancouver BC          http://andrew.triumf.ca/~andrew 
Canada   V6T 2A3      49D14.7N 123D13.6W
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads