Computer memory is organized into addressable units, each of which stores multiple bits. In the early days
of computing (meaning up until the 1970s), there was no agreement on the size of a memory unit. Different
computers used different size memory “cells.” The memory cell size was also referred to as the computer’s
“word size.” The computer word was the basic unit of memory storage. The word size of the IBM 704 was
36 bits; the word size of the Digital Equipment PDP-1 was 18 bits; the word size of the Apollo Guidance
Computer was 15 bits; the word size of the Saturn Launch Vehicle Computer was 26 bits; the word size of the
CDC 6400 was 60 bits. These machines existed during the 1950s, 1960s, and 1970s.
The IBM 360 family, starting in the mid-1960s, introduced the idea of a standard memory cell of 8 bits called
the “byte.” Since then, computer manufacturers have come to advertise memory size as a count of standard bytes.
The idea of the computer word size is still with us, as it represents the number of bits the computer usually
processes at one time. The idea of word size has become less crystalline, however, because newer computer
designs operate on units of data of different sizes. The Intel Pentium processes 32 or 64 bits at a time, but it
is also backwards compatible to the Intel 8086 processor of 1980 vintage, which had a word size of 16 bits.
To this day, the Intel family of processors calls 16 bits a word, and in any case each byte has its own address in
memory.
Today the byte is the measure of computer memory, and most computers, regardless of word size, offer
“byte addressability.” Byte addressability means that each byte has a unique memory address. Even though the
computer may be a 32-bit machine, each byte in the 4-byte computer word (32 bits) can be addressed uniquely,
and its value can be read or updated.
As you probably know, the industry uses prefixes to set the scale of a measure of memory. A kilobyte is
1024 bytes, or 210 bytes—roughly a thousand bytes. A megabyte is 1,048,576 bytes, or 220 bytes—roughly
a million bytes. A gigabyte is 1,037,741,824 bytes, or 230 bytes—roughly a billion bytes.
We hear larger prefixes occasionally, too. A terabyte is 1,099,511,627,776 bytes, or 240 bytes—roughly a trillion
bytes. A petabyte is 1,125,899,906,842,624, or 250 bytes—roughly a quadrillion bytes. Such numbers are so
large that their discussion usually accompanies speculation about the future of computing. However, we are starting
to hear about active data bases in the terabyte, and even the petabyte range (http://www.informationweek.com/
story/IWK20020208S0009).
Memory is used to store program instructions and data. The basic operations on memory are store and retrieve.
Storing is also referred to as “writing.” Retrieval is also referred to as “fetching,” “loading,” or “reading.” Fetch
is an obvious synonym for retrieve, but what about load? By loading one means loading a register in the CPU
from memory, which from the point of view of the memory system is retrieval.
There are at least two registers associated with the memory control circuitry to facilitate storage and
retrieval. These are the memory address register (MAR) and the memory data register (MDR). When writing to
memory, the CPU first transfers the value to be written to the MDR, and the address of the location to be used
to the MAR. At the next memory access cycle, the value in MDR will be copied into the location identified by
the contents of the MAR.
When retrieving from memory, the CPU first stores the address to read in the MAR. When the read occurs
on the next memory access cycle, the value in that location is copied into the MDR. From the MDR in the
memory controller, the data value can be transferred to one of the CPU registers or elsewhere.
Main computer memory, such as we have in our PCs, is referred to as random access memory (RAM). That
means we can access any element of memory at will, and with roughly the same speed, regardless of address.
By contrast, consider information and data stored on a magnetic tape. Magnetic tape is a kind of memory
(we can store data on a magnetic tape), but magnetic tape is definitely not random access. Magnetic tape is
serial access. We can read the contents of memory location 4000 only after having read and passed over all those
locations that come before
In addition to main memory, which has been the focus of our discussion so far, computer designers also
usually provide small, high-performance memories, called cache memories, that are located close to the CPU.
Cache memory may even be located on the same electronic chip as the CPU.
Cache is the French word for “hiding place.” Cache memory is used to hold a copy of the contents of a small
number of main memory locations. This turns out to be very useful, because program execution demonstrates
a property called “locality of reference.”
By locality of reference, we mean that for relatively long periods of time, the execution of a program will
reference and affect a small number of memory locations. Accesses to memory are not random. Rather, for one
period of time the program will read and write one part of memory, for example, an array of numbers, and for
another period of time the program will store and retrieve from a different part of memory, for example, a record
from a data base.
When the computer copies the contents of main memory currently being accessed to cache memory, the
CPU can avoid waiting for access to slower main memory, and access the cache instead. Since access times for
cache memory are typically 5 to 10 times faster than access times for main memory, this tactic has proven very
generally effective. Almost all computers built since 1980 have incorporated one or more cache memories in
their design.
The management of cache memory is challenging, because the system must keep the contents of the cache
memory synchronized with the contents of main memory. Engineers call this cache “coherency.” As long as the
program is reading from memory, but not writing, there is no problem. When the program writes to memory,
however, both main memory and cache must be updated.
Also, when the program begins to access a new area of memory, one for which the contents are not already
reflected in the cache, the cache management algorithm will typically bring to the cache the needed word as
well as a number of following words from memory. At the same time, the cache management algorithm must
decide which contents of the current cache to discard. As complex as this management is, use of cache memory
usually makes a very noticeable difference in performance, with speedup of average memory access often in the
neighborhood of 50 percent.
No comments:
Post a Comment