Session8-Memory Unit
Session8-Memory Unit
UNIT STRUCTURE
3.1 Learning Objectives
3.2 Introduction
3.3 Memory Hierarchy
3.4 Main Memory
3.5 Semiconductor RAM
3.5.1 Static and Dynamic RAM
3.5.2 Internal Organization of Memory Chips
3.6 ROM
3.6.1 Types of ROM
3.7 Locality of Reference
3.8 Cache Memory
3.8.1 Cache Operation - an overview
3.9 Mapping Functions
3.9.1 Direct Mapping
3.9.2 Associative Mapping
3.9.3 Set-Associative Mapping
3.10 Replacement Algorithm
3.11 Virtual Memory
3.11.1 Paging
3.12 Magnetic Disk
3.12.1 Data Organization in Magnetic Disk
3.12.2 Disk Access Time
3.13 RAID
3.14 Optical Memory
3.14.1 CD-ROM
3.14.2 DVD Disks
3.15 Magnetic Tape
3.16 Let Us Sum Up
3.17 Further Readings
3.18 Answers To Check Your Progress
3.19 Model Questions
3.2 INTRODUCTION
In the previous unit, we have learnt about the peripheral devices
associated with a computer system and various techniques with the
help of which data transfers between the main memory and the
input-output devices takes place.
In this unit we shall discuss about various types of memory
associated with a computer system including main memory, cache
and virtual memory and various technology associated with these
memory units. Finally, we conclude the unit discussing the concept
of secondary memory along with their types.
The computer stores the programs and the data in its memory unit.
The CPU fetches the instructions out of the memory unit to execute
and process them.
Memory can be primary (or main) memory and secondary (or auxiliary)
memory. Main memory stores programs and data currently executed
by the CPU of a computer. Auxiliary memory provides backup storage
of information. Data as well as instructions are transferred from the
secondary memory to the main memory whenever it is needed by
the CPU.
Regarding the speed of the memory, there are two useful measures
of the speed of memory units : Memory Access Time and Memory
Cycle Time.
Register
Static RAM
Dynamic RAM
Magnetic disks
Magnetic Tapes
There are three key characteristics of the memory. They are cost,
capacity and access time. On moving down the memory hierarchy,
it is found that the cost of the storage devices decreases but their
storage capacity as well as the memory access time increases. In
other words, the smaller memories are more expensive and much
faster. These are supplemented by the larger, cheaper and slower
storage devices.
Thus from the above figure it can be seen that the registers are at
the top of the hierarchy and so provides the fastest, the smallest and
the most expensive type of memory device for the CPU to access
data. Registers are actually small amount of storage available on the
CPU and their contents can be accessed more quickly than any
other available storage. They may be 8–bit registers or 32-bit registers
according to the number of bits that they can hold in them.
RAM : In RAM, it is possible to both read and write data from and
to the memory in a fixed amount of time independent of the memory
location or address. RAM is also a volatile memory which means it
stores the data in it as long as power is switched on. Once the
power goes off, all the data stored in it is also lost. Therefore, a RAM
cell must be provided a constant power supply.
b b'
T1 T2
Word Line
Bit Lines
Bit Line
Word Line
T
C
Refresh
Counter
Cell
Row Row
address decoder Array
latch
Row /
Column
Address
Read/Write
Column
Column circuits &
address
decoder
counter
Clock
CS
W0
A0
A1 W1
Address Memory
A2 Decoder
Cell
A3
W15
b7 b1 b0
Fig.3.5: Organization of cells in a memory chip
the form of array of rows and columns. Each cell in the array
can hold one bit of information. Each row in the array forms
ROM (Read Only Memory) is another type of main memory that can
only be read. Each memory cell in ROM is hardware preprogrammed
during the IC (Integrated Circuit) fabrication process. That is the code
or the data in ROM is programmed in it at the time of its manufacture.
The data stored in ROM is not lost even if the power is switched off.
For this reason, it is called a non-volatile storage. It is used to store
programs that are permanently stored and are not subject to change.
The system BIOS program is stored in ROM so that the computer
can use it to boot the system when the computer is switched on.
Bit Line
Word Line
As the name indicates, this type of ROM chips allows the user
to code data into it. They were created as making ROM chips
from scratch. It is time-consuming and also expensive in creating
small numbers of them. PROM chips are like ROM chips but
the difference is that PROM chips are created by inserting a
fuse at the point P (in the above diagram). Before programming,
all the memory cells in PROM contains 0. The user then can
insert 1’s wherever needed by burning out the fuses at those
locations by sending high current pulses. However, PROMs
can be programmed only once. They are more fragile than
ROMs.
Disk Caching
14
• Direct Mapping
• Associative Mapping
• Set-Associative Mapping
Tag
Block 0
Tag
Block 1
Tag Block 2 Block 127
Block 128
Block 129
BB
Tag
Block 127
Block 256
Block 257
Block 4095
there is a fixed cache location for any given block in main generally
typically ra
memory. If a program accesses two blocks that map to the
to 256 by
same cache line repeatedly, then cache misses are very high.
Tag Word
(a)16- bit main memory address Block 0
Block 1
Tag
Tag
Tag
Tag
Block i
Block 63
Block 64
Block 65
Block 4
Block 127
Block 128
Block 129
Block 126
Block 4095
Block 127
(c) Main memory
(b) Cache memory
For direct mapping where there is only one possible line for a block
of memory, no replacement algorithm is required. For associative
and set associative mapping, however, an algorithm is needed. At
this point, we will describe the one most common replacement
algorithm, called LRU algorithm. This algorithm is easy to understand
and provides a good background to understand the more advanced
replacement algorithms. Several other replacement algorithms are
also used in practice such as: first in first out replacement algorithm,
random replacement algorithm etc.
Before coming to the point virtual memory, let us review some basics:
physical memory(RAM) versus secondary memory(disk space).
3.11.1 Paging
0
Page 0
1024
Page 1
2048
Page 2
3072
0
Page frame 0
1024
Page frame 1
2048
Page frame 2
3072
Page frame 3
Page 15 4095
16383 (b)
(a) 4K Main memory (RAM) is
16K Virtual memory is divided into divided into 4 page frames each
16 pages each of size 1K of size 1K
0100 0 0 0 0 0 1 0 1 1 0
Fig.3.11
0100 0 0 0 0 0 1 0 1 1 0
0001 0
0 0 1 0Page 02 0 1
0011 0
0100 01 1
0101 10 1
0110 0
0111 0 01 0 0 0 0 0 1 0 1 1 0
1000 11 1 12 bit Physical address
1001 0
1010 0
00 Page frame 0
1011 0
01 Page frame 1
1100 0
10 Page frame 2
1110 0
11 Page frame 3
1111 0
4K Main memory
Presence bit
The disks rotates at very high speeds. During a read/ write operation,
only the disk rotates and the head is always stationary.
Tracks
Read/Write head
Some magnetic disk uses a single read/ write head for each
disk surface while others uses separate read/ write heads for
each track on the disk surface. Accordingly, the read/write head
may be movable or fixed. If the magnetic disk uses a single
head for each disk surface then the read/write head must be
able to be positioned above any track in the surface. Therefore,
the head has to be a movable head. In such case, the head
is mounted on an arm and the arm can be extended or retracted
to position the head on any track.
(a)
(b)
The disks which are attached to the computer units and cannot
be removed by the occasional users are called the hard disk.
Those which can be inserted and removed from the system
easily by the users are called floppy disks.
The sum of these two delays, that is the seek time and the
latency time is called the disk access time.
Read/Write Head
Access arm
Surfac assembly
e5
Surface 4
Surf ace
3
Surface 2
Surf ac
e1
Surface 0
Direction of movement of
access arm assembly
3.13 RAID
The rate in the increase in the speeds of the processor and the
main memory is much more than that in the improvement of the
secondary storage devices. Of course there has been an increase
in the storage capacities of these devices.
In the RAID 1 scheme identical copies of the same data are stored
on two disks. Data stripping is also used here but the strip is mapped
to both the physical disks. The two disks are mirrors of each other.
If a disk failure occurs, then all the operations on its data can be
done on its mirror disk. The disadvantage of RAID 1 scheme is the
cost involved with it to improve the reliability.
In the mid 1980’s Sony and Philips companies developed the first
generation of CDs. The CDs are non-volatile and they could not be
erased.
In the past few years a variety of optical disk systems have been
introduced:
CD (Compact Disk)
CD-ROM (Compact Disk Read Only Memory )
WORM (Write Once Read Many)
Erasable Optical Disk, etc.
Variations of the term DVD often indicate the way data is stored
on the disks : DVD-ROM (read only memory) has data that
can only be read and not written; DVD-R
and DVD+R (recordable) can record data only once, and then
function as a DVD-ROM; DVD-RW (re-writable), DVD+RW,
and DVD-RAM (random access memory) can all record and
erase data multiple times. The wavelength used by standard
DVD lasers is 650 nm thus, the light has a red color.
DVD -5 4.7GB 1 1
DVD -9 8.54GB 2 1
DVD –R 4.7GB 1 1
DVD –R 9.4GB 1 2
The magnetic tape is mostly used for off-line storage of large amount
of data. They are the cheapest and the slowest methods for data
storage.
Earlier the tapes had nine tracks each but the newer tape systems
use 18 or 36 tracks, corresponding to a word or a double word. A
separate read/write head is mounted one in each track so that data
can be recorded and read in a sequential manner.
Data are organized in the form of records and these records are
separated by gaps referred to as inter-record gaps.
RECOR RECORD
D
File Record 7 or 9
Mark bit
Fig. 3.17: Data Organization on a Magnetic Tape
a. Rewind tape
b. Erase tape
c. Forward space one record
d. Backspace one record
e Forward space one file
f. Backspace one file
The end of the tape is marked by EOT (End of Tape). The records
in a tape may be of fixed or variable length.