Upload
maximillian-owen
View
231
Download
0
Embed Size (px)
Citation preview
© Prepared By:Razif Razali 1
CHAPTER FIVECHAPTER FIVE
COMPUTER MEMORY COMPUTER MEMORY SYSTEMSYSTEM
© Prepared By:Razif Razali
2
ContentsContents
• IntroductionIntroduction
• Features of memory systemFeatures of memory system
• Semiconductor main memorySemiconductor main memory
• Cache memoryCache memory
• External memoryExternal memory
IntroductionIntroduction• The memory is that part of the computer where programs and data are stored.The memory is that part of the computer where programs and data are stored.• Computer memory system is divided into two parts:Computer memory system is divided into two parts:
– Internal memory– External memory
• Internal MemoryInternal Memory– Data / instruction stored inside this storage can be accessible easily by CPU. – It’s a part of main component of a computer system– Types : register, cache memory and main memory
• • External MemoryExternal Memory
– Data / instruction stored inside this storage cannot be accessible easily by CPU, must go through I/O Module or I/O unit
– It’s a not an integral part of main component of a computer system– Examples: magnetic disks, optical disks etc.
© Prepared By:Razif Razali
3
Features of Memory SystemFeatures of Memory System
• LocationLocation– The term location refers to whether memory is internal and external to the computer.– Internal memory is often equated with main memory.– External memory consists of peripheral storage devices, such as disk and tape, that are accessible
to the processor via I/O controllers.• CapacityCapacity
– An obvious characteristic of memory is its capacity– For internal memory, this is typically expressed in terms of bytes(1 byte = 8 bits) or word– Common word lengths are 8, 16, and 32 bits– External memory capacity is typically expressed in terms of bytes
• Unit of transferUnit of transfer– For internal memory, the unit of transfer is equal to the number of data lines into and out of the
memory module.– This may be equal to the word length, but is often larger, such as 64, 128 or 256 bits– For external memory, data are often transferred in much larger units than a word, and these are
referred to as blocks
© Prepared By:Razif Razali
4
Features of Memory SystemFeatures of Memory System
• Access methodAccess method– The method of accessing units of data is another distinction among memory types. – These includes: Sequential Direct Random Associative
• PerformancePerformance– Three performance parameter are used:– Access time (latency)
• Time between presenting the address and getting the valid data– Memory Cycle time
• Time may be required for the memory to “recover” before next access• Cycle time is access + recovery
– Transfer Rate• Rate at which data can be moved into or out of a memory unit
© Prepared By:Razif Razali
5
Features of Memory SystemFeatures of Memory System
• Physical typePhysical type
– A variety of physical types of memory have been employed.
– The most common today are :
• Semiconductor
– RAM
• Magnetic
– Disk & Tape
• Optical
– CD & DVD
• Others
– Bubble
– Hologram
© Prepared By:Razif Razali
6
Features of Memory System
• Physical characteristicsPhysical characteristics– Several physical characteristics
of data storage are important.– In a volatile memory, information
decays naturally or is lost when electrical power is switched off.
– In a non-volatile memory, information once recorded remains without deterioration until deliberately changed; no electrical power is needed to retain information
© Prepared By:Razif Razali
7
Memory hierarchy diagram
Memory hierarchy pyramid
© Prepared By:Razif Razali
8
Semiconductor main memory• Main memory often referred to as Main memory often referred to as corecore..
• All semiconductor memory cells share certain properties:All semiconductor memory cells share certain properties:
– They exhibit two stable states, which used to represent binary 1 and 0.
– They are capable of being written into (at least once), to set the state.
– They are capable of being read to sense the state.
© Prepared By:Razif Razali
9Semiconductor memory type
Random Access Memory (RAM)
• The most common is referred as RAM.
• One distinguishing characteristic of RAM is that it is possible both to read data from the memory and to write new data into the memory easily and rapidly.
• Both reading and writing are accomplished through the use of electrical signals.
• RAM technology is divided into 2 technologies:
– Dynamic RAM (DRAM)
– Static RAM (SRAM)
© Prepared By:Razif Razali
10
Dynamic RAM• Made with cells that store data as charge on capacitor. Made with cells that store data as charge on capacitor. • The presence or absence of charges in a capacitor have a natural tendency to discharge, The presence or absence of charges in a capacitor have a natural tendency to discharge,
dynamic RAMs require periodic charge refreshing to maintain data storage.dynamic RAMs require periodic charge refreshing to maintain data storage.• Characteristics:Characteristics:
– Made with cells that store data as charge on capacitors– Charges leak– Need refreshing even when powered – Simpler construction– Smaller per bit– Less expensive– Need refresh circuits– Slower– Main memory– It is essentially an analogue device
• Level of charge determines value; 1 or 0
© Prepared By:Razif Razali
11
Static RAM (SRAM)
• A digital device, using the same logic elements used in the processor. A digital device, using the same logic elements used in the processor. • In SRAM, binary values are stored using traditional flip flop logic gates configurations. In SRAM, binary values are stored using traditional flip flop logic gates configurations. • A static RAM will hold its data as long as power is supplied to it.A static RAM will hold its data as long as power is supplied to it.• CharacteristicsCharacteristics
– Bits stored as on/off switches– No charges to leak– No refreshing needed when powered– More complex construction– Larger per bit– More expensive– Does not need refresh circuits– Faster– Cache– Is a digital device, using the same logic elements used in the processor
• Uses flip-flops to store binary value
© Prepared By:Razif Razali
12
Read Only Memory (ROM)
• ROM contains a permanent pattern of data that cannot be changed.
• A ROM is nonvolatile; that is no power source is required to maintain the bit values in memory.
• It is possible to read a ROM, it is not possible to write new data into it.– Programmable ROM (PROM)– Erasable PROM (EPROM)– Electrically EPROM (EEPROM)– Flash memory
© Prepared By:Razif Razali
13
Cache memory
• Cache memory is intended to give memory speed approaching that of the fastest memories available, and at the same time provide a large memory size at the price of less expensive types of semiconductor memories.
• There is a relatively large and slow main memory together with a smaller, faster cache memory.
• The cache contains a copy of portion in main memory.
© Prepared By:Razif Razali
14
Cache memory
• When the processor attempts to read a word of memory, a check is made When the processor attempts to read a word of memory, a check is made to determine if the word is in the cache. to determine if the word is in the cache.
• If so the word is delivered to the processor.If so the word is delivered to the processor.
• If not, a block of main memory, consisting of some fixed number of words, If not, a block of main memory, consisting of some fixed number of words, is read into the cache and then the word is delivered to the processor.is read into the cache and then the word is delivered to the processor.
• When a block of data is fetched into the cache to satisfy a single memory When a block of data is fetched into the cache to satisfy a single memory references, it is likely that there will be future references to that same references, it is likely that there will be future references to that same memory location or to other words in the block. memory location or to other words in the block.
© Prepared By:Razif Razali
15
Cache sizeCache size• The size of the cache should be small enough so that the overall average
cost per bit is close to that of main memory alone and large enough so that the overall average access time is close to that of the cache alone.
• The larger the cache, the lager the number of gates involved in addressing the cache.
• The result is that large cache tends to be slightly slower than the small ones – even when built with the same integrated circuit technology and put in the same place on chip and circuit board.
© Prepared By:Razif Razali
16
Mapping functionMapping function
• Because there are fewer cache lines than main memory blocks, an Because there are fewer cache lines than main memory blocks, an algorithm is needed for mapping main memory blocks into cache lines.algorithm is needed for mapping main memory blocks into cache lines.
• A means is needed for determining which main memory block currently A means is needed for determining which main memory block currently occupies a cache line.occupies a cache line.
• The choice of the mapping function dictates how the cache is organized.The choice of the mapping function dictates how the cache is organized.
• Three techniques can be used: Three techniques can be used:
– Direct Mapping
– Associative Mapping
– Set Associative Mapping
© Prepared By:Razif Razali
17
Direct Mapping
• The simplest technique, map each block of main memory into one possible cache line.
• i.e. if a block is in cache, it must be in one specific place
• The mapping is express as i = j mod m
where i = cache line number
j = main memory block number
m= number of lines in the cache
• Example :
– Assume MM size is 4K and cache size is 2K. Cache is divided into 4 slots.
– From this information , find out how much size of each SLOT and the total NUMBER of BLOCKS reside in MM ?
– In which slot does block 0,1,2 will be mapped in?
© Prepared By:Razif Razali
18
Direct Mapping - Pros & Cons
• The direct mapping technique is simple and inexpensive to implement
• Its main disadvantage is that there is a fixed cache location for any given block– If a program accesses 2 blocks that map to the same line
repeatedly, cache misses are very high
© Prepared By:Razif Razali
19
Direct Mapping Example
© Prepared By:Razif Razali
20
Figure shows our example system using direct mapping. In the example, m = 16K = 214 and i = j modulo 214. The mapping becomes
Direct Mapping
© Prepared By:Razif Razali
21
Associative Mapping
• With associative mapping, there is flexibility as to which block to replace when a new block is read into the cache.
• Replacement algorithms are designed to maximize the hit ratio• Advantage :
– A main memory block can load into any line of cache• The principal disadvantage is the complex circuitry required to
examine the tags of all cache lines in parallel
© Prepared By:Razif Razali
22
Associative Mapping
© Prepared By:Razif Razali
23
Set Associative Mapping
• SA mapping is a compromise that exhibits the strengths of both the direct and associative approaches while reducing their disadvantages.
• In this case, cache is divided into a number of sets (v sets), each set contains a number of lines (k lines).
• A given block maps to any line in a given set.• E.g. Block 7 can be in any line of set i • Replacement algorithm is needed to determine which slot is to
be carried out, if all slots in the set are full.
© Prepared By:Razif Razali
24
Set Associative Mapping
• The relationship are The relationship are i= j modulo v i= j modulo v
Where i = cache set numberWhere i = cache set number
j = main memory block numberj = main memory block number
m= number of lines in the cachem= number of lines in the cache• Example :Example :• Given the following information about cache memory system that using set Given the following information about cache memory system that using set
associative mapping method:associative mapping method:• cache size is 1K, slot size is 128 words, total number of blocks is 16 and cache size is 1K, slot size is 128 words, total number of blocks is 16 and
total number of sets is 4. Find out:total number of sets is 4. Find out:
a) total number of slot?a) total number of slot?
b) block size?b) block size?
c) main memory size?c) main memory size?
d) block 2 will be mapped into which slot number?d) block 2 will be mapped into which slot number?
© Prepared By:Razif Razali
25
Replacement Algorithms (1) - Direct mapping
• Once the cache has been filled, when a new block is brought into the cache, one of the existing slot must be replaced
• For direct mapping, there is only one possible line for any particular block, and no choice is possible
• Each block only maps to one line
• Replace that line
© Prepared By:Razif Razali
26
Replacement Algorithms (2) - Associative & Set Associative
• For associative and set associative technique, a replacement algorithm For associative and set associative technique, a replacement algorithm is neededis needed
• To achieve high speed, such an algorithm must be implemented in To achieve high speed, such an algorithm must be implemented in hardwarehardware
• The most popular Replacement Algorithm are:The most popular Replacement Algorithm are:
i. Least Recently used (LRU)i. Least Recently used (LRU)
Replace that block in the set that has been in the cache longest with no reference to it
ii. First in first out (FIFO)ii. First in first out (FIFO)
replace block that has been in cache longest
iii. Least frequently used (LFU)iii. Least frequently used (LFU)
replace block which has had fewest hits
iv. Randomiv. Random
© Prepared By:Razif Razali
27
Write Policy
• The cache's write policy determines how it handles writes to memory locations that are currently being held in cache
• Must not overwrite a cache block unless main memory is up to date
• Multiple CPUs may have individual caches• I/O module may be able to read write directly to main
memory .• If a word has been altered only in the cache, then the
corresponding memory word is invalid
© Prepared By:Razif Razali
28
Write Policy• There are two techniques : • Write through
– Using this technique, all write operations are made to main memory as well as to the cache, ensuring that main memory is always valid
– This type of caching provides worse performance than write-back, but is simpler to implement and has the advantage of internal consistency, because the cache is never out of sync with the memory the way it is with a write-back cache.
– The main disadvantage of this technique is that it generates substantial memory traffic and may create a bottleneck - Slows down writes
• Write back – When the system writes to a memory location that is currently held in cache, it only writes the
new information to the appropriate cache line. – When the cache line is eventually needed for some other memory address, the changed data is
"written back" to system memory. – This type of cache provides better performance than a write-through cache, because it saves on
(time-consuming) write cycles to memory.
© Prepared By:Razif Razali
29
External memory
• Magnetic disk remains the most important component of external memory. Magnetic disk remains the most important component of external memory. • Both removable and fixed, or hard disks are used in systems ranging from Both removable and fixed, or hard disks are used in systems ranging from
personal computers to mainframes and supercomputers.personal computers to mainframes and supercomputers.• To achieve greater performance and higher availability, servers and larger To achieve greater performance and higher availability, servers and larger
system use RAID disk technology. system use RAID disk technology. • RAID is a family of techniques for using multiple disks as a parallel array RAID is a family of techniques for using multiple disks as a parallel array
of data storage devices, with redundancy built in to compensate for disk of data storage devices, with redundancy built in to compensate for disk failure.failure.
• Optical disk storage technology has become increasingly important in all Optical disk storage technology has become increasingly important in all types of computer systems. types of computer systems.
• While CD-ROM has been widely used for many years, more recent While CD-ROM has been widely used for many years, more recent technologies, such as writable CD and DVD, are becoming increasingly technologies, such as writable CD and DVD, are becoming increasingly important. important.
© Prepared By:Razif Razali
30
Types of External Memory
• Magnetic disk– A disk is a circular platter constructed of nonmagnetic material,
called the substrate has been an aluminum or aluminum alloy material. Most recently, glass substrate have been introduced.
– Eg: Hard disk and Diskette• RAID
– RAID is a set of physical disk drives viewed by the operating systems as a single logical drive.
– Data are distributed across the physical drives of an array.– Redundancy disk capacity is used to store parity information,
which guarantees data recoverability in case of a disk failure.
© Prepared By:Razif Razali
31
Types of External Memory
• Optical Memory– The CD is a nonerasable disk that can store more than 60 minutes od audio information on one
side. – The huge commercial success of the CD enabled the development of low-cost optical-disk
storage technology that has revolutionized computer data storage.– Eg: CD-ROM, CD-R, CD-RW, DVD.
• Magnetic tape– Tape system use the same reading and recording techniques as disk systems. The medium is
flexible polyster (similar to that used in some clothing) tape coated with magnetizable material.– The coating may consist of particles of pure metal in special binders or vapor-plated metal film.– The tape and tape drive are analogous to a home tape recorder systems.– Data on the tape are structured as a number of parallel tracks running lengthwise.– The recording of data in this form is referred to as parallel recording.– Most modern systems instead use serial recording, in which data are laid out as a sequence of
bits along each track, as is done with magnetic disks.
© Prepared By:Razif Razali
32
CONCLUSIONS• Types of MemoryTypes of Memory
– Internal vs External• Features of Memory SystemFeatures of Memory System
– Location, Capacity, Unit of Transfer, Access Method, Performance, Physical Type.• Memory Hierarchy PyramidMemory Hierarchy Pyramid• Technique of Mapping FunctionTechnique of Mapping Function
– Direct Mapping– Associative Mapping– Set Associative Mapping
• Write PolicyWrite Policy– Write Through– Write Back
• Types of External MemoryTypes of External Memory– Magnetic Disk, RAID, Optical Memory, Magnetic Tape
© Prepared By:Razif Razali
33