Chapter 03
Chapter 03
Computer Memory
CHAPTER 03
2
• Key characteristics
Overview • Design Constraints
• Hierarchy
3
Key characteristics
4
Design Constraints
How much (capacity) , how fast (access time), how expensive (cost),
Memory Hierarchy
• Locality of reference
• Cache mapping schemes
Cache • Replacement policies
memory • Cache write policies
7
Locality of reference
The instruction currently being fetched is very close in memory to the
instruction to be fetched next. The same idea applies to the data
value currently being accessed (read/written) in memory.
1. If the line with that memory address is in the cache (hit), the data is
read from the cache to the CPU.
2. If the line with that memory address is not in the cache (a miss), the
cache is updated by replacing one of its active lines by the line with
that memory address, and then the data is read from the cache to
the CPU.
12
1. If the line with that memory address is in the cache, the data is
written to the cache, and the line is marked "invalid" (no longer is an
image of the corresponding memory line).
2. If the line with that memory address is not in the cache, the cache is
updated by replacing one of its active lines by the line with that
memory address. The data is then written from the CPU to the cache
and the line is marked "invalid.”
Suppose:
A cache has 24 = 16 lines, each with 23 = 8 bytes ➔ Cache size = 128 Bytes
The main memory 256 bytes in the memory's address space
--> there are 8 bit addresses
14
Direct mapping
Each block has only one place it can appear in the cache.
...
Address
lines 2nd 16 blocks of
8 words each
Direct Mapping
Advantage: Simple and inexpensive to implement.
Main disadvantage:
There is a fixed cache location for any given block → if a program
happens to reference words repeatedly from two different blocks
that map into the same line → the blocks will be continually swapped
in the cache → the hit ratio will be low (thrashing).
17
Associative mapping
Any block of main memory can be placed anywhere in the cache
memory.
The fastest and most flexible mapping technique
18
Set-Associative mapping
Cache blocks are divided into sets. Set size is in the power of 2
Example: the cache has 2 blocks --> 2-way set associative, the cache
has 4 blocks --> 4-way set associative
20
L2 (unified)
I-Cache & D-Cache
256 KB, 8-way, 11 cycles
L3 (unified)
8 MB, 16-way, 30-40 cycles
24
Organization
The basic element of a semiconductor memory is the memory cell
which are:
Two stable states, which can be used to represent binary 1 and 0.
Capable of being written into (at least once), to set the state.
Capable of being read to sense the state.
26
Types of ROM
ROM contain permanent pattern of data that can not be changed.
EPROM (Erasable PROM): read and write electrically (old data must
be erased by exposing the package to an intense UV radiation).
Types of RAM
DRAM (Dynamic RAM): is made with cells that store data as charge
on capacitors. Because capacitors have a natural tendency to
discharge →require periodic charge refreshing to maintain data.
SRAM (Static RAM): is a digital device that uses the same logic
elements used in the processor. In a SRAM, values are stored using
traditional FF logic-gate → hold its data as long as power is supplied.
Chip Logic
Semiconductor memory comes in
packaged chips. Each chip
contains an array of memory cells.
The array is organized into W
words of n bits each.
Overall Structure
35
• Magnetic disk
External • Solid State Drives
Memory • Optical Memory
38
Construction
A disk is a circular platter constructed of nonmagnetic material,
called the substrate, coated with a magnetizable material.
Construction
For most disks, the magnetizable coating is applied to both sides of
the platter (double sided). Some less expensive disk systems use
single-sided disks.
Performance parameters
Seek time: the time required to move the disk arm to the required
track = Startup time + Traverse time + Settle time.
For common disk size today (3.5’ = 8.9 cm), typical average seek time
is under 10ms.
Transfer time:
42
Timing comparison
Consider a disk with an advertised average seek time of 4 ms,
rotation speed of 15,000 rpm, and 512-byte sectors with 500 sectors
per track. Suppose that we wish to read a file consisting of 2500
sectors for a total of 1.28 Mbytes.
Timing comparison
Consider a disk with an advertised average seek time of 4 ms,
rotation speed of 15,000 rpm, and 512-byte sectors with 500 sectors
per track. Suppose that we wish to read a file consisting of 2500
sectors for a total of 1.28 Mbytes.
Timing comparison
Consider a disk with an advertised average seek time of 4 ms,
rotation speed of 15,000 rpm, and 512-byte sectors with 500 sectors
per track. Suppose that we wish to read a file consisting of 2500
sectors for a total of 1.28 Mbytes.
RAID
The rate of improvement in secondary storage performance has
been considerably less than the rate for processors and main
memory.
The mismatch has made the disk storage system, the main focus of
concern in improving overall computer system performance ➔ using
parallel components (multiple disks)
46
RAID
Industry has agreed on a standardized scheme for multiple-disk
database design, known as RAID (Redundant Array of Independent
Disks). RAID scheme consists of 7 levels (0 → 6). All levels share three
common characteristics:
• Flash memory
Solid State • SSD
Drive (SSD) • Practical issues with SSD
51
Flash memory
In recent years, the cost and performance of flash memory has
replace HDDs.
In NOR flash memory, the basic access unit is a bit, and the logical
NOR flash memory can read and write data to specific locations, and
can reference and retrieve a single byte. NOR flash memory is used
Flash memory
In NAND flash memory, the basic unit is 16 or 32 bits, and the
logical organization resembles NAND devices.
NAND reads and writes in small blocks. It is used in USB flash
drives, memory cards (in digital cameras, MP3 players, etc.),
and in SSDs.
NAND provides higher bit density than NOR and greater write
speed.
NAND flash read data on a block-wise basis (also known as
page access), where each block holds hundreds to thousands
of bits.
53
Lower power consumption: SSDs use as little as 2.1 watts of power per
drive, considerably less than comparable-size HDDs.
Lower access times and latency rates: Over 10 times faster than the
spinning disks in an HDD
54
Practical issues
Tend to slow down as the device is used
Flash memory is accessed in blocks (size of 512 KB), there are typically
128 pages per block.
1. The entire block must be read from the flash memory and placed in a
RAM buffer. Then the appropriate page in the RAM buffer is updated.
2. Before the block can be written back to flash memory, the entire
block of flash memory must be erased—it is not possible to erase just
one page of the flash memory.
3. The entire block from the buffer is now written back to the flash
memory
55
Practical issues
Becomes unusable after a certain number of writes
As flash cells are stressed, they lose their ability to record and retain
values (typical limit is 100,000 writes)
56
• Compact Disk
Optical • CD Recordable
Memory • CD Rewritable
• Digital Versatile Disk
57
CD Recordable (CD-R)
For CDs and CD-ROMs, information is recorded by the pitting of the
surface of the medium, which changes reflectivity.
For a CD-R, the medium includes a dye layer. The dye is used to
change reflectivity and is activated by a high-intensity laser.
59
CD Rewritable (CD-RW)
The CD-RW optical disk can be repeatedly written and overwritten,
as with a magnetic disk.
The phase change disk uses a material that has two significantly
different reflectivities in two different phase states:
Amorphous state, in which the molecules exhibit a random orientation
that reflects light poorly;
Crystalline state, which has a smooth surface that reflects light well.
A beam of laser light can change the material from one phase to
the other.
Bits are packed more closely on a DVD: The spacing between loops
of a spiral on a CD is 1.6 μm, the minimum distance between pits
along the spiral is 0.834 μm. The DVD uses a laser with shorter
wavelength and achieves a loop spacing of 0.74 μm and a
minimum distance between pits of 0.4 μm (4.7GB)
Dual-layer DVD (8.5GB): the lasers in DVD drives can adjust focus to
read a semireflective layer on top of the reflective layer.