Department of Energy Argonne National Laboratory Office of Science NEWTON's Homepage NEWTON's Homepage
NEWTON, Ask A Scientist!
NEWTON Home Page NEWTON Teachers Visit Our Archives Ask A Question How To Ask A Question Question of the Week Our Expert Scientists Volunteer at NEWTON! Frequently Asked Questions Referencing NEWTON About NEWTON About Ask A Scientist Education At Argonne Cache Memory
Name: Lingling
Status: Student
Age: 20s
Location: N/A
Country: N/A
Date: Around 1999


Question:
What is the purpose of cache memory? And how the instruction fetch/ excecute cycle changes with the additon of cache memory? Please describe it step by step. Thanks!



Replies:
The purpose of cache memory is to allow the CPU to operate at full speed without wasting time waiting for memory access.

In a computer, not all parts operate at the same speeds. Disk drives are really slow, while the CPU is extremely fast. However, before the CPU can do anything, it needs to retrieve data to work on. If that data is stored on a disk, the CPU will wait a long time before it can be accessed.

Typically, a program is set up to run as follows:
1. Load the program and data from a disk into RAM.
2. Fetch the instructions from RAM
3. Fetch the data from RAM
4. Perform the instruction
5. Write the results back to RAM
6. When done, save the final results back to disk.

This works great, and is all there is on many systems, such as the Apple II, Commodore 64, and other older sytems.

Current computers, however, operate at much higher speeds, and in fact operate much faster than RAM can be accessed. If modern computers read and wrote directly to RAM, they would spend most of their time waiting for memory.

In order to solve this, another layer of memory has been added, called the cache. It is a small amount of very fast, expensive memory, that operates close to the speed of the computer. A separate cache controller chip monitors the RAM accesses and loads data and instructions from RAM to the cache. Once it is in the cache, the CPU can operate at full speed.

Sometimes, the cache controller can't predict exactly what is needed. In these cases, the CPU is stalled and has to wait while the necessary data is loaded from RAM into the cache.

So, the cycle looks only slightly different from the normal model
1. Load the program and data from a disk into RAM.
2. Cache controller loads instructions and data from RAM into cache.
3. Fetch the instructions from cache.
5. Fetch the data from cache 6. Perform the instruction
7. Write the results back to cache
8. Write the results bacck from cache to RAM
9. When done, save the final results back to disk.

I hope this helps.

Thanks,
--Eric Tolman


Click here to return to the Computer Science Archives

NEWTON is an electronic community for Science, Math, and Computer Science K-12 Educators, sponsored and operated by Argonne National Laboratory's Educational Programs, Andrew Skipor, Ph.D., Head of Educational Programs.

For assistance with NEWTON contact a System Operator (help@newton.dep.anl.gov), or at Argonne's Educational Programs

NEWTON AND ASK A SCIENTIST
Educational Programs
Building 360
9700 S. Cass Ave.
Argonne, Illinois
60439-4845, USA
Update: June 2012
Weclome To Newton

Argonne National Laboratory