UNIT 3 - Computer Memory
UNIT 3 - Computer Memory
UNIT 3 - Computer Memory
INTRODUCTION
The computer’s memory stores data, instructions required during the processing of data, and
output results. Storage may be required for a limited period of time, instantly, or, for an extended
period of time. Different types of memories, each having its own unique features, are available
for use in a computer. The cache memory, registers, and RAM are fast memories and store the
data and instructions temporarily during the processing of data and instructions. The secondary
memories like magnetic disks and optical disks have large storage capacities and store the data
and instructions permanently, but are slow memory devices. The memories are organized in the
computer in a manner to achieve high levels of performance at the minimum cost.
In this unit, we discuss different types of memories, their characteristics and their use in the
computer.
MEMORY REPRESENTATION
The computer memory stores different kinds of data like input data, output data, intermediate
results, etc., and the instructions. Binary digit or bit is the basic unit of memory. A bit is a single
binary digit, i.e., 0 or 1. A bit is the smallest unit of representation of data in a computer.
However, the data is handled by the computer as a combination of bits. A group of 8 bits form a
byte. One byte is the smallest unit of data that is handled by the computer. One byte can store 28,
i.e., 256 different combinations of bits, and thus can be used to represent 256 different symbols.
In a byte, the different combinations of bits fall in the range 00000000 to 11111111. A group of
bytes can be further combined to form a word. A word can be a group of 2, 4 or 8 bytes.
1 bit = 0 or 1
1
Memory is logically organized as a linear array of locations. For a processor, the range of the
memory addresses is 0 to the maximum size of memory.
MEMORY HIERARCHY
The memory is characterized on the basis of two key factors—capacity and access time.
Capacity is the amount of information (in bits) that a memory can store. Access time is the time
interval between the read/write request and the availability of data. The lesser the access time,
the faster is the speed of memory. Ideally, we want the memory with fastest speed and largest
capacity. However, the cost of fast memory is very high. The computer uses a hierarchy of
memory that is organized in a manner to enable the fastest speed and largest capacity of memory.
The hierarchy of the different memory types is shown in Figure 1.
The internal memory and external memory are the two broad categories of memory used in the
computer. The internal memory consists of the CPU registers, cache memory and primary
memory. The internal memory is used by the CPU to perform the computing tasks. The external
memory is also called the secondary memory. The secondary memory is used to store the large
amount of data and the software.
2
Registers, cache memory, and primary memory constitute the internal memory. The primary
memory is further of two kinds—RAM and ROM. Registers are the fastest and the most
expensive among all the memory types. The registers are located inside the CPU, and are directly
accessible by the CPU. The speed of registers is between 1–2 ns (nanosecond). The sum of the
size of registers is about 200B. Cache memory is next in the hierarchy and is placed between the
CPU and the main memory. The speed of cache is between 2–10 ns. The cache size varies
between 32 KB to 8MB. Any program or data that has to be executed must be brought into RAM
from the secondary memory. Primary memory is relatively slower than the cache memory. The
speed of RAM is around 60ns. The RAM size varies from 512KB to 6GB.
Secondary Memory: The key features of secondary memory storage devices are—
To get the fastest speed of memory with largest capacity and least cost, the fast memory is
located close to the processor. The secondary memory, which is not as fast, is used to store
information permanently, and is placed farthest from the processor. With respect to CPU, the
memory is organized as follows:
Registers are placed inside the CPU (small capacity, high cost, very high speed)
Cache memory is placed next in the hierarchy (inside and outside the CPU)
Primary memory is placed next in the hierarchy
3
Secondary memory is the farthest from CPU (large capacity, low cost, low speed)
NOTE: The speed of memories is dependent on the kind of technology used for the memory. The
registers, cache memory and primary memory are semiconductor memories. They do not have
any moving parts and are fast memories. The secondary memory is magnetic or optical memory,
has moving parts and has slow speed.
CPU REGISTERS
Registers are very high-speed storage areas located inside the CPU. After CPU gets the data and
instructions from the cache or RAM, the data and instructions are moved to the registers for
processing. Registers are manipulated directly by the control unit of CPU during instruction
execution. That is why registers are often referred to as the CPU’s working memory. Since CPU
uses registers for the processing of data, the number of registers in a CPU and the size of each
register affect the power and speed of a CPU. The more the number of registers (ten to hundreds)
and bigger the size of each register (8 bits to 64 bits), the better it is.
CACHE MEMORY
Cache memory is placed in between the CPU and the RAM. Cache memory is a fast memory,
faster than the RAM. When the CPU needs an instruction or data during processing, it first looks
in the cache. If the information is present in the cache, it is called a cache hit, and the data or
instruction is retrieved from the cache. If the information is not present in cache, then it is called
a cache miss and the information is then retrieved from RAM. The content of cache is decided by
the cache controller (a circuit on the motherboard). The most recently accessed information or
instructions help the controller to guess the RAM locations that may be accessed next. To get
good system performance, the number of hits must far outnumber the misses. The two main
factors that affect the performance of cache are its size and level (L1, L2 and L3).
PRIMARY MEMORY
Primary memory is the main memory of computer. It is a chip mounted on the motherboard of
computer. Primary memory is categorized into two main types-
RAM is used for the temporary storage of input data, output data and intermediate results. The
input data entered into the computer using the input device, is stored in RAM for processing.
After processing, the output data is stored in RAM before being sent to the output device. Any
intermediate results generated during the processing of program are also stored in RAM. Unlike
4
RAM, the data once stored in ROM either cannot be changed or can only be changed using some
special operations.
Therefore, ROM is used to store the data that does not require a change. Flash memory is another
form of rewritable read-only memory that is compact, portable, and requires little energy.
5
o DRAM must be refreshed continually to store information. For this, a memory
controller is used. The memory controller recharges all the capacitors holding a 1
before they discharge. To do this, the memory controller reads the memory and
then writes it right back.
o DRAM gets its name from the refresh operation that it requires to store the
information; otherwise it will lose what it is holding. The refresh operation occurs
automatically thousands of times per second. DRAM is slow because the
refreshing takes time.
o Access speed of DRAM ranges from 50 to 150 ns.
SRAM chip is usually used in cache memory due to its high speed.
SRAM uses multiple transistors (four to six), for each memory cell. It does not have a
capacitor in each cell.
A SRAM memory cell has more parts so it takes more space on a chip than DRAM cell.
It does not need constant refreshing and therefore is faster than DRAM.
SRAM is more expensive than DRAM, and it takes up more space.
It stores information as long as it is supplied with power.
SRAM are easier to use and very fast. The access speed of SRAM ranges from 2–10
nanosecond.
The memory chips are available on a separate Printed Circuit Board (PCB) that is
plugged into a special connector on the motherboard. Memory chips are generally
available as part of a card called a memory module. There are generally two types of
RAM modules—Single In-line Memory Module (SIMM) and Dual In-line Memory
Module (DIMM).
o SIMM modules have memory chip on one side of the PCB. SIMM modules can
store 8 bits to 32 bits of data simultaneously.
o DIMM modules have memory chips on both sides of the PCB. DIMM format are
64-bit memories. Smaller modules known as Small Outline DIMM (SO DIMM)
are designed for portable computers. SO DIMM modules have 32-bit memory.
o ROM, as the name implies, has only read capability and no write capability. After
the information is stored in ROM, it is permanent and cannot be corrected.
o ROM comes programmed by the manufacturer. It stores standard processing
programs that permanently reside in the computer. ROM stores the data needed
6
for the start up of the computer. The instructions that are required for initializing
the devices attached to a computer are stored in ROM.
o The ROM memory chip stores the Basic Input Output System (BIOS). BIOS
provide the processor with the information required to boot the system. It
provides the system with the settings and resources that are available on the
system. BIOS is a permanent part of the computer. It does not load from disk but
instead is stored in a ROM memory chip. The program code in the BIOS differs
from ordinary software since it acts as an integral part of the computer. When the
computer is turned on, the BIOS does the following things—
o Power On Self Test (POST) is a program that runs automatically when the system
is booted. BIOS performs the power-on self-test. It checks that the major
hardware components are working properly.
o BIOS setup program, which is a built-in utility in BIOS, lets the user set the many
functions that control how the computer works. BIOS displays the system settings
and finds the bootable devices. It loads the interrupt handlers and device drivers.
It also initializes the registers.
o Bootstrap Loader is a program whose purpose is to start the computer software for
operation when the power is turned on. It loads the operating system into RAM
and launches it. It generally seeks the operating system on the hard disk. The
bootstrap loader resides in the ROM. The BIOS initiates the bootstrap sequence.
o ROMs are of different kinds. They have evolved from the fixed read only memory
to the ones that can be programmed and re-programmed. They vary in the number
of re-writes and the method used for the re-writing. Programmable ROM
(PROM), Erasable Programmable ROM (EPROM) and Electrically Erasable
Programmable ROM (EEPROM) are some of the ROMs. All the different kinds
of ROM retain their content when the power is turned off.
o PROM can be programmed with a special tool, but after it has been programmed
the contents cannot be changed. PROM memories have thousands of fuses (or
diodes). High voltage (12 V) is applied to the fuses to be burnt. The burnt fuses
correspond to 0 and the others to 1.
o EPROM can be programmed in a similar way as PROM, but it can be erased by
exposing it to ultra violet light and re-programmed. EPROM chips have to be
removed from the computer for re-writing.
o EEPROM memories can be erased by electric charge and re- programmed.
EEPROM chips do not have to be removed from the computer for re-writing.
7
It combines the features of RAM and ROM. It is a random access memory and its content can be
stored in it at any time. However, like ROM, the data is not lost when the machine is turned off
or the electric power is cut. Flash memory stores bits of data in memory cells.
Flash memories are high-speed memories, durable, and have low- energy consumption. Since
flash memory has no moving part, it is very shock-resistant. Due to these features, flash memory
is used in devices such as digital camera, mobile phone, printer, laptop computer, and record and
play back sound devices, such as MP3 players.
SECONDARY MEMORY
In the previous section, we saw that RAM is expensive and has a limited storage capacity. Since
it is a volatile memory, it cannot retain information after the computer is powered off. Thus, in
addition to primary memory, an auxiliary or secondary memory is required by a computer. The
secondary memory is also called the storage device of computer. In this unit, the terms secondary
memory and storage device are used interchangeably. In comparison to the primary memory, the
secondary memory stores much larger amounts of data and information (for example, an entire
software program) for extended periods of time. The data and instructions stored in secondary
memory must be fetched into RAM before processing is done by CPU.
Magnetic tape drives, magnetic disk drives, optical disk drives and magneto- optical disk drives
are the different types of storage devices.
a. Sequential access
b. Direct access
8
predefined order in which one can read and write data from a direct access device. In a magnetic
disk consisting of 80 records, to access the 25th record, the computer can directly access the 25th
record, without going past the first 24 records. Based on access, magnetic tapes are sequential
access devices, and, magnetic disks, optical disk and magneto-optical disks are direct access
devices.
MAGNETIC TAPE
Magnetic tape is a plastic tape with magnetic coating. It’s a storage medium on a large open reel
or in a smaller cartridge or cassette (like a music cassette). Magnetic tapes are cheaper storage
media. They are durable, can be written, erased, and re-written. Magnetic tapes are sequential
access devices, which mean that the tape needs to rewind or move forward to the location where
the requested data is positioned in the magnetic tape. Due to their sequential nature, magnetic
tapes are not suitable for data files that need to be revised or updated often. They are generally
used to store back-up data that is not frequently used or to transfer data from one system to other.
Magnetic tape is divided horizontally into tracks (7 or 9) and vertically into frames. A
frame stores one byte of data, and a track in a frame stores one bit. Data is stored in
successive frames as a string with one data (byte) per frame.
Data is recorded on tape in the form of blocks, where a block consists of a group of
data also called as records. Each block is read continually. There is an Inter-Record
Gap (IRG) between two blocks that provides time for the tape to be stopped and
started between records.
Magnetic tape is mounted on a magnetic tape drive for access. The basic magnetic
tape drive mechanism consists of the supply reel, take-up reel, and the read/write
head assembly. The magnetic tape moves on tape drive from the supply reel to take-
up reel, with its magnetic coated side passing over the read/write head.
Tapes are categorized based on their width - ¼ inch, ½ inch, etc.
The storage capacity of the tape varies greatly. A 10-inch diameter reel of tape which
is 2400 feet long can store up to 180 million characters.
9
Magnetic Disk
Magnetic disk is a direct access secondary storage device. It is a thin plastic or metallic circular
plate coated with magnetic oxide and encased in a protective cover. Data is stored on magnetic
disks as magnetized spots. The presence of a magnetic spot represents the bit 1 and its absence
represents the bit 0.
The surface of disk is divided into concentric circles known as tracks. The outermost track is
numbered 0 and the innermost track is the last track. Tracks are further divided into sectors. A
sector is a pie slice that cuts across all tracks. The data on disk is stored in sector. Sector is the
smallest unit that can be read or written on a disk. A disk has eight or more sectors per track
(Figure 4).
Magnetic disk is inserted into a magnetic disk drive for access. The drive consists of a
read/write head that is attached to a disk arm, which moves the head. The disk arm can move
inward and outward on the disk.
During reading or writing to disk, the motor of disk drive moves the disk at high speed (60 –
150 times/sec.)
Accessing data on the disk requires the following—
o The read/write head is positioned to the desired track where the data is to be read
from or written to. The time taken to move the read/write head to the desired track is
called the seek time.
o Once the read/write head is at the right track, then the head waits for right sector to
come under it (disk is moving at high speed). The time taken for desired sector of the
track to come under read/write head is called the latency time.
10
o Once the read/write head is positioned at the right track and sector, the data has to be
written to disk or read from disk. The rate at which data is written to disk or read
from disk is called data transfer rate.
o The sum of seek time, latency time and time for data transfer is the access time of the
disk.
The storage capacity of disk drive is measured in gigabytes (GB).
Large disk storage is created by stacking together multiple disks. A set of same tracks on
all disks forms a cylinder. Each disk has its own read/write head which work in
coordination.
A disk can also have tracks and sectors on both sides. Such a disk is called double-sided
disk.
11
ii. File Allocation Table It records the location of each file and status of each sector.
While reading or writing to disk, operating system checks the FAT to find free
area or locate where data is stored on disk, respectively.
iii. Root Directory This is the main folder of disk. It contains other folders in it,
creating a hierarchical system of folders. The root directory contains information
about all folders on the disk.
iv. Data Area The remaining area of the disk (after boot sector, FAT, root directory)
is the data area. It stores the program files and data files that are stored on the
disk.
Floppy disk, hard disk and zip disk are the different types of magnetic disks.
OPTICAL DISK
Optical disk (Figure 5) is a flat and circular disk which is coated with reflective plastic material
that can be altered by laser light. Optical disk does not use magnetism. The bits 1 and 0 are
stored as spots that are relatively bright and light, respectively.
An optical disk consists of a single spiral track that starts from the edge to the centre of disk.
Due to its spiral shape, it can access large amount of data sequentially, for example music and
video. The random access on optical disk is slower than that of magnetic disk, due to its spiral
shape.
The tracks on optical disk are further divided into sectors which are of same length. Thus, the
sectors near the centre of disk wrap around the disk longer than the sectors on the edges of disk.
Reading the disk thus requires spinning the disk faster when reading near the centre and slower
when reading near the edge of disk. Optical disks are generally slower than hard disks. Figure 6
shows the tracks and sectors in a magnetic disk and optical disk.
12
Figure 6 Sectors and track in magnetic disk and optical disk
Optical disks can store large amount of data, up to 6 GB, in a small space. Commonly used
optical disks store 600–700 MB of data.
The access time for an optical disk ranges from 100 to 200 ms. There are two most common
categories of optical disks—read-only optical disks and recordable optical disks.
CD-ROM
Originally, Compact Disk (CD) was a popular medium for storing music. Now, it is used in
computers to store data and is called Compact Disk- Read Only Memory (CD-ROM).
As the name suggests, CD-ROM is an optical disk that can only be read and not written on. CD-
ROM is written on by the manufacturer of the CD-ROM using the laser light.
A CD-ROM drive reads data from the compact disk. Data is stored as pits (depressions) and
lands (flat area) on CD-ROM disk. When the laser light is focused on the disk, the pits scatter the
light (interpreted as 0) and the lands reflect the light to a sensor (interpreted as 1).
As CD-ROM is read only, no changes can be made into the data contained in it.
Since there is no head touching the disk, but a laser light, CD-ROM does not get worn out easily.
The storage density of CD-ROM is very high and cost is low as compared to floppy disk and
hard disk.
13
Access time of CD-ROM is less. CD-ROM drives can read data at 150Kbps. They come in
multiples of this speed like—8x, 16x, 52x, 75x, etc.
DVD-ROM
Digital Video Disk-Read Only Memory (DVD-ROM) is an optical storage device used to store
digital video or computer data.
In addition to the read only CDs and DVDs, recordable optical disks are also available. Users can
record music, video, audio and data on it. The recordable optical disks are—
14
Blu-ray Disc
Blu-ray Disc (BD) is an optical disc storage medium designed to supersede the DVD format. The
plastic disc is 120 mm in diameter and 1.2 mm thick, the same size as DVDs and CDs.
Conventional (pre-BD-XL) Blu-ray Discs contain 25 GB per layer, with dual layer discs (50 GB)
being the industry standard for feature-length video discs. Triple layer discs (100 GB) and
quadruple layers (128 GB) are available for BD-XL re-writer drives.
The name Blu-ray Disc refers to the blue laser used to read the disc, which allows information to
be stored at a greater density than is possible with the longer-wavelength red laser used for
DVDs. The major application of Blu-ray Discs is as a medium for video material such as feature
films. Besides the hardware specifications, Blu-ray Disc is associated with a set of multimedia
formats. Generally, these formats allow for the video and audio to be stored with greater
definition than on DVD.
MAGNETO-OPTICAL DISK
o Magneto-optical disks use laser beam to read data and magnetic field to write data to
disk.
o These are optical disks where data can be written, erased and re-written.
o They are expensive and outdated. They were used during the mid 1990s. They have now
been replaced by CD-RW and DVD-R.
When you load or open an application it is loaded in the RAM. Since the CPU looks for
information in the RAM, any data and instructions that are required for processing (read, write or
15
update) is brought into RAM. To conserve RAM usage, many applications load only the
essential parts of the program initially and then load other pieces as needed. Any files that are
opened for use in that application are also loaded into RAM.
The CPU requests the data it needs from RAM, processes it and writes new data back to RAM in
a continuous cycle. The shuffling of data between the CPU and RAM happens millions of times
every second.
When you save a file and close the application, the file is written to the secondary memory as
specified by you. The application and any accompanying files usually get deleted from RAM to
make space for new data.
If the files are not saved to a storage device before being closed, they are lost.
Sometimes, when you write a program and the power goes off, your program is lost if you have
not saved it. This is because your program was in the RAM and was not saved on the secondary
memory; the content of the RAM gets erased when the power is switched off.
16