æÇááå íÇ ÝÇØãÉ ÇäÇ ÏæÑÊ ßÊíííííííííííÑ Úáì ÇÌÇÈå áÓÄÇáß
ÈÓ ãÇ áÞíÊÔ ÇáÇ ÇÌÇÈå ãä ãæÞÚ ÇäÌáíÒì æáæ ÇäÊ ÞÑíÊíå ÈÌÏ åÊÚÑÝì ÇáÇÌÇÈå
æåæ Ïå ÇáÛÑÖ ãä ÇáßÇÔ ãíãæÑì 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.
æÇäÇ ÌÇíÈå ãä ÇáãæÞÚ Ïå
www.newton.dep.anl.gov/askasci/comp99/CS020.htmæÏå ãÞÇá áEric Tolman