Teach Computer
Science
Computer
memory
teachcomputerscience.co
m
1
.
Revision notes
teachcomputerscience.co
m
Introduction
Memory is the space where data and programs are stored. Data
in memory is accessed through instructions from the CPU.
Memory in a computer system is classified into primary and
secondary memory. In this article, types of memory and their
specific functions are explained.
Primary memory
The various primary memories available in a CPU are listed
below in order of its closeness to CPU:
i. Registers
ii. Cache
iii. RAM
iv. Virtual Memory
The access time of data in a memory type depends on its
closeness to the CPU. But, the closer the memory type, the more
expensive it is. The following figure illustrates the four types of
primary memories.
Fastest, smallest and
most expensive memory CPU Registers
Cache
RAM
Slowest, largest and
Virtual Memory (in Hard disk)
least expensive memory
Figure 1: Types of primary memory
Latency is the time taken by components to respond to a
request. To avoid short delays between the CPU’s request for
data and finding the data in the memory, some instructions and
data are copied to cache.
teachcomputerscience.co
m
Random access memory
(RAM)
RAM is a temporary memory which stores data, files and parts of
the operating system that is currently in use. When a program is
loaded from hard drive, all its contents such instructions and
data are loaded to RAM and CPU accesses this information. It is
also called the main memory. This is also used by the operating
system, applications and any data that are currently used. It is
also important to note that the access time for CPU to access
any data from RAM is less when compared to accessing data
from the hard drive. Therefore, the larger the size of RAM, the
faster the computer will operate. Buffers also use RAM.
When the power is lost, the contents of RAM are lost. The
contents of RAM can be read from, written to and changed. Each
memory location in RAM has a unique address. There are two
types of RAM:
Dynamic RAM (DRAM)
Dynamic RAM consists of transistors that act as switches and
capacitors that hold binary data. DRAM has to be constantly
refreshed (every 15 microseconds) to maintain the charge in the
capacitor. DRAM is used for main RAM memory.
Static RAM (SRAM)
Static RAM uses ‘flip flops’ which hold each bit of memory. SRAM
need not be refreshed constantly. SRAM is faster than DRAM.
SRAM is used in cache memory. SRAM is more complex to build
than DRAM and is therefore more expensive. Due to the complex
design and more transistors and additional wiring required in
SRAM, it offers smaller capacity compared to DRAM.
Figure 2: RAM
teachcomputerscience.co
m
Read only memory (ROM)
Read Only Memory (ROM) is a permanent memory that is used to
store the instructions that are executed once the computer is
switched ON. This set of instructions is called a boot process.
This is responsible for initialising the hardware and operating
system soon after the power is switched ON. The contents of
ROM are not erased even when the power is switched off. The
contents of ROM can only be read and cannot be changed.
ROM is made by interconnecting several transistors. As ROM
remembers its contents even when power is switched off, it falls
under the category of non-volatile memory. Types of ROM are:
PROM (programmable read-only memory)
PROM is manufactured as blank ROM. These chips are
inexpensive and programmed by the programmer for different
applications. The contents cannot be changed once
programmed.
EPROM (erasable programmable read-only memory)
The contents of EPROM are erased in exposure to ultraviolet
light. So, EPROM can be reprogrammed.
EEPROM (electrically erasable programmable read-only memory)
EEPROM can be easily updated by the programmer. EEPROM is
widely used in PCs and smartphones where the developer
updates applications.
teachcomputerscience.co
m
Flash memory
Flash memory is a type of ROM. It is programmed by applying
slightly large electric current that forces an electron through a
barrier as shown in the figure below.
Electrons
trapped in Electrons
this layer forced
through
Charge barrier
applied
Figure 3: Flash memory
Once the electrons cross this barrier, it gets stored in a layer. The
electrons can then be detected without affecting its position. As
a flash of current is used to store data, it is called flash memory.
Flash memory is also rewritable.
teachcomputerscience.co
m
Virtual memory
When a computer has too many processes running at the same
time and the capacity of RAM is not enough, a section of the hard
drive is allocated for storing temporary data. This section of hard
disk is called virtual memory. A part of the storage drive is
available as RAM temporarily. This management of memory is
performed by the operating system. A virtual memory scheme is
illustrated in the following figure. A part of the RAM that is
currently not in use is transferred to the hard disk and a part of
hard disk that is currently required by RAM is transferred to RAM.
This process of transferring data between RAM and the hard disk
is slow and may affect the performance of the computer.
Hard disk
Virtual
RAM
memory
Paging /
Swapping
Figure 4: Virtual memory
Swapping (or paging) is the process by which the OS moves data
between RAM and virtual memory. Data not immediately needed
is removed from RAM and copied to the virtual memory. When
data is required, it is copied again to RAM. By using this method,
a computer handles requests even when it does not have enough
RAM.
teachcomputerscience.co
m
2
.
Activity
teachcomputerscience.co
m
Activity-1
Duration: 10 minutes
1. Complete the table below with the keywords given in the
box.
Non-volatile Volatile Boot process Programs and data
currently in use
Is? Stores?
RAM
ROM
2. Arrange the following primary memories in the order of
increasing access time.
Hard disk CPU RAM Cache
registers
teachcomputerscience.co
m
3
.
End of topic
questions
teachcomputerscience.co
m
End of topic questions
1. Why are some data copied to cache memory?
2. What is the difference between the basic operation of RAM
and ROM?
3. What is the difference between SRAM and DRAM?
4. What does RAM contain?
5. What does ROM contain?
6. What are the different types of ROM? Explain in detail how
each one of them works.
7. What is virtual memory? What are its contents?
8. What is paging?
teachcomputerscience.co
m