0% found this document useful (0 votes)
57 views42 pages

Chapter-3 Edited

Uploaded by

dawitsibhat37
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views42 pages

Chapter-3 Edited

Uploaded by

dawitsibhat37
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

Chapter-3 Memory Systems

Contents
Characteristics and hierarchy of memory
systems
Cache memory
Main memory
Secondary memory
Virtual memory
Memory management
Characteristics of Memory System
• The memory unit is a essential
component in any digital computer since
it is needed for storing programs and
data.
1.Location : It represents the internal or
external location of the memory in a
computer. The internal memory is inbuilt in
computer memory.
• CPU: Registers
• Internal: Main memory and cache
• External: Storage devices (tapes, discs,
USB pen drive)
Characteristics of Memory System
2. Capacity
It is the most important feature of computer
memory. Storage capacity can vary in external
and internal memory. External devices'
storage capacity is measured in terms of Giga
bytes, whereas the internal memory is
measured with bytes or words. The storage
word length can vary in bits, such as 8, 16 or
32 bits.
Characteristics of Memory System
3.Unit of Transfer

As the name suggests, a unit of transfer measures the transfer rate of

bits that can be read or write in or out of the memory devices. The

transfer rate of data can be different in external and internal memory.

o Internal memory: The transfer rate of bits is mostly equal to the

word size and usually governed by data bus width.

o External memory: The transfer rate of bit or unit is not equal to the

word length. It is always greater than a word or may be referred to

as blocks and usually a block which is much larger than a word


• Addressable unit
 Smallest location which can be uniquely addressed
 Some systems have only word addressable memory while many have
byte addressable memory
 A block or even cluster of blocks on most disks
Characteristics of Memory System
4.Method of Accessing
Memory can be accessed through four modes of
memory.
a) Sequential Access: The sequential access method is
used in a data storage device to read and stored
data sequentially from the external memory.
Whereas, the data received from random access
memory (RAM) can be in any order.
Memory is organized into units of data called,
records.
Access must be in specific linear sequence and a
shared read write mechanism is used.
Characteristics of Memory System
b) Direct Access
is a method that allows input/output (I/O)
devices to access or retrieve data
directly from the main memory.
Individual blocks have unique address
based on physical location.
Access is by jumping to vicinity plus
sequential search to reach the final
location
Access time depends on location and
previous location.
Characteristics of Memory System
c) Random Access
It is a method used to randomly access data
from memory. For example, to go from A to
Z in random access, we can directly jump to
any specified location.
In the Sequential method, we have to follow
all intervening from A to Z to reach at the
particular memory location.
Individual addresses identify locations
exactly.
Access time is independent of location or
previous access and is constant (example:
Characteristics of Memory System
d) Associative Memory: It is a special type of memory that
optimizes search performance through defined data to
directly access the stored information based on a
memory address.
 The word is retrieved based on a portion of its contents
rather than its address.
 Access time is independent of location or previous
access (cache memory)
5. Performance
From user’s perspective the most important
characteristics of memory are capacity and
performance. Three performance parameters:
 Access time
 Cycle Time
 Transfer Rate
Characteristics of Memory System
Access time: In random access memory, it
represents the total time taken by memory devices
to perform a read or write operation that an
address is sent to memory.
• For RAM, time is the time between presenting an
address to memory and getting the data on the
bus.
• For other memories the largest component is
positioning the read/write mechanism.
Memory Cycle Time: Total time required to
access memory block and additional required time
before starting second access.
• Function of memory components and system
bus, not the processor.
Characteristics of Memory System
Transfer rate: It describes the transfer rate of data used to
transmit memory to or from an external or internal
memory device.
Bit transfer can be different for different external and
internal devices.
 This is the rate at which data can be transferred into
or out of a memory unit.
 For random access:
[Transfer rate = 1/cycle time]
 For non random access memory:
TN= Ta+ n/R
Where: TN= the average time to read or write N-bits
Ta=average access time
n=number of bits
Characteristics of Memory System
6. Physical Types: It defines the physical type of
memory used in a computer such as magnetic,
semiconductor, magneto-optical and optical.
• Semiconductor
 RAM
• Magnetic Surface Memory
 Disk & Tape
• Optical
 CD & DVD
Characteristics of Memory System
7. Physical Characteristics
Volatility
• Does the memory retain data in the absence of
electrical power?
Erasable
• Can the memory be rewritten? If so, how fast? How
many erase cycles can occur?
Power consumption
Category of memory
Hierarchy of Memory
• The design constraints on computers
memory can be summed up by three
questions:
1.How much? =Capacity
2.How fast?=access time
3.How expensive? =cost
•Memory systems can be implemented by
variety of technologies, across this spectrum of
technologies, the following relationships holds:
Faster access time, greater cost per bit
Greater capacity, smaller cost per bit
Greater capacity, slower access time
Hierarchy of Memory
Hierarchy of Memory
• As one goes down the hierarchy
Decrease cost per bit
Increasing capacity
Increasing access time
Decrease frequency of access of the
memory by the processor
Registers
• Register are used to quickly accept, store,
and transfer data and instructions that are
being used immediately by the CPU.
• There are various types of Registers those
are used for various purpose.
Register
is used for holding variables and temporary results.
Accessing data from the register is the fastest way to access
memory.
Registers are high-speed storage areas within the CPU, but
have the least storage capacity.
Registers are not referenced by their address, but are directly
accessed and manipulated by the CPU during instruction
execution.
Registers store data, instructions, addresses and
intermediate results of processing.
The data and instructions that require processing must be
brought in the registers of CPU before they can be processed.
For example, if two numbers are to be added, both numbers
are brought in the registers, added and the result is also
placed in a register.
Register
Among of the some Mostly used Registers Accumulator
(AC) : stores the result of arithmetic and logic operations.
Instruction Register (IR) : contains the current instruction
most recently fetched.
Program Counter (PC): contains the address of next
instruction to be processed.
Memory Address Register (MAR): contains the address of
next location in the memory to be accessed.
Memory Buffer Register (MBR): temporarily stores data
from memory or the data to be sent to memory.
Data Register (DR) : stores the operands and any other
data.
For processing, it is required that the data and instructions
are accessed from the RAM and stored in the registers.
The time taken to move the data between RAM and CPU
registers is large. This affects the speed of processing of
computer, and results in decreasing the performance of CPU.
Cache Memory
Cache memory is increases the speed of processing which
placed between RAM and CPU.
During processing, CPU first checks cache for the required data.
If data is not found in cache, then it looks in the RAM for data.
To access the cache memory, CPU does not have to use the
motherboard’s system bus for data transfer.
(The data transfer speed slows to the motherboard’s capability,
when data is passed through system bus. CPU can process data
at a much faster rate by avoiding the system bus.)
Instead of pulling it every time from the RAM, it is put in cache
for fast access. Cache is further classified to L1, L2 and L3
Cache Memory
1.L1 Cache: is also known as the onboard, internal, or primary
cache. It is built with the CPU. Its speed is very high, and the
size of the L1 cache varies from 8 KB to 128 KB. It is accessed
without any delay.

2.L2 Cache: It is also known as external or secondary cache,


which requires fast access time to store temporary data. It is
built into a separate chip in a motherboard, not built into the
CPU like the L1 level. The size of the L2 cache may be 128 KB
to 1 MB. It takes more clock cycles to access than L1 cache
L3 Cache: is generally used with high performance and capacity
of the computer. It is built into a motherboard. Its speed is very
slow, and the maximum size up to 8 MB. It takes more clock
cycles to access than L2 cache.
Cache Memory
• May be located on CPU chip or module
• When processor attempts to read a word from
memory, cache is checked first
• It is used to hold those parts of data and
program which are most frequently used by
CPU.
• The parts of data and programs are transferred
from disk to cache memory by operating
system, from where CPU can access them.
Cache Memory
The advantages of cache memory are as
follows:
• Cache memory is faster than main
memory.
• It consumes less access time as compared
to main memory.
• It stores the program that can be executed
within a short period of time.
• It stores data for temporary use.
The disadvantages:
• Cache memory has limited capacity.
Cache Memory
Cache Performance: When the processor needs to
read or write a location in main memory, it first
checks for a corresponding entry in the cache.
• If the processor finds that the memory location is in
the cache, a cache hit has occurred and data is read
from cache
• If the processor does not find the memory location
in the cache, a cache miss has occurred.
For a cache miss, the cache allocates a new entry and
copies in data from main memory, then the request is
fulfilled from the contents of the cache. The
performance of cache memory is frequently measured
in terms of a quantity called Hit ratio.
Hit ratio = hit / (hit + miss) = no. of hits/total
accesses
Cache Memory
Cache Mapping: There are three different types
of mapping used for the purpose of cache memory in
order to answer the following questions.
1. When we copy a block of data from main memory
to the cache, where exactly should we put it?
2. How can we know if a word is already in the cache,
or if it has to be fetched from main memory first?
3. Eventually, the small cache memory might fill up.
To load a new block from main RAM, we’d have to
replace one of the existing blocks in the cache...
which one?
Direct mapping,
Associative mapping,
Set-Associative mapping.
Cache Memory
Direct mapping
Caches are divided into blocks, which may be of
various sizes. The number of blocks in a cache is
usually a power of 2.
In this technique each block from main memory
has only one possible place in the cache
organization. It has three fields like Tag,
Block/index, and Word/block offset.
Word: Number bits required to identify a
particular word with in the block.
Index: Number of bits required to identify the
block number in cache memory where a main
memory block will be placed.
Tags: which supply the rest of the address bits to
Cache Memory
For example, on the below figure is a 16-byte main memory and a 4-
byte cache (four 1-byte blocks). Memory locations 0, 4, 8 and 12 all
map to cache block 0. Addresses 1, 5, 9 and 13 map to cache block
1, etc. How can we compute this mapping?

j = i modulo m
Where:
i = main memory block number
j = cache block number
m = number of blocks in the cache
Cache Memory
Example
A computer system uses 16-bit memory addresses. It has a
2K-byte cache organized in a direct-mapped manner with 64
bytes per cache block. Assume that the size of each memory
word is 1 byte.
Calculate the number of bits in each of the Tag, Block/index,
and Word/block offset fields of the memory address.
Solution
Block size = 64 bytes = 2^6 bytes = 2^6 words (since 1 word = 1 byte)
Therefore, Number of bits in the Word field = 6
Cache size = 2K-byte = 2^11 bytes; Number of cache blocks = Cache
size / Block size = 2^11/2^6 = 2^5 Therefore, Number of bits in the
Block field = 5
Total number of address bits = 16
Therefore, Number of bits in the Tag field = 16 - 6 - 5 = 5
For a given 16-bit address, the 5 most significant bits, represent the Tag,
the next 5 bits represent the Block, and the 6 least significant bits
represent the Word/block offset.
Cache Memory
Associative Mapping: Here the mapping of the main memory block can be
done with any of the cache block. The memory address has only 2 fields; word
& tag. This technique is also called as fully associative cache mapping.
Example
Consider a fully associative mapped cache of size 16 KB with block size 256
bytes. The size of main memory is 128 KB. Find Number of bits in tag field.
Solution
Given
Cache memory size = 16 KB
Block size = Frame size = Line size = 256 bytes
Main memory size = 128 KB
We consider that the memory is byte addressable.
Number of Bits in Physical Address
Size of main memory = 128 KB = 2^17 bytes Thus, Number of bits in physical
address = 17 bits
Number of Bits in Block Offset
Block size = 256 bytes = 2^8 bytes Thus, Number of bits in block offset = 8
bits
Number of Bits in Tag
Number of bits in tag = Number of bits in physical address – Number of bits in
Cache Memory
Set-Associative Mapping: It is the combination of advantages of both
direct & associative mapping. Here, the cache consists of a number
sets, each of which consists of a number of blocks.
Example: Consider a 2-way set associative mapped cache of size 16
KB with block size 256 bytes. The size of main memory is 128 KB. Find
Number of bits in tag.
Solution

Given
Set size = 2
Cache memory size = 16 KB
Block size = Frame size = Line size = 256 bytes
Main memory size = 128 KB
We consider that the memory is byte addressable.
Number of Bits in Physical Address
Size of main memory = 128 KB = 217 bytes
Cache Memory
Number of Bits in Block Offset
Block size = 256 bytes = 28 bytes
Thus, Number of bits in block offset = 8 bits

Number of Lines in Cache


Total number of lines in cache = Cache size / Line size = 16 KB / 256 bytes =
214 bytes / 28 bytes = 64 lines
Thus, Number of lines in cache = 64 lines

Number of Sets in Cache


Total number of sets in cache= Total number of lines in cache / Set size = 64 /
2= 32 sets = 25 sets
Thus, Number of bits in set number = 5 bits
Cache Memory
Number of Bits in Tag
Number of bits in tag = Number of bits in physical
address – (Number of bits in set number + Number of bits
in block offset)
= 17 bits – (5 bits + 8 bits)
= 17 bits – 13 bits
= 4 bits
Thus, Number of bits in tag = 4 bits
Cache Memory
Cache Memory
Exercise: Consider a 4-way set associative mapped cache. The size of main
memory is 64 MB and there are 10 bits in the tag. Find the size of cache memory.
Main Memory
• Main memory/primary memory holds
only those data and instructions on which
computer is currently working.
• It is generally made up of semiconductor
device.
• These memories are not as fast as
registers.
• The data and instruction required to be
processed reside in main memory. It is
divided into two subcategories RAM and
ROM.
RAM
DRAM is the most common type of memory chip.
It uses transistors and capacitors. The transistors are arranged in a matrix
of rows and columns. The capacitor holds the bit of information 0 and 1.
DRAM must be refreshed continually to store information. For this, a
memory controller is used.
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.
It stores information as long as it is supplied with power.
ROM
ROM comes programmed by the manufacturer. It stores standard
processing programs that permanently reside in the computer.
ROM stores the data needed for the start up of the computer. The
instructions that are required for initializing the devices attached to a
computer are stored in ROM.
The ROM memory chip stores the Basic Input Output System (BIOS).
Types of ROM
PROM
EPROM
EEPROM
Main/Primary/Internal Memory
• There is one major difference between a
ROM and a RAM chip.
• A ROM chip is non-volatile storage and
does not require a constant source of
power to retain information stored on it.
• When power is lost or turned off, a ROM
chip will keep the information stored on it.
• In contrast, a RAM chip is volatile and
requires a constant source of power to
retain information.
• When power is lost or turned off, a RAM
chip will lose the information stored on it.
Cont.….
Characteristics of Main Memory
• These are semiconductor memories
• It is known as main memory.
• Usually volatile memory.
• Data is lost in case power is switched off.
• It is working memory of the computer.
• Faster than secondary memories.
• A computer cannot run without primary
memory
Secondary Memory
• This type of memory is also known as external
memory or non-volatile. It is slower than main
memory.
• These are used for storing data/Information
permanently. CPU directly does not access these
memories instead they are accessed via input-
output routines.
• Contents of secondary memories are first transferred
to main memory, and then CPU can access it.
• Magnetic tape drives, magnetic disk drives, optical
disk drives are the different types of storage
devices.
Secondary Memory
The list of steps that the computer performs from the time it is switched on are:
1.Turn the computer on.
2.The computer loads data from ROM. It makes sure that all
the major components of the computer are functioning
properly.
3.The computer loads the BIOS from ROM. The BIOS provides
the most basic information about storage devices, boot
sequence, security, plug and play capability and other items.

4.The computer loads the OS from the hard drive into the
system’s RAM. CPU has immediate access to the OS as the
critical parts of the OS are maintained in RAM as long as the
computer is on.
This enhances the performance and functionality of the
overall system.
5.Now the system is ready for use.
Secondary Memory
6.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 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.

7.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.
Secondary Memory
8.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.

9.If the files are not saved to a storage device before


being closed, they are lost.

10.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.

You might also like