Memory Unit3
Memory Unit3
System
Module 3
Table of content
3.1 : 68 pages
3.2 : 19 pages
3.3 : 13 pages
3.4 : 3 pages
What is Computer Memory?
• Computer memory is just like the human brain.
• It is used to store data/information and instructions.
• It is a data storage unit or a data storage device where data is to be processed and
instructions which are required for processing are stored.
• It can store both the input and output.
It is used to store data temporarily (in case of RAM). It is used to store data permanently.
Examples are RAM and ROM. Examples are hard disk, CD, DVD, flash drive etc.
In general, referring to the computer memory usually means the internal memory.
Internal Memory
The key features of internal memory are:
1. Limited storage capacity.
2. Temporary storage.
3. Fast access.
4. High cost.
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 4MB.
Any program or data that has to be executed must be brought into RAM from the secondary
memory.
Cache is relatively faster than primary memory.
The speed of RAM is around 60ns. The RAM size varies from 512KB to 64GB
Secondary Memory
The key features of secondary memory storage devices are:
1. Very high storage capacity.
2. Permanent storage (non-volatile), unless erased by user.
3. Relatively slower access.
4. Stores data and instructions that are not currently being used by CPU but may be required
later for processing.
5. Cheapest among all memory.
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
• Secondary memory is the farthest from CPU (large capacity, low cost, low speed)
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.
CPU Registers and Their Functions
Registers in CPU are of different types that each do a specific job when the computer follows instructions.
Let’s explore the primary types of CPU registers and their respective functions:
•Data Registers: Data registers, also called general-purpose registers, hold information while the computer
works on it. They are really important for doing math and logical tasks on the CPU.
•Address Registers: Address registers keep track of where information is stored in memory. As well as
making it easier for the computer to find and use data. They help move information between the CPU and
memory smoothly.
•Control Registers: Control registers in CPU helps to manage things like interruptions, how programs run,
and the status of the system. They also make sure all parts of the CPU work together smoothly.
•Special Purpose Registers: Some registers have specific jobs, like the Program Counter (PC). Which also
remembers where the next instruction is stored in memory for the CPU to use.
Types of CPU Registers
CPU registers are sorted into different types based on what they do and how they are used inside the CPU. So,
here are some common types of CPU registers:
1. Data Registers
•Accumulator (ACC): Holds numbers for math and logic.
•General-Purpose Registers (GPRs): Can hold different types of info during programs, like numbers or
addresses.
2. Address Registers
•Memory Address Register (MAR): Keeps track of where data or instructions are stored in memory.
•Index Registers (IX and IY): Helps find specific memory locations by adding to a base address.
3. Control Registers
•Program Counter (PC): Points to the next instruction for the CPU to use.
•Instruction Register (IR): Holds the current instruction the CPU is working on.
•Stack Pointer (SP): Manages the stack, like when functions call each other.
4. Status Registers
•Flags Register in CPU: This shows if math or logic operations have certain outcomes, like if a number is
zero or if there’s been an overflow.
5. Floating-Point Registers
They are specialized hardware components within a computer’s central processing unit (CPU) designed to
efficiently handle floating-point arithmetic operations.
These are some of the common types of CPU registers. The specific registers available and their functions
may vary depending on the CPU architecture and design.
Functions of Registers in CPU
Registers in computing serve several crucial purposes:
•Fast Data Access: Registers are the quickest memory in a computer since they’re right inside the CPU. This
means getting data from them is almost instant, unlike getting it from RAM.
•Instruction Execution: Registers hold onto data that the CPU is working with, like numbers for math or
memory addresses for moving data around.
•Control and Status: Registers keep track of how the CPU and the whole computer system are running. For
example, the program counter remembers where the next instruction is, and flags signal like if a math
operation had a big number or if the result is zero.
•Data Storage: Registers keep important data temporarily, like stuff taken from RAM or devices, or numbers
being used in calculations.
•Addressing: Some registers help the CPU find specific spots in memory to read from or write to.
Why we need a CPU register?
• For the fast operations of an instruction, the CPU register is highly useful. Without theses
CPU operation is unimaginable. These are the fastest memory when we look at the
different memory will hold the top position in the memory hierarchy.
• A register can hold an instruction, address, or any other sort of data.
• There are different types of registers available and we have seen most used in the above
part of the article.
• Thus having register, it makes the operations of CPU smooth efficient and meaningfull.
• A register must be large enough according to its requirements and specifications .
Advantages and Disadvantages
Advantages
• These are fastest memory blocks and hence instructions are executed fastly compared to main memory
• Since each register’s function is different, and instructions will be handled with grace and smoothness by
the CPU with the help of registers
• There are rarely any CPU that will not be having register in the digital world.
Disadvantages
• Since the memory size of the register is finite and if the instruction is bigger then CPU need to use cache
or main memory along with register for the operation
• It is costliest of all according to memory hierarchy design
What is Primary Memory
Primary memory is a segment of computer memory that can be accessed directly by the processor. In a hierarchy of
memory, primary memory has access time less than secondary memory and greater than cache memory. Generally,
primary memory has a storage capacity lesser than secondary memory and greater than cache memory.
ROM RAM
Non-volatile memory used for permanent
Volatile memory used for temporary storage
storage
ROM generally holds only megabytes of storage RAM can store in gigabytes
Used for the temporary storage of data Used for permanent storage of data
Types of Primary Memory
1. RAM (Random Access Memory)
The Word “RAM” stands for “random access memory” or may also refer to short-term memory. It’s called
“random” because you can read or store data randomly at any time and from any physical location. It is a
temporal storage memory. RAM is volatile that only retains all the data as long as the computer powered. It
is the fastest type of memory.
RAM stores the currently processed data from the CPU and sends them to the graphics unit.
What is RAM (Random Access Memory)?
It is one of the parts of the Main memory, also famously known as Read Write Memory. Random Access
memory is present on the motherboard and the computer’s data is temporarily stored in RAM. As the name
says, RAM can help in both Read and write. RAM is a volatile memory, which means, it is present as long as
the Computer is in the ON state, as soon as the computer turns OFF, the memory is erased.
1. SRAM (Static Random Access memory)
• SRAM is used as Cache memory, it can hold the data as long as the power availability is there. It is
refreshed simultaneously to store the present information.
• It is made with CMOS (Complementary Metal Oxide Semiconductor ) technology.
• It contains 4 to 6 transistors and it also uses clocks.
• It does not require a periodic refresh cycle due to the presence of transistors.
• Although SRAM is faster, it requires more power and is more expensive in nature.
• Since SRAM requires more power, more heat is lost here as well.
• Another drawback of SRAM is that it can not store more bits per chip, for instance, for the same amount of
memory stored in DRAM, SRAM would require one more chip.
Function of SRAM
The function of SRAM is that it provides a direct interface with the Central Processing Unit at
higher speeds.
Characteristics of SRAM
•SRAM is used as the Cache memory inside the computer.
•SRAM is known to be the fastest among all memories.
•SRAM is costlier.
•SRAM has a lower density (number of memory cells per unit area).
•The power consumption of SRAM is less but when it is operated at higher frequencies, the power
consumption of SRAM is compatible with DRAM.
2. DRAM (Dynamic Random Access memory)
DRAM is used for the Main memory, it has a different construction than SRAM, it used one transistor and
one capacitor (also known as a conductor), which is needed to get recharged in milliseconds due to the
presence of the capacitor.
Dynamic RAM was the first sold memory integrated circuit.
DRAM is the second most compact technology in production (First is Flash Memory).
Although DRAM is slower, it can store more bits per chip, for instance, for the same amount of memory
stored in SRAM, DRAM requires one less chip.
DRAM requires less power and hence, less heat is produced.
Function of DRAM
The function of DRAM is that it is used for programming code by a computer processor in order to function.
It is used in our PCs (Personal Computers).
Characteristics of DRAM
•DRAM is used as the Main Memory inside the computer.
•DRAM is known to be a fast memory but not as fast as SRAM.
•DRAM is cheaper as compared to SRAM.
•DRAM has a higher density (number of memory cells per unit area)
•The power consumption by DRAM is less.
Types of DRAM
•SDRAM: Synchronous DRAM, increases performance through its pins, which sync up with the data
connection between the main memory and the microprocessor.
•DDR SDRAM: (Double Data Rate) It has features of SDRAM also but with double speed.
•DDR2, DDR3, AND DDR4: These are successor versions of DDR SDRAM with upgrades in
performance.
•ECC DRAM: (Error Correcting Code) This RAM can find corrupted data easily and sometimes can
fix it.
•RDRAM: It stands for Rambus DRAM. It used to be popular in the late 1990s and early 2000s. It has
been developed by the company named Rambus Inc. at that time it competed with SDRAM. It’s latency
was higher at the beginning but it was more stable than SDRAM, consoles like Nintendo 64 and Sony Play
Station 2 used that.
Difference Between SRAM and DRAM
SRAM DRAM
DRAM stand for Dynamic Random Access
SRM stand for Static Random Access memory
memory
Faster Slower
Advantages of Using RAM
•Speed: RAM is faster than other types of storage like ROM, hard drives or SSDs, allowing for quick access to data and smooth
performance of applications.
•Multitasking: More RAM allows a computer to handle multiple applications simultaneously without slowing down.
•Flexibility: RAM can be easily upgraded, enhancing a computer’s performance and extending its usability.
•Volatile Storage: RAM automatically clears its data when the computer is turned off, reducing the risk of unwanted data
accumulation.
Disadvantages of Using RAM
•Volatility: Data stored in RAM is lost when the computer is turned off, which means important data must be saved to
permanent storage.
•Cost: RAM can be more expensive per gigabyte compared to other storage options like hard drives or SSDs.
•Limited Storage: RAM has a limited capacity, so it cannot store large amounts of data permanently.
•Power Consumption: RAM requires continuous power to retain data, contributing to overall power consumption of the device.
•Physical Space: Increasing RAM requires physical space in the computer, which might be limited in smaller devices like
laptops and tablets.
ROM (Read Only Memory)
ROM is the long-term internal memory.
ROM is “Non-Volatile Memory” that retains data without the flow of electricity.
ROM is an essential chip with permanently written data or programs.
It is similar to the RAM that is accessed by the CPU. ROM comes with pre-written by the computer
manufacturer to hold the instructions for booting-up the computer.
•Non-Volatile Memory: ROM is a non-volatile memory type; thus, it keeps its data even when the power is
switched off. This makes it suitable for storing permanent instructions and data since it guarantees that the
recorded information will remain intact and may be accessed whenever necessary.
•Read-Only Nature: Reading-only memory, or ROM, as its name implies, prevents data from being readily
modified or wiped. This characteristic provides stability and prevents accidental alterations, ensuring the
integrity and reliability of the stored information.
•Permanent Storage: ROM offers permanent storage of data and instructions. Once the data is programmed
into ROM during manufacturing, it remains fixed and cannot be changed without physically replacing the ROM
chip. This permanence guarantees the consistency and stability of the stored information.
•Firmware Storage: ROM is commonly used for storing firmware containing essential instructions for
operating electronic devices. ROM's non-volatile and read-only nature ensures that the firmware remains
unchanged, providing reliable and consistent functionality to the device.
•Data Security: ROM offers inherent data security. Since the data stored in ROM cannot be modified or
erased, it protects against unauthorized alterations or tampering. This feature enhances the security and
authenticity of the stored information, making ROM suitable for critical instructions and sensitive data.
•Instant Read Access: ROM provides instant read access to the stored instructions and data. The
information can be accessed directly without time-consuming loading, enabling quick retrieval and
execution of essential instructions.
•Compatibility: ROM is compatible with various systems and architectures, allowing seamless integration
into different electronic devices and systems. This compatibility ensures that ROM can be utilized in various
applications.
•Reliability: Due to its read-only nature, ROM offers high reliability. The data stored in ROM is not
susceptible to accidental modifications or loss, ensuring consistent and predictable performance over time.
Such dependability is crucial for important systems where stability and data integrity are of the utmost
importance.
•Booting and Initialization: ROM plays a crucial role in electronic systems' booting and initialization
processes. The firmware stored in ROM contains the initial instructions required to start the system, load the
operating system, and initiate the hardware components. This ensures a smooth and controlled startup
sequence for the device.\
•Cost-Effectiveness: ROM is generally more cost-effective than other memory types, making it an
economical choice for many applications. Production costs are cheaper since the manufacturing procedures
used to produce ROMs are well-established.
Types of ROM:
1) Masked Read Only Memory (MROM):
It is the oldest type of read only memory (ROM). It has become obsolete so it is not used anywhere in today's world. It is
a hardware memory device in which programs and instructions are stored at the time of manufacturing by the
manufacturer. So it is programmed during the manufacturing process and can't be modified, reprogrammed, or erased
later. The MROM chips are made of integrated circuits. Chips send a current through a particular input-output
pathway determined by the location of fuses among the rows and columns on the chip. The current has to pass along a fuse-
enabled path, so it can return only via the output the manufacturer chooses. This is the reason the rewriting and any other
modification is not impossible in this memory.
Programmable Read Only Memory (PROM):
PROM is a blank version of ROM. It is manufactured as blank memory and programmed after
manufacturing. We can say that it is kept blank at the time of manufacturing. You can purchase and then
program it once using a special tool called a programmer.
The programmer can choose one particular path for the current by burning unwanted fuses by sending a high
voltage through them. The user has the opportunity to program it or to add data and instructions as per his
requirement. Due to this reason, it is also known as the user-programmed ROM as a user can program it.
To write data onto a PROM chip; a device called PROM programmer or PROM burner is used. The process
or programming a PROM is known as burning the PROM. Once it is programmed, the data cannot be modified
later, so it is also called as one-time programmable device.
Erasable and Programmable Read Only Memory
(EPROM):
EPROM is a type of ROM that can be reprogramed and erased many times. The method to erase the data is
very different; it comes with a quartz window through which a specific frequency of ultraviolet light is passed for
around 40 minutes to erase the data. So, it retains its content until it is exposed to the ultraviolet light. You need a
special device called a PROM programmer or PROM burner to reprogram the EPROM.
Uses: It is used in some micro-controllers to store program, e.g., some versions of Intel 8048 and the Free scale
68HC11.
Electrically Erasable and Programmable Read Only Memory (EEPROM):
EEP ROM is a type of read only memory that can be erased and reprogrammed repeatedly, up to 10000
times. It is also known as Flash EEPROM as it is similar to flash memory. It is erased and reprogrammed
electrically without using ultraviolet light. Access time is between 45 and 200 nanoseconds.
The data in this memory is written or erased one byte at a time; byte per byte, whereas, in flash memory data
is written and erased in blocks. So, it is faster than EEPROM. It is used for storing a small amount of data in
computer and electronic systems and devices such as circuit boards.
Uses: The BIOS of a computer is stored in this memory.
FLASH ROM:
It is an advanced version of EEPROM. It stores information in an arrangement or array of memory cells made
from floating-gate transistors. The advantage of using this memory is that you can delete or write blocks of
data around 512 bytes at a particular time. Whereas, in EEPROM, you can delete or write only 1 byte of data
at a time. So, this memory is faster than EEPROM.
It can be reprogrammed without removing it from the computer. Its access time is very high, around 45 to 90
nanoseconds. It is also highly durable as it can bear high temperature and intense pressure.
Uses: It is used for storage and transferring data between a personal computer and digital devices. It is used in
USB flash drives, MP3 players, digital cameras, modems and solid-state drives (SSDs). The BIOS of many
modern computers are stored on a flash memory chip, called flash BIOS.
Uses of ROM:
ROM (Read-Only Memory) is used in various electronic devices. Let's explore the numerous ROM apps found
in these electronic devices.
Computers:
In computer systems, ROM is essential. The Basic Input/Output System (BIOS) and first startup instructions
are stored as part of the computer's firmware. The firmware included in ROM is in charge of initializing the
hardware elements, running self-tests, and loading the operating system into memory when you switch on your
computer.
Video Games:
ROM is widely used in video games. Game data was previously stored on ROM cartridges in earlier gaming
consoles and portable devices. These cartridges carried the game's code, graphics, sound, and other components
on ROM chips. A gaming console loads the game when you insert a game cartridge by reading the data from
the ROM chip. Using ROM in video games allowed for easy distribution and ensured that the game data
remained intact without the risk of accidental modifications.
Smartphones:
• ROM is essential in smartphones for storing firmware, such as the operating system and built-in applications.
To maintain consistency throughout the device's existence, manufacturers program the firmware into the
ROM during the device's construction. The bootloader, which starts the booting process and loads the
operating system, is also included in ROM. By utilizing ROM, smartphones can provide stable and reliable
performance and protect the firmware from potential corruption or tampering.
Digital Speed Meters:
• In the automotive industry, ROM is used in digital speed meters or speedometers. The ROM chip in these
devices stores the calibration data and conversion tables needed to measure and display the vehicle's speed
accurately. This ensures that the speed meter operates consistently and provides accurate readings. The non-
volatile nature of ROM ensures that the calibration data remains intact even if the power is disconnected or
the vehicle is turned off.
Programmable Electronics:
• ROM is used in programmable electronic devices, microcontrollers, and programmable logic devices (PLDs). Those
devices frequently use programmable read-only memory (prom) or erasable programmable read-only memory
(EPROM). Users can program these ROM chips to preserve certain information or instructions that the device can
access and carry out. This flexibility allows for customization and flexibility in various digital applications, along
with robotics, automation, and control systems.
Advantages of ROM:
1.Data Retention: ROM maintains data even without power, ensuring that crucial data is retained and accessible
whenever necessary.
2.Permanent Storage: ROM's non-modifiable nature assures that the information stored inside stays intact,
making it a reliable and consistent source of data and instructions.
3.Reliable Performance: As ROM is read-only, unintentional modifications are prevented, ensuring that stored
data will work reliably and consistently over time.
4.Non-Volatile Memory: ROM is an option for storing important instructions, firmware, and data that shouldn't
be changed since it can preserve data without a constant power source.
5.Stability: The ROM offers a strong basis for the booting process and overall system function by storing crucial
instructions and calibration data, assuring consistent and predictable performance.
6.Data Security: Read-only memory (ROM) protects against unauthorized alterations, strengthening the
security of data held within and preventing unauthorized access.
7.Instant Accessibility: The ability to instantly access data and instructions stored in ROM reduces the need
for time-consuming data loading procedures, allowing for speedier system operation.
8.Simple Design and Manufacturing: The design of ROM chips makes it simple to integrate them into
electrical equipment.
9.Cost-Effectiveness: ROM is often less expensive than other memory types, making it a cost-effective
option for many applications without compromising performance.
10.Compatibility: ROM may easily be integrated into various electronic systems and devices since it is
compatible with various architectures and systems.
Disadvantages of ROM:
1.Immutability: The main disadvantage of ROM is its inability to be modified or updated. Once data is
programmed into ROM, it cannot be changed, limiting its flexibility and adaptability in certain applications.
2.Limited Flexibility: Unlike writable memory, such as RAM or flash memory, ROM does not allow for
dynamic changes or updates to the stored data, restricting its use in situations that require frequent modifications.
3.Manufacturing Challenges: Manufacturing ROM chips requires special processes, making them less flexible
and potentially more expensive to produce than other types of memory.
4.Design Constraints: The fixed nature of ROM imposes design constraints as the data programmed into it
cannot be easily altered or expanded. This can be limiting when system requirements change, or additional
functionality is desired.
5.Time-Consuming Development: Creating and programming ROM requires significant time and effort during
the development phase, which may slow down the overall product development cycle.
6. Higher Costs for Small-Scale Production: The initial costs associated with ROM production, such as
mask creation, can be relatively high, making it less cost-effective for small-scale or customized production
runs.
7. Lack of Upgradability: ROM can only be upgraded or replaced with newer versions by physically
replacing the entire chip, which can be costly and impractical in many situations.
8. Storage Inefficiency: ROM is read-only; unused space within the ROM chip cannot be utilized, resulting in
potential storage inefficiencies.
9. Limited Error Correction: Unlike other memory types, ROM does not provide built-in error correction
mechanisms, which can disadvantage applications with critical data integrity.
10. Reduced Versatility: The fixed nature of ROM makes it less versatile for applications that require
dynamic storage and frequent changes to the stored data.
You know that processor memory, also known as primary memory, is expensive as well as limited. The
faster primary memory are also volatile. If we need to store large amount of data or programs permanently,
we need a cheaper and permanent memory. Such memory is called secondary memory. Here we will
discuss secondary memory devices that can be used to store large amount of data, audio, video and
multimedia files.
Characteristics of Secondary Memory
These are some characteristics of secondary memory, which
distinguish it from primary memory −
•It is non-volatile, i.e. it retains data when power is switched off
•It is large capacities to the tune of terabytes
•It is cheaper as compared to primary memory
Depending on whether secondary memory device is part of CPU
or not, there are two types of secondary memory – fixed and
removable.
Let us look at some of the secondary memory devices available.
Hard Disk Drive
Hard disk drive is made up of a series of circular disks called platters arranged one over the other almost ½
inches apart around a spindle. Disks are made of non-magnetic material like aluminum alloy and coated with 10-
20 nm of magnetic material.
Standard diameter of these disks is 14 inches and they rotate with speeds
varying from 4200 rpm (rotations per minute) for personal computers to
15000 rpm for servers. Data is stored by magnetizing or demagnetizing the
magnetic coating. A magnetic reader arm is used to read data from and
write data to the disks. A typical modern HDD has capacity in terabytes
(TB).
Function of Hard disk
1. The hard disk is a secondary storage device, which is designed to store data permanently.
2. The secondary storage devices include a large storage capacity as compared to the primary storage devices.
3. The data stored in a hard disk is retained when our computer system shuts down.
4. The data stored in the hard disk can be of many types such as the operating system, installed software,
documents, and other files of computer.
Hard disk was introduced in the year 1956 by IBM. The first personal computer contains a hard drive of less
than 1 megabyte, while modern computers contain a hard drive of 1 terabyte.
5. Every computer contains atleast one hard drive to store data and software.
In Windows operating system, the hard drive is known to be the C drive,
and in MAC, it is simply called as the hard drive. The desktop computers which have external hard drives are
used for backup purposes or additional storage.
Advantages of the hard disk
The advantages of a Hard Disk Drive are given as follows:
•One of the significant advantages of a Hard Disk drive is that its cost is low.
•Another advantage of a Hard Disk is that it is readily available in the market.
•Hard Disk is faster than optical disks.
•The capacity for storing the data in HDDs is large.
• It is the first level of cache memory, which is called Level 1 cache or L1 cache.
• In this type of cache memory, a small amount of memory is present inside the CPU
itself.
• If a CPU has four cores (quad core cpu), then each core will have its own level 1
cache.
• As this memory is present in the CPU, it can work at the same speed as of the CPU.
• The size of this memory ranges from 2KB to 64 KB.
• The L1 cache further has two types of caches:
1. Instruction cache, which stores instructions required by the CPU,
2. Data cache that stores the data required by the CPU.
L2:
•Reduced Memory Latency: By storing frequently accessed data and instructions closer to
the CPU cores, cache minimizes the latency associated with fetching data from main
memory.
Cache mapping is needed to identify where the cache is present in cache memory.
Mapping provides the cache line number where the content is present in the case of cache
hit or where to bring the content from the main memory in the case of cache miss.
Cache mapping is a technique that is used to bring the main memory content to the
cache (cache miss) or to identify the cache block in which the required content is
present (cache hit).
Primary Terminologies
Some primary terminologies related to cache mapping are listed below:
•Main Memory Blocks: The main memory is divided into equal-sized partitions called the
main memory blocks.
•Cache Line: The cache is divided into equal partitions called the cache lines.
•Block Size: The number of bytes or words in one block is called the block size.
•Tag Bits: Tag bits are the identification bits that are used to identify which block of main
memory is present in the cache line.
•Number of Cache Lines: The number of cache lines is determined by the ratio of cache
size divided by the block or line size.
•Number of Cache Set: The number of cache sets is determined by the ratio of several
cache lines divided by the associativity of the cache.
Some important points related to cache mappings are listed below.
•The number of bytes in main memory block is equal to the number of bytes in cache line
i.e., the main memory block size is equal to the cache line size.
•Number of blocks in cache = Cache Size / line or Block Size
•Number of sets in cache = Number of blocks in cache / Associativity
•The main memory address is divided into two parts i.e., main memory block number and
byte number.
Direct Mapping
• The simplest technique, known as direct mapping, maps each block of main memory into only one possible
cache line. or In Direct mapping, assign each memory block to a specific line in the cache.
• If a line is previously taken up by a memory block when a new block needs to be loaded, the old block is
trashed.
• In direct mapping physical address is divided into three parts : Tag bits, Cache Line Number and Byte offset.
• The bits in the cache line number represents the cache line in which the content is present
• The bits in tag are the identification bits that represents which block of main memory is present in
cache.
• The bits in the byte offset decides in which byte of the identified block the required content is present .
• Cache Line Number = Main Memory block Number
% Number of Blocks in Cache
Fully Associative Mapping
In fully associative mapping address is divided into two parts
i.e., Tag bits and Byte offset.
The tag bits identify that which memory block is present and bits in the byte offset field
decides in which byte of the block the required content is present.
For mapping there is one possible location in the The mapping of the main memory block can be
The mapping of the main memory block can be
cache organization for each block from main done with a particular cache block of any direct-
done with any of the cache block.
memory because we have a fixed formula. mapped cache.
If the processor need to access same memory If the processor need to access same memory In case of frequently accessing two different pages
location from 2 different main memory pages location from 2 different main memory pages of the main memory if reduced, the cache hit ratio
frequently, cache hit ratio decreases. frequently, cache hit ratio has no effect. reduces.
The index is given by the number of blocks in The index is given by the number of sets in
The index is zero for associative mapping.
cache. cache.
• In a system that uses paging, RAM is divided into a number of blocks called pages, usually
4K in size.
• Processes are then allocated just enough for pages to meet their memory requirements.
• This means there will always be a small amount of memory wasted, except in the unusual
case where a process requires exactly a whole number of pages.
• During the normal course of operations, pages are swapped between RAM and a page file,
which represents the virtual memory.
• Suffers from internal fragmentation but not external fragmentation.
Segmentation
• Segmentation is an alternative approach to memory management:
• Instead of pages of a fixed size, the memory management system allocates segments of differing length to
processes that exactly meet their requirements.
• Unlike in a paged system, no memory is wasted in a segment.
• Segmentation also allows applications to be split up into logically independent address spaces, which can
make them easier and more secure to share.
• One downside to segmentation is that because each segment is a different length, it can lead to memory
fragmentation.
• As segments are continually allocated and de-allocated, small chunks of memory are scattered within the
memory space. They’re too small to be useful.
• As these small chunks build up, fewer and fewer segments of useful size can be allocated.
• It’s difficult for the OS to keep track of all these segments, and each process will need to use multiple
segments.
• This is inefficient and can reduce overall application performance.
SrNo Paging Segmentation
2
Paging divides program into fixed size pages. Segmentation divides program into variable size segments.
Logical address is divided into page number and Logical address is divided into segment number and segment
8
page offset offset
Page table entry has the frame number and some Segment table entry has the base address of the segment and
10
flag bits to represent details about pages. some protection bits for the segments.
How to manage the virtual memory
Managing virtual memory within an OS can be straightforward, as there are default settings that determine the
amount of hard drive space to allocate for virtual memory.
Those settings will work for most applications and processes, but there may be times when it is necessary to
manually reset the amount of hard drive space allocated to virtual memory -- for example, with applications that
depend on fast response times or when the computer has multiple hard disk drives (HDDs).
When manually resetting virtual memory, the minimum and maximum amount of hard drive space to be used for
virtual memory must be specified.
Allocating too little HDD space for virtual memory can result in a computer running out of RAM.
If a system continually needs more virtual memory space, it may be wise to consider adding RAM.
Common OSes may generally recommend users not increase virtual memory beyond 1 ½ times the amount of
RAM.
Managing virtual memory differs by OS.
For this reason, IT professionals should understand the basics when it comes to managing physical memory,
virtual memory and virtual addresses.
RAM cells in SSDs also have a limited lifespan. RAM cells have a limited number of writes, so using them for
virtual memory often reduces the lifespan of the drive.
What are the limitations of using virtual memory?
Although the use of virtual memory has its benefits, it also comes with some tradeoffs worth considering, such
as:
•Applications run slower if they are running from virtual memory.
•Thrashing can occur if there is not enough RAM, which will make the computer perform slower.
•It may take time to switch between applications using virtual memory.
•It lessens the amount of available hard drive space.
•Data must be mapped between virtual and physical memory, which requires extra hardware support for
address translations, slowing down a computer further.
•The size of virtual storage is limited by the amount of secondary storage, as well as the addressing scheme
with the computer system.
Feature Virtual Memory Physical Memory (RAM)
Memory protection
Protection mechanisms have to be satisfied by the processor which is in the execution state, to avoid
interference of other unauthorized to perform write operations to the same file located in the shared memory
space. This has to be in control by the processor of the system rather than the installed operating system, as OS
has a function to control the process which occupies them, thereby checking the reference of the valid memory.
In simple terms, protection is the method of securing the memory from unauthorized processes.
Logical addressing −
Programs that are stored inside the memory units are organized into modules and these modules are modifiable with read and
execute permission but a few do not have permission to modify. The sequence of bytes or otherwise as words is the
representation form of main memory which is linear and has a one-dimensional address area in nature. As said above, logical
addresses are generated by the CPU during the run time of the process. The user programs which are given as input is divided
into modules compiled independently and their references are addressed during the run time of the system. Protection can vary
on each level of logical spaces where different modules reside.
Physical space −
As it’s known that the memory of the system has two divisions such as main memory and secondary memory. Main memory
(volatile) is capable to store and handle the current programs which are in execution with better performance whereas secondary
memory (which acts as nonvolatile) supports storing the data for a long time but provides less performance when compared to
main memory. The flow of information and swapping process seems to be a difficult task for the user to understand.
The overlaying approach can be followed by the user when the main memory and the data to be stored are not as sufficient as
required. This method allows various modules of a user program allocated to the same memory space. The major drawback is
during a multiprogramming environment, the user does not know the details about the space and its location in the memory
during the program execution.
LINKS
https://www.toppr.com/guides/computer-science/computer-fundamentals/primary-memory/cache-memor
y/
https://www.javatpoint.com/rom
https://www.techtarget.com/searchstorage/definition/cache-memory