Teach Computer
Science
Computer memory
teachcomputerscience.co
m
2
Lesson Objectives
Students will learn about:
▪ Primary memory, i.e. memory that is directly accessed by
CPU in detail.
▪ Types of primary memory.
▪ What does a computer do when it has too many processes
to handle but its RAM is full
teachcomputerscience.co
m
1.
Content
teachcomputerscience.co
m
4
Memory
▪ 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.
teachcomputerscience.co
m
5
Types of memory
Primary memory Secondary memory
Primary memory is a type of memory Secondary memory refers to the
that is accessed directly by the CPU. external storage devices such as hard
For example: RAM, ROM and cache. drives, CD, flash drives, etc.
teachcomputerscience.co
m
6
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
▪ But, the closer the memory type, the more expensive it is.
▪ The closer the memory type, the faster the access is
teachcomputerscience.co
m
7
Primary memory
Fastest, smallest and
most expensive memory CPU Registers
Cache
RAM
Slowest, largest and
Virtual Memory (in Hard disk)
least expensive memory
teachcomputerscience.co
m
8
Latency
▪ 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 the cache.
teachcomputerscience.co
m
9
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 the hard drive, all its contents
such as its instructions and data are loaded to the RAM and the
CPU accesses this information. It is also called the main memory.
▪ Used by the operating system, applications and any data that are
currently used.
▪ The access time for a CPU to access any data from the RAM is less
when compared to accessing data from a hard drive.
▪ The larger the size of RAM, the faster the computer operates.
teachcomputerscience.co
m
10
Random access memory
(RAM)
▪ 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.
teachcomputerscience.co
m
11
Random access memory
(RAM)
teachcomputerscience.co
m
12
Types of RAM
Dynamic RAM (DRAM) Static RAM (SRAM)
DRAM consists of transistors that act SRAM uses ‘flip flops’ which hold each
as switches and capacitors that hold bit of memory.
binary data. SRAM need not be refreshed
DRAM has to be constantly refreshed constantly. SRAM is faster than DRAM.
(every 15 microseconds) to maintain SRAM is used in cache memory.
the charge in the capacitor.
SRAM is more complex to build than
DRAM is used for main RAM memory. 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. teachcomputerscience.co
m
Read only memory 13
(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. Is an
example for non-volatile memory.
teachcomputerscience.co
m
14
Types of ROM
PROM (programmable EPROM (erasable EEPROM (electrically
read-only memory) programmable read- erasable
PROM is manufactured as only memory) programmable read-
blank ROM. The contents of EPROM only memory)
These chips are are erased in exposure EEPROM can be easily
inexpensive and to ultraviolet light. updated by the
programmed by the So, EPROM can be programmer.
programmer for different reprogrammed. EEPROM is widely used
applications. in PCs and
The contents cannot be smartphones where the
changed once developer updates
programmed. applications.
teachcomputerscience.co
m
15
Flash memory
▪ Flash memory is a type of ROM. It is programmed by applying a
slightly large electric current that forces an electron through a
barrier.
Electrons
trapped in Electrons
this layer forced
through
Charge barrier
applied
teachcomputerscience.co
m
16
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 as flash
memory.
▪ Flash memory is also rewritable. teachcomputerscience.co
m
17
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 hard drive is allocated for storing temporary
data. This section of hard disk is called a virtual memory.
teachcomputerscience.co
m
18
Virtual memory
▪ A part of the storage drive is available as RAM temporarily. This
management of memory is performed by the operating system.
▪ A part of RAM that is currently not is use is transferred to the
hard disk and a part of the hard disk that is currently required
by RAM is transferred to RAM.
▪ This process of transferring data between RAM and hard disk is
slow and may affect the performance of computer.
teachcomputerscience.co
m
19
Paging
▪ Swapping (or paging) is the process by which the OS moves data
between RAM and virtual memory.
Hard disk
Virtual
RAM
memory
Paging /
Swapping
teachcomputerscience.co
m
20
Paging
▪ Data that is 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
Let’s review some 21
concepts
Memory Primary memory RAM (Random Access
Memory)
Memory is the space where Primary memory is a type of
data and programs are stored. memory that is accessed RAM is a temporary memory
Data in memory is accessed directly by CPU. which stores data, files and
through instructions from the parts of the operating system
CPU. that is currently in use.
Types of RAM: ROM (Read Only Memory) Virtual memory
DRAM: Made of transistors and Read Only Memory (ROM) is a The section of hard drive that
switches are needs to be permanent memory that is stores data when a computer
refreshed constantly. used to store the instructions has too many processes
that are executed once the running at the same time and
SRAM: Made of flip-flops and
computer is switched ON. the capacity of RAM is not
need not be refreshed.
enough is virtual memory.
teachcomputerscience.co
m
2.
Activity
teachcomputerscience.co
m
23
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
teachcomputerscience.co
m
24
Activity-1
Duration: 10 minutes
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
26
End of topic questions
1. Why is some data copied to the 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?
teachcomputerscience.co
8. What is paging? m