Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
14 views10 pages

UNIT 4 Memory

The document provides an overview of computer memory, detailing its types, features, and classifications, including primary memory (RAM and ROM) and secondary memory. It explains the characteristics and differences between SRAM and DRAM, as well as various types of ROM, such as MROM, PROM, EPROM, EEPROM, and Flash memory. Additionally, it discusses the advantages and disadvantages of RAM and ROM, and outlines different secondary storage devices like hard disks and CDs.

Uploaded by

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

UNIT 4 Memory

The document provides an overview of computer memory, detailing its types, features, and classifications, including primary memory (RAM and ROM) and secondary memory. It explains the characteristics and differences between SRAM and DRAM, as well as various types of ROM, such as MROM, PROM, EPROM, EEPROM, and Flash memory. Additionally, it discusses the advantages and disadvantages of RAM and ROM, and outlines different secondary storage devices like hard disks and CDs.

Uploaded by

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

UNIT 4

UNIT-4 o External memory: The transfer rate of bit or


Computer memory unit is not equal to the word length. It is
Computer memory is any physical device, used to store data, always greater than a word or may be
information or instruction temporarily or permanently. It is the referred to as blocks.
collection of storage units that stores binary information in the
5. Performance: The performance of memory is majorly
form of bits. The memory block is split into a small number of
divided into three parts.
components, called cells. Each cell has a unique address to store
the data in memory, ranging from zero to memory size minus
o Access Time: In random access memory, it
one. represents the total time taken by memory
devices to perform a read or write operation
For example, if the size of computer memory is 64k words, the
that an address is sent to memory.
memory units have 64 * 1024 = 65536 locations or cells. The
o Memory Cycle Time: Total time required to
address of the memory's cells varies from 0 to 65535.
access memory block and additional required
Features of Memory
time before starting second access.
Following are the different features of the memory system that
o Transfer rate: It describes the transfer rate
includes:
of data used to transmit memory to or from
1. Location: It represents the internal or external location
an external or internal memory device. Bit
of the memory in a computer. The internal memory is
transfer can be different for different external
inbuilt in computer memory. It is also known as
and internal devices.
primary memory. the example of primary memory are
registers, cache and main memory. Whereas, external 6. Physical types: It defines the physical type of memory
memory is the separate storage device from the used in a computer such as magnetic, semiconductor,
computer, such as disk, tape, USB pen drive. magneto-optical and optical.
2. Capacity: It is the most important feature of computer 7. Organization: It defines the physical structure of the
memory. Storage capacity can vary in external and bits used in memory.
internal memory. External devices' storage capacity is 8. Physical characteristics: It specifies the physical
measured in terms of bytes, whereas the internal behavior of the memory like volatile, non-volatile or
memory is measured with bytes or words. The storage non-erasable memory. Volatile memory is known as
word length can vary in bits, such as 8, 16 or 32 bits. RAM, which requires power to retain stored
3. Access Methods: Memory can be accessed through information, and if any power loss has occurred, stored
four modes of memory. data will be lost. Non-volatile memory is a permanent
o DMA: As the name specifies, Direct storage memory that is used to obtain any stored
Memory Address (DMA) is a method that information, even when the power is off. Non-erasable
allows input/output (I/O) devices to access or memory is a type of memory that cannot be erased after
retrieve data directly or from the main the manufactured like ROM because at the time of
memory. manufactured ROM are programmed.
o Sequential Access Method: The sequential Classification of Memory
access method is used in a data storage The following figure represents the classification of memory:
device to read stored data sequentially from
the computer memory. Whereas, the data
received from random access memory
(RAM) can be in any order.
o Random Access Method: It is a method
used to randomly access data from memory.
This method is the opposite of SAM. 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.
o Associative Access Method: It is a special
Primary or Main Memory
type of memory that optimizes search
Primary memory is also known as the computer system's main
performance through defined data to directly
memory that communicates directly within the CPU, Auxiliary
access the stored information based on a
memory and the Cache memory. Main memory is used to kept
memory address.
programs or data when the processor is active to use them. When
4. Unit of transfer: As the name suggests, a unit of a program or data is activated to execute, the processor first loads
transfer measures the transfer rate of bits that can be instructions or programs from secondary memory into main
read or write in or out of the memory devices. The memory, and then the processor starts execution. Accessing or
transfer rate of data can be different in external and executing of data from primary memory is faster because it has a
internal memory. cache or register memory that provides faster response, and it is
o Internal memory: The transfer rate of bits is located closer to the CPU. The primary memory is volatile,
mostly equal to the word size. which means the data in memory can be lost if it is not saved

NOTES BY KAVYA SINGH DEPARTMENT CSE


UNIT 4
when a power failure occurs. It is costlier than secondary SRAM Vs. DRAM
memory, and the main memory capacity is limited as compared
to secondary memory. SRAM SRAM DRAM DRAM
The primary memory is further divided into two parts: It is a Static Random-Access It is a Dynamic Random Access
1. RAM (Random Access Memory) Memory. Memory.
2. ROM (Read Only
Memory) Random Access Memory The access time of SRAM is slow. The access time of DRAM is high.
(RAM)
It uses flip-flops to store each bit of It uses a capacitor to store each bit of
Random Access Memory (RAM) is one of the faster types of information. information.
main memory accessed directly by the CPU. It is the hardware in
a computer device to temporarily store data, programs or It does not require periodic
It requires periodically refreshing to
program results. It is used to read/write data in memory until the refreshing to preserve the
preserve the information.
machine is working. It is volatile, which means if a power failure information.
occurs or the computer is turned off, the information stored
It uses in cache memory. It is used in the main memory.
in RAM will be lost. All data stored in computer memory can be
read or accessed randomly at any time. The cost of SRAM is expensive. The cost of DRAM is less expensive.

It has a complex structure. Its structure is simple.


It requires low power consumption. It requires more power consumption.
Advantages of RAM
o It is a faster type of memory in a computer.
o It requires less power to operate.
o Program loads much faster
o More RAM increases the performance of a system and
can multitask.
There are two types of RAM: o Perform read and write operations.
 SRAM o The processor can read information faster than a hard
 DRAM disc, floppy, USB, etc.
DRAM: DRAM (Dynamic Random-Access Memory) is a type
Disadvantages of RAM
of RAM that is used for the dynamic storage of data in RAM. In
o Less RAM reduces the speed and performance of a
DRAM, each cell carries one-bit information. The cell is made up
computer.
of two parts: a capacitor and a transistor. The size of the
o Due to volatile, it requires electricity to preserve the
capacitor and the transistor is so small, requiring millions of them
data.
to store on a single chip. Hence, a DRAM chip can hold more
o It is expensive than ROM
data than an SRAM chip of the same size. However, the capacitor
o It is unreliable as compared to ROM
needs to be continuously refreshed to retain information because
o The Size of RAM is limited.
DRAM is volatile. If the power is switched off, the data store in
memory is lost. Read-Only Memory (ROM)
Advertisement ROM is a memory device or storage medium that is used
Characteristics of DRAM to permanently store information inside a chip. It is a read-only
1. It requires continuously refreshed to retain the data. memory that can only read stored information, data or programs,
2. It is slower than SRAM but we cannot write or modify anything. A ROM contains some
3. It holds a large amount of data important instructions or program data that are required to start or
4. It is the combination of capacitor and transistor boot a computer. It is a non-volatile memory; it means that the
5. It is less expensive as compared to SRAM stored information cannot be lost even when the power is turned
6. Less power consumption off or the system is shut down.
SRAM: SRMA (Static Random-Access Memory) is a type of
RAM used to store static data in the memory. It means to store
data in SRAM remains active as long as the computer system has
a power supply. However, data is lost in SRAM when power
failures have occurred.
Characteristics of Static Ram
1. It does not require to refresh.
2. It is faster than DRAM
3. It is expensive.
4. High power consumption
5. Longer life
6. Large size
7. Uses as a cache memory

Types of ROM

NOTES BY KAVYA SINGH DEPARTMENT CSE


UNIT 4
There are five types of Read Only Memory: 2.It is a slower memory than RAM to access the stored
1. MROM (Masked Read Only Memory): data.
MROM is the oldest type of read-only memory whose 3. It takes around 40 minutes to destroy the existing data
program or data is pre-configured by the integrated using the high charge of ultraviolet light.
circuit manufacture at the time of manufacturing. RAM Vs. ROM
Therefore, a program or instruction stored within the
RAM RAM ROM ROM
MROM chip cannot be changed by the user.
2. PROM (Programmable Read Only Memory): It is a Random-Access Memory. It is a Read Only Memory.
It is a type of digital read-only memory, in which the
user can write any type of information or program only Read and write operations can Only Read operation can be
once. It means it is the empty PROM chip in which the be performed. performed.
user can write the desired content or program only once Data can be lost in volatile Data cannot be lost in non-
using the special PROM programmer or PROM burner memory when the power supply volatile memory when the
device; after that, the data or instruction cannot be is turned off. power supply is turned off.
changed or erased.
3. EPROM (Erasable and Programmable Read Only It is a faster and expensive It is a slower and less expensive
Memory): memory. memory.
It is the type of read only memory in which stored data Storage data requires to be Storage data does not need to
can be erased and re-programmed only once in the refreshed in RAM. be refreshed in ROM.
EPROM memory. It is a non-volatile memory chip that
holds data when there is no power supply and can also The size of the chip is bigger The size of the chip is smaller
store data for a minimum of 10 to 20 years. In EPROM, than the ROM chip to store the than the RAM chip to store the
if we want to erase any stored data and re-programmed data. same amount of data.
it, first, we need to pass the ultraviolet light for 40
Types of RAM: DRAM and Types of ROM: MROM,
minutes to erase the data; after that, the data is re-
SRAM PROM, EPROM, EEPROM
created in EPROM.
4. EEPROM (Electrically Erasable and Secondary Memory
Programmable Read Only Memory): Secondary memory is a permanent storage space to hold a large
The EEROM is an electrically erasable and amount of data. Secondary memory is also known as external
programmable read only memory used to erase stored memory that representing the various storage media (hard drives,
data using a high voltage electrical charge and re- USB, CDs, flash drives and DVDs) on which the computer data
programmed it. It is also a non-volatile memory whose and program can be saved on a long term basis. However, it is
data cannot be erased or lost; even the power is turned cheaper and slower than the main memory. Unlike primary
off. In EEPROM, the stored data can be erased and memory, secondary memory cannot be accessed directly by the
reprogrammed up to 10 thousand times, and the data CPU. Instead of that, secondary memory data is first loaded into
erase one byte at a time. the RAM (Random Access Memory) and then sent to the
5. Flash ROM: processor to read and update the data. Secondary memory
Flash memory is a non-volatile storage memory chip devices also include magnetic disks like hard disk and floppy
that can be written or programmed in small units called disks, an optical disk such as CDs and CDROMs, and magnetic
Block or Sector. Flash Memory is an EEPROM form of tapes.
computer memory, and the contents or data cannot be Features of Secondary Memory
lost when the power source is turned off. It is also used o Its speed is slower than the primary/ main memory.
to transfer data between the computer and digital o Store data cannot be lost due to non-volatile nature.
devices. o It can store large collections of different types, such as
Advantages of ROM audio, video, pictures, text, software, etc.
1. It is a non-volatile memory in which stored information o All the stored data in a secondary memory cannot be
can be lost even power is turned off. lost because it is a permanent storage area; even the
2. It is static, so it does not require refreshing the content power is turned off.
every time. o It has various optical and magnetic memories to store
3. Data can be stored permanently. data.
4. It is easy to test and store large data as compared to Types of Secondary Memory
RAM. The following are the types of secondary memory devices:
5. These cannot be changed accidently Advertisement
6. It is cheaper than RAM. Hard Disk
7. It is simple and reliable as compared to RAM. A hard disk is a computer's permanent storage device. It is a non-
8. It helps to start the computer and loads the OS. volatile disk that permanently stores data, programs, and files,
Disadvantages of ROM and cannot lose store data when the computer's power source is
Advertisement switched off. Typically, it is located internally on computer's
1. Store data cannot be updated or modify except to read motherboard that stores and retrieves data using one or more
the existing data. rigid fast rotating disk platters inside an air-sealed casing. It is a
large storage device, found on every computer or laptop for
NOTES BY KAVYA SINGH DEPARTMENT CSE
UNIT 4
permanently storing installed software, music, text
documentation, videos, operating system, and data until the user
did not delete.

Types of CDs
1. CD-ROM (Compact Disc Read Only Memory): It is
Floppy Disk mainly used for bulk size mass like audio CDs,
A floppy disk is a secondary storage system that consisting of software and computer games at the time of
thin, flexible magnetic coating disks for holding electronic data manufacture. Users can only read data, text, music,
such as computer files. It is also known as Floppy Diskette that videos from the disc, but they cannot modify or burnt
comes in three sizes like 8 inches, 5.5 inches and 3.5 inches. The it.
stored data of a floppy disk can be accessed through the floppy 2. CD-R (Compact Disc Recordable): The type of
disk drive. Furthermore, it is the only way through a new Compact Disc used to write once by the user; after that,
program installed on a computer or backup of the information. it cannot be modified or erased.
However, it is the oldest type of portable storage device, which 3. CD-RW (Compact Disc Rewritable): It is a
can store data up to 1.44 MB. Since most programs were larger, rewritable CD disc, often used to write or delete the
that required multiple floppy diskettes to store large amounts of stored data.
data. Therefore, it is not used due to very low memory storage. DVD Drive/Disc
DVD is an optical disc storage device, stands for Digital Video
Display or Digital Versatile Disc. It has the same size as a CD
but can store a larger amount of data than a compact disc. It was
developed in 1995 by Sony, Panasonic, Toshiba and Philips four
electronics companies. DVD drives are divided into three types,
such as DVD ROM (Read Only Memory), DVD R (Recordable)
and DVD RW (Rewritable or Erasable). It can store multiple data
formats like audio, videos, images, software, operating system,
etc. The storing capacity of data in DVD is 4.7 GB to 17 GB.

CD (Compact Disc)
A CD is an optical disk storage device, stands for Compact Disc.
It is a storage device used to store various data types like audio,
videos, files, OS, Back-Up file, and any other information useful
to a computer. The CD has a width of 1.2 mm and 12 cm in
Blu Ray Disc (BD)
height, which can store approximately 783 MB of data size. It
Blu Ray is an Optical disc storage device used to store a large
uses laser light to read and write data from the CDs.
amount of data or high definition of video recording and playing
other media files. It uses laser technology to read the stored data
of the Blu-ray Disk. It can store more data at a greater density as
compared to CD/ DVD. For example, compact discs allow us to
store 700 MB of data, and in DVDs, it provides up to 8 GB of
storage capacity, while Blu-ray Discs provide 28 GB of space to
store data.
Pen Drive

NOTES BY KAVYA SINGH DEPARTMENT CSE


UNIT 4
A pen drive is a portable device used to permanently store data
 Cost Per Bit. This metric represents dividing the
and is also known as a USB flash drive. It is commonly used to overall memory cost by the total number of bits
store and transfer the data connected to a computer using a USB accessed.
port. It does not have any moveable part to store the data; it uses
an integrated circuit chip that stores the data. It allows the users
Each characteristic either increases or decreases, going from CPU
to store and transfer data like audio, videos, images, etc. from one
registers (level 0) to the fourth level, as represented in the table
computer to any USB pen drive. The storing capacity of pen
below:
drives from 64 MB to 128 GB or more.

Characteristics From Level 0 to Level 4

Performance Decreases

Capacity Increases

Access Time Decreases

Cost per Bit Increases

2D and 2.5D Memory organization


Memory Hierarchy Design The internal structure of Memory either RAM or ROM is made
Memory hierarchy optimizes data access and storage. Design up of memory cells that contain a memory bit. A group of 8 bits
choices depend on the specific computer architecture, intended makes a byte. The memory is in the form of a multidimensional
use, and the trade-off between speed, capacity, and cost. array of rows and columns. In which, each cell stores a bit and a
Memory hierarchy design creates levels of memory based on complete row contains a word. A memory simply can be divided
different types and their characteristics. The memory hierarchy into this below form.
design looks like this:
 Level 0: Registers. 2n = N
 Level 1: Cache. where n is the no. of address lines and N is the total memory in
 Level 2: Main memory. bytes.
 Level 3: Secondary memory, magnetic disks, or solid- There will be 2n words.
state memory.
 Level 4: Tertiary memory.
2D Memory organization –
In 2D organization, memory is divided in the form of rows and
columns(Matrix). Each row contains a word, now in this memory
organization, there is a decoder. A decoder is a combinational
circuit that contains n input lines and 2n output lines. One of the
output lines selects the row by the address contained in the MAR
and the word which is represented by that row gets selected and
is either read or written through the data lines.

Memory Hierarchy Characteristics

The hierarchy is based on characteristics which optimally balance


performance, capacity, and cost:

 Performance. Increases when users need to access


lower memory hierarchy levels less frequently. Without
the memory hierarchy, a speed gap exists between the
main memory and CPU registers.
 Capacity. Represents a volume of information the
memory is able to store.
 Access Time. The interval between the read/write
request and the data availability. 2.5D Memory organization –
In 2.5D Organization the scenario is the same but we have two

NOTES BY KAVYA SINGH DEPARTMENT CSE


UNIT 4
different decoders one is a column decoder and another is a row Disadvantages:
decoder. Column decoder is used to select the column and a row Limited Bandwidth: 2D memory organization has limited
decoder is used to select the row. The address from the MAR bandwidth due to the sequential access pattern of memory chips,
goes as the decoders’ input. Decoders will select the respective which can lead to slower data transfer rates.
cell through the bit outline, then the data from that location will Limited Capacity: 2D memory organization has limited
be read or through the bit, inline data will be written at that capacity since it requires memory chips to be arranged in a two-
memory location. dimensional grid, limiting the number of memory chips that can
be used.
Limited Scalability: 2D memory organization is not scalable,
making it difficult to increase memory capacity or performance
without adding more memory chips.

2.5D Memory Organization:

Advantages:
Higher Bandwidth: 2.5D memory organization has higher
bandwidth since it uses a high-speed interconnect between
memory chips, enabling faster data transfer rates.
Higher Capacity: 2.5D memory organization has higher
capacity since it can stack multiple memory chips on top of each
other, enabling more memory to be packed into a smaller space.
Scalability: 2.5D memory organization is highly scalable,
making it easier to increase memory capacity or performance
without adding more memory chips.
Disadvantages:
Read and Write Operations –
Complexity: 2.5D memory organization is more complex than
1. If the select line is in Reading mode then the Word/bit which
2D memory organization since it requires additional
is represented by the MAR will be available to the data lines
interconnects and packaging technologies.
and will get read.
Higher Cost: 2.5D memory organization is generally more
2. If the select line is in write mode then the data from the
expensive than 2D memory organization due to the additional
memory data register (MDR) will be sent to the respective
interconnects and packaging technologies required.
cell which is addressed by the memory address register
Higher Power Consumption: 2.5D memory organization has
(MAR).
higher power consumption due to the additional interconnects
3. With the help of the select line, we can select the desired data
and packaging technologies, making it less ideal for use in
and we can perform read and write operations on it.
mobile devices and other low-power electronics.

Comparison between 2D & 2.5D Organizations –


1. In 2D organization hardware is fixed but in 2.5D hardware
Cache Memory:
changes.
2. 2D Organization requires more gates while 2.5D requires less.
3. 2D is more complex in comparison to the 2.5D organization. Cache memory is a high-speed memory, which is small in size
4. Error correction is not possible in the 2D organization but in but faster than the main memory (RAM). The CPU can access it
more quickly than the primary memory. So, it is used to
2.5D it could be done easily.
5. 2D is more difficult to fabricate in comparison to the 2.5D synchronize with high-speed CPU and to improve its
organization. performance.

2D Memory Organization:

Advantages:
Simplicity: 2D memory organization is a simple and
straightforward approach, with memory chips arranged in a two-
dimensional grid.
Cost-Effective: 2D memory organization is cost-effective,
making it a popular choice for many low-power and low-cost
devices.
Low Power: 2D memory organization has low power
consumption, making it ideal for use in mobile devices and other
portable electronics. Cache memory can only be accessed by CPU. It can be a
reserved part of the main memory or a storage device outside the
CPU. It holds the data and programs which are frequently used

NOTES BY KAVYA SINGH DEPARTMENT CSE


UNIT 4
by the CPU. So, it makes sure that the data is instantly available for the data in primary memory. retain the data in secondary
CPU whenever the CPU needs this data. In other words, if the CPU memory.
finds the required data or instructions in the cache memory, it doesn't
need to access the primary memory (RAM). Thus, by acting as a Examples of primary memory Examples of secondary
buffer between RAM and CPU, it speeds up the system performance. are RAM, ROM, Registers, memory are CD, DVD, HDD,
EPROM, PROM and cache magnetic tapes, flash disks, pen
memory. drive, etc.
Types of Cache Memory:
Cache Performance
When the processor needs to read or write a location in the
1. L1 Cache: The L1 cache is also known as the onboard, main memory, it first checks for a corresponding entry in the
internal, or primary cache. It is built with the help of cache. If the processor finds that the memory location is in the
the CPU. Its speed is very high, and the size of the L1 cache,
cache varies from 8 KB to 128 KB. a Cache Hit has occurred and data is read from the cache.
2. L2 Cache: It is also known as external or secondary If the processor does not find the memory location in the cache,
cache, which requires fast access time to store a cache miss has occurred. For a cache miss, the cache allocates
temporary data. It is built into a separate chip in a a new entry and copies in data from the main memory, then the
motherboard, not built into the CPU like the L1 level. request is fulfilled from the contents of the cache.
The size of the L2 cache may be 128 KB to 1 MB. The performance of cache memory is frequently measured in
3. L3 Cache: L3 cache levels are generally used with terms of a quantity called Hit ratio.
high performance and capacity of the computer. It is Hit Ratio(H) = hit / (hit + miss) = no. of hits/total accesses
built into a motherboard. Its speed is very slow, and the Miss Ratio = miss / (hit + miss) = no. of miss/total accesses = 1 -
maximum size up to 8 MB. hit ratio(H)
Advantages of Cache Memory We can improve Cache performance using higher cache block
1. Cache memory is the faster memory as compared to the size, and higher associativity, reduce miss rate, reduce miss
main memory. penalty, and reduce the time to hit in the cache.
2. It stores all data and instructions that are repeatedly Cache Mapping
used by the CPU for improving the performance of a There are three different types of mapping used for the purpose
computer. of cache memory which is as follows:
3. The access time of data is less than the main memory. 1. Direct Mapping
Disadvantage of Cache Memory 2. Associative Mapping
1. It is very costly as compared to the Main memory and 3. Set-Associative Mapping
the Secondary memory. 1. Direct Mapping
2. It has limited storage capacity. The simplest technique, known as direct mapping, maps each
Register Memory block of main memory into only one possible cache line. or In
The register memory is a temporary storage area for storing and Direct mapping, assign each memory block to a specific line in
transferring the data and the instructions to a computer. It is the the cache. If a line is previously taken up by a memory block
smallest and fastest memory of a computer. It is a part of when a new block needs to be loaded, the old block is trashed.
computer memory located in the CPU as the form of registers. An address space is split into two parts index field and a tag
The register memory is 16, 32 and 64 bits in size. It temporarily field. The cache is used to store the tag field whereas the rest is
stores data instructions and the address of the memory that is stored in the main memory. Direct mapping`s performance is
repeatedly used to provide faster response to the CPU. directly proportional to the Hit ratio.
Primary Vs. Secondary Memory i = j modulo m
Primary Primary Secondary Memo Secondary where
Memory ry i = cache line number
j = main memory block number
It is also known as temporary It is also known as a permanent m = number of lines in the cache
memory. memory.

Data cannot be accessed


Data can be access directly by
directly by the I/O processor or
the processor or CPU.
CPU.

Stored data can be a volatile or The nature of secondary


non-volatile memory. memory is always non-volatile.

It is more costly than secondary It is less costly than primary


memory. memory.

It is a faster memory. It is a slower memory. Direct Mapping


For purposes of cache access, each main memory address can be
It has limited storage capacity. It has a large storage capacity. viewed as consisting of three fields. The least significant w bits
It required the power to retain It does not require power to identify a unique word or byte within a block of main memory. In
most contemporary machines, the address is at the byte level. The
remaining s bits specify one of the 2 s blocks of main memory.

NOTES BY KAVYA SINGH DEPARTMENT CSE


UNIT 4
The cache logic interprets these s bits as a tag of s-r bits (the most associative mapping the index bits are given by the set offset bits.
significant portion) and a line field of r bits. This latter field In this case, the cache consists of a number of sets, each of which
identifies one of the m=2 r lines of the cache. Line offset is index consists of a number of lines.
bits in the direct mapping.

Set-Associative Mapping
Relationships in the Set-Associative Mapping can be defined as:
m=v*k
i= j mod v

where
i = cache set number
j = main memory block number
v = number of sets
m = number of lines in the cache number of sets
k = number of lines in each set
Direct Mapping – Structure
2. Associative Mapping
In this type of mapping, associative memory is used to store the
content and addresses of the memory word. Any block can go
into any line of the cache. This means that the word id bits are
used to identify which word in the block is needed, but the tag
becomes all of the remaining bits. This enables the placement of
any word at any place in the cache memory. It is considered to be
the fastest and most flexible mapping form. In associative
mapping, the index bits are zero.

Set-Associative Mapping – Structure


For more, you can refer to the Difference between Types of
Cache Mapping .
Application of Cache Memory
Here are some of the applications of Cache Memory.
Primary Cache: A primary cache is always located on the
processor chip. This cache is small and its access time is
comparable to that of processor registers.
Secondary Cache: Secondary cache is placed between the
primary cache and the rest of the memory. It is referred to as the
level 2 (L2) cache. Often, the Level 2 cache is also housed on the
processor chip.
Associative Mapping – Structure Spatial Locality of Reference: Spatial Locality of
3. Set-Associative Mapping Reference says that there is a chance that the element will be
This form of mapping is an enhanced form of direct mapping present in close proximity to the reference point and next time if
where the drawbacks of direct mapping are removed. Set again searched then more close proximity to the point of
associative addresses the problem of possible thrashing in the reference.
direct mapping method. It does this by saying that instead of Temporal Locality of Reference: Temporal Locality of
having exactly one line that a block can map to in the cache, we Reference uses the Least recently used algorithm will be used.
will group a few lines together creating a set . Then a block in Whenever there is page fault occurs within a word will not only
memory can map to any one of the lines of a specific set. Set- load the word in the main memory but the complete page fault
associative mapping allows each word that is present in the cache will be loaded because the spatial locality of reference rule says
can have two or more words in the main memory for the same that if you are referring to any word next word will be referred to
index address. Set associative cache mapping combines the best in its register that’s why we load complete page table so the
of direct and associative cache mapping techniques. In set complete block will be loaded.

NOTES BY KAVYA SINGH DEPARTMENT CSE


UNIT 4
Advantages
Cache Memory is faster in comparison to main memory and
secondary memory.
Programs stored by Cache Memory can be executed in less time.
The data access time of Cache Memory is less than that of the
main memory.
Cache Memory stored data and instructions that are regularly
used by the CPU, therefore it increases the performance of the
CPU.
Disadvantages
Cache Memory is costlier than primary memory and secondary
memory .
Data is stored on a temporary basis in Cache Memory.
Whenever the system is turned off, data and instructions stored in
cache memory get destroyed.
The high cost of cache memory increases the price of the
Computer System.
Page Replacement Algorithms
Page replacement algorithms are techniques used in operating
systems to manage memory efficiently when the virtual FIFO – Page Replacement
memory is full. When a new page needs to be loaded Initially, all slots are empty, so when 1, 3, 0 came they are
into physical memory , and there is no free space, these allocated to the empty slots —> 3 Page Faults.
algorithms determine which existing page to replace. when 3 comes, it is already in memory so —> 0 Page Faults.
If no page frame is free, the virtual memory manager performs a Then 5 comes, it is not available in memory so it replaces the
page replacement operation to replace one of the pages existing oldest page slot i.e 1. —> 1 Page Fault. 6 comes, it is also not
in memory with the page whose reference caused the page fault. available in memory so it replaces the oldest page slot i.e 3 —> 1
It is performed as follows: The virtual memory manager uses a Page Fault. Finally, when 3 come it is not available so it replaces
page replacement algorithm to select one of the pages currently
2. Optimal Page Replacement
in memory for replacement, accesses the page table entry of the
In this algorithm, pages are replaced which would not be used for
selected page to mark it as “not present” in memory, and initiates
the longest duration of time in the future.
a page-out operation for it if the modified bit of its page table
Example-2: Consider the page references 7, 0, 1, 2, 0, 3, 0, 4, 2,
entry indicates that it is a dirty page.
3, 0, 3, 2, 3 with 4 page frame. Find number of page fault using
Common Page Replacement Techniques
Optimal Page Replacement Algorithm.
1. First In First Out (FIFO)
2. Optimal Page replacement
3. Least Recently Used (LRU)
4. Most Recently Used (MRU)
1. First In First Out (FIFO)
This is the simplest page replacement algorithm. In this
algorithm, the operating system keeps track of all pages in the
memory in a queue, the oldest page is in the front of the queue.
When a page needs to be replaced page in the front of the queue
is selected for removal.
Example 1: Consider page reference string 1, 3, 0, 3, 5, 6, 3 with
3 page frames.Find the number of page faults using FIFO Page
Replacement Algorithm. Optimal Page Replacement
Initially, all slots are empty, so when 7 0 1 2 are allocated to the
empty slots —> 4 Page faults
0 is already there so —> 0 Page fault. when 3 came it will take
the place of 7 because it is not used for the longest duration of
time in the future.—> 1 Page fault. 0 is already there so —> 0
Page fault. 4 will takes place of 1 —> 1 Page Fault.
Now for the further page reference string —> 0 Page
fault because they are already available in the memory. Optimal
page replacement is perfect, but not possible in practice as the
operating system cannot know future requests. The use
of Optimal Page replacement is to set up a benchmark so that
other replacement algorithms can be analyzed against it.

NOTES BY KAVYA SINGH DEPARTMENT CSE


UNIT 4
3. Least Recently Used
In this algorithm, page will be replaced which is least recently
used. Virtual Memory
Example-3: Consider the page reference string 7, 0, 1, 2, 0, 3, 0,
4, 2, 3, 0, 3, 2, 3 with 4 page frames. Find number of page faults Virtual memory in computer architecture plays a crucial
using LRU Page Replacement Algorithm. role by expanding available memory beyond physical
limits. This innovative concept allows efficient
multitasking, enhancing system performance and enabling
smoother operations.

Virtual memory optimizes resource allocation by


combining hardware and software, ensuring seamless
execution of diverse applications simultaneously.

Concept & Purpose Of Virtual Memory

Least Recently Used – Page Replacement To begin with, let us understand the concept and purpose
Initially, all slots are empty, so when 7 0 1 2 are allocated to the of virtual memory:
empty slots —> 4 Page faults
0 is already their so —> 0 Page fault. when 3 came it will take Technique In Operating Systems
the place of 7 because it is least recently used —> 1 Page fault
0 is already in memory so —> 0 Page fault . Virtual memory is a technique used in computer
4 will takes place of 1 —> 1 Page Fault architecture to create an illusion of having more memory
Now for the further page reference string —> 0 Page fault
by allowing programs to access more memory than is
physically available.
because they are already available in the memory.
4. Most Recently Used (MRU) Virtual memory provides an essential abstraction layer that
In this algorithm, page will be replaced which has been used enables programs to execute as if they have continuous
recently. Belady’s anomaly can occur in this algorithm. access to a large memory block, even with fragmented or
Example 4: Consider the page reference string 7, 0, 1, 2, 0, 3, 0, limited physical memory. This abstraction simplifies
4, 2, 3, 0, 3, 2, 3 with 4 page frames. Find number of page faults programming and enhances system performance.
using MRU Page Replacement Algorithm.
Efficient Resource Utilization

By utilizing virtual memory, multiple processes can run


concurrently without needing dedicated physical memory
for each process. This efficient utilization of resources
ensures that the system can handle various tasks
simultaneously, improving overall system performance.

Advantages & Disadvantages Of Virtual Memory


Most Recently Used – Page Replacement Let us study the advantages and disadvantages of virtual
Initially, all slots are empty, so when 7 0 1 2 are allocated to the memory in computer architecture:
empty slots —> 4 Page faults
0 is already their so–> 0 page fault Advantages Of Virtual Memory
when 3 comes it will take place of 0 because it is most recently
used —> 1 Page fault Increased multitasking: Virtual memory allows multiple
when 0 comes it will take place of 3 —> 1 Page fault programs to run simultaneously, enhancing productivity.
when 4 comes it will take place of 0 —> 1 Page fault
2 is already in memory so —> 0 Page fault Efficient use of physical memory: Virtual memory
when 3 comes it will take place of 2 —> 1 Page fault enables the system to utilize physical memory more
when 0 comes it will take place of 3 —> 1 Page fault effectively by swapping data in and out as needed.
when 3 comes it will take place of 0 —> 1 Page fault
Larger memory space: With virtual memory,
when 2 comes it will take place of 3 —> 1 Page fault
applications can access a larger memory space than the
when 3 comes it will take place of 2 —> 1 Page fault
physical RAM available.

Disadvantages Of Virtual Memory

Performance impact: Constant data swapping between


physical memory and the hard drive can slow system
performance.

NOTES BY KAVYA SINGH DEPARTMENT CSE

You might also like