04 Memory
04 Memory
Computer Organization
and Architecture
7th Edition
Chapter 5
Memory
SYLLABUS
Characteristics of memory system and hierarchy,
Algorithms
memories
• INTERNAL
—Usually governed by data bus width
• EXTERNAL
—Usually a block which is much larger than a
word
• Addressable unit
—Smallest location which can be uniquely
addressed
4. Access Methods (1)
• Sequential
—Start at the beginning and read through in
order
—Access time depends on location of data and
previous location
—e.g. tape
• Direct
—Individual blocks have unique address
—Access is by jumping to vicinity plus
sequential search
—Access time depends on location and
previous location
—e.g. disk
Access Methods (2)
• Random
—Individual addresses identify locations exactly
—Access time is independent of location or
previous access
—e.g. RAM
• Associative
—Data is located by a comparison with contents
of a portion of the store
—Access time is independent of location or
previous access
—e.g. cache
5. Performance
• Access time
—Time between requesting for operation and
the time it is made available at the required
location
• Transfer Rate
—Rate at which data can be moved
6. Physical Types
• Semiconductor
—RAM
• Magnetic
—Disk & Tape
• Optical
—CD & DVD
7. Physical Characteristics
• Decay
• Volatility
• Erasable
• Power consumption
8. Organisation
• Physical arrangement of bits into words
• Not always obvious
• e.g. interleaved
Memory Hierarchy
• Registers
—In CPU
• Internal or Main memory
—May include one or more levels of cache
—“RAM”
• External memory
—Backing store
Memory Hierarchy - Diagram
Decreasing Cost
Increase Capacity
• State 1
—C1 high, C2 low
—T1 T4 off, T2 T3 on
• State 0
—C2 high, C1 low
—T2 T3 off, T1 T4 on
SRAM v DRAM
• Both volatile
—Power needed to preserve data
• Dynamic cell
—Simpler to build, smaller
—More dense
—Less expensive
—Needs refresh
—Larger memory units
• Static
—Faster
—Cache
Read Only Memory (ROM)
• Permanent storage
—Non volatile
• TYPES OF ROM
—PROM
—EPROM
—EEPROM
PROM-Programmable ROM
• Written during manufacture
• Programmable (“once”)
—PROM
—Small amount of data to be written
—Less expensive
– Erased by UV
—Flash memory
virtually indefinitely
5. ROM cartridges
• Commonly used in games machines
• Prevents software from being easily copied
Cache
Cache
Main
Memory
Memory CPU
(SRAM)
(DRAM)
3. If present then
4. If not, the CPU
the instruction is
has to fetch next
fetched from the
instruction from
cache – a very fast
main memory - a
operation
much slower process
= Bus connections
Cache operation – overview
• Size
• Mapping Function
• Replacement Algorithm
• Write Policy
• Block Size
• Number of Caches
Size does matter
• Cost
—More cache is expensive
• Speed
—More cache is faster (up to a point)
—Checking cache for data takes time
MAPPING TECHNIQUES
• DIRECT MAPPING
• ASSOCIATIVE MAPPING
4FFFFE 2 /6 / 10 [2]
5
3 /7/ 11 [7]
6
10
11
DIRECT MAPPING
0 16 words
• Cache- 128 blocks of 16 words each 1 16 words
5(16-(7+4)) 7(2 7) 4 (2 4)
Working of Direct Mapping
• Word" field selects one from among the 16 addressable
words in a line.
• The "Line" field defines the cache line where this memory
line should reside.
Tag Word
12(16-4) 4 (2 4)
Working of Fully Associative Mapping
• "Tag" field identifies one of the 2 12 = 4096 memory lines;
• All the cache tags are searched to find out whether or not
the Tag field matches one of the cache tags.
6(16-(4+6)) 6(2 6) 4 (2 4)
Working
• "Tag" field identifies one of the 26 = 64 different memory
lines in each of the 26 = 64 different "Set" values.
• Since each cache set has room for only two lines at a time,
the search for a match is limited to those two lines (rather
than the entire cache).
• If there's a match, we have a hit and the read or write can
proceed immediately.
• Otherwise, there's a miss and we need to replace one of the
two cache lines by this line before reading or writing into the
cache. (The "Word" field again select one from among 16
addressable words inside the line.)
• In set-associative mapping, when the number of lines per
set is n, the mapping is called n-way associative. For
instance, the above example is 2-way associative.
Direct Mapping
Cache Line Table
• Cache line Main Memory blocks held
• 0 0, m, 2m, 3m…2s-m
• 1 1,m+1, 2m+1…2s-m+1
• Simple
• Inexpensive
very high
Associative Mapping
ii) How many bits are needed to represent the TAG, SET
and WORD fields?
Problem statement
words.
ii) How many bits are needed to represent the TAG, SET
different caches
—Write through
—Write invalidate
—Write Update
Software Solutions
software
Hardware Solution
• Cache coherence protocols
• Run time
• Transparent to programmer
• Lots of traffic
processors
both solutions
Write Invalidate
• MESI protocol
MESI Protocol
• Modified
• Exclusive
• Shared
• Invalid
MESI protocol
reduced waiting.
Associative Memory
• Content-addressed or associative memory-memory is
accessed by its content (as opposed to an explicit
address).
programs to be
opened
simultaneously by
as temporary
storage of memory
pages.
VIRTUAL MEMORY
• 32 or 64MB of RAM available for CPU usage.
• Find RAM for areas that have not been used recently
RAM space )
called paging.
• First Fit
• Best Fit
Replacement Algorithms
• Hardware implemented algorithm (speed)
• Least Recently used (LRU)
—Pick the slot that hasn't been used in the
longest time.
• Random
• OPT-Optimal(Future)
7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1
FIFO,LRU,OPT
1) 1 , 6 ,4 , 5 , 1 ,4, 3, 2, 1, 2, 1, 4,6,7,4
FIFO 7 – 4 – 6
LRU 4 - 6 - 7
OPT 7 – 6 -4 (Conflict resolved using LRU)
2) 2 , 3 , 2 , 1 , 5 , 2 , 4 , 5 , 3 , 2 , 5 , 2
FIFO 3 - 2 - 5
LRU 3 – 5 - 2
OPT 2 - 3 - 5
FIFO Page Replacement
LRU Page Replacement
A. Frank - P. Weisberg
Optimal Page Replacement
Secondary Storage
• Magnetic disks
• Floppy disks
• Magnetic Tape
• RAID
• Optical Memory
• CD-ROM
• DVD
RAID Levels 0 - 6
REDUNDANT ARRAY OF INDEPENDENT DISKS
• Storage is an important consideration when setting up a server.
• Almost all of the important information that you and your users care
later retrieval.
• Single disks can serve you well if your needs are straight forward.