0% found this document useful (0 votes)
3 views46 pages

Module 4 Memory Organisation

The document discusses memory organization, specifically memory interleaving, which enhances data access speed by distributing data across multiple memory modules. It also outlines the memory hierarchy, detailing the different types of memory from registers to secondary storage, and explains the characteristics and functions of RAM, including DRAM and SRAM. Additionally, it describes the essential components of a computer system, emphasizing the roles of the CPU, motherboard, hard drive, and RAM.

Uploaded by

parthkinra14
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)
3 views46 pages

Module 4 Memory Organisation

The document discusses memory organization, specifically memory interleaving, which enhances data access speed by distributing data across multiple memory modules. It also outlines the memory hierarchy, detailing the different types of memory from registers to secondary storage, and explains the characteristics and functions of RAM, including DRAM and SRAM. Additionally, it describes the essential components of a computer system, emphasizing the roles of the CPU, motherboard, hard drive, and RAM.

Uploaded by

parthkinra14
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

Memory Organisation

Memory Interleaving
It is a Technique that divides memory into a number of modules such that Successive
words in the address space are placed in the Different modules. These modules is known
as banks.
Consecutive Word in a Module:

Figure-1: Consecutive Word in a Module


Let us assume 16 Data’s to be Transferred to the Four Module. Where Module 00 be
Module 1, Module 01 be Module 2, Module 10 be Module 3 & Module 11 be Module 4.
Also, 10, 20, 30….130 are the data to be transferred.
From the figure above in Module 1, 10 [Data] is transferred then 20, 30 & finally, 40 which
are the Data. That means the data are added consecutively in the Module till its max
capacity.
Most significant bit (MSB) provides the Address of the Module & the least significant bit
(LSB) provides the address of the data in the module.
For Example, to get 90 (Data) 1000 will be provided by the processor. This 10 will
indicate that the data is in module 10 (module 3) & 00 is the address of 90 in Module 10
(module 3). So,
Module 1 Contains Data : 10, 20, 30, 40
Module 2 Contains Data : 50, 60, 70, 80
Module 3 Contains Data : 90, 100, 110, 120
Module 4 Contains Data : 130, 140, 150, 160
Consecutive Word in Consecutive Module:

Figure-2: Consecutive Word in Consecutive Module

Now again we assume 16 Data’s to be transferred to the Four Module. But Now the
consecutive Data are added in Consecutive Module. That is, 10 [Data] is added in
Module 1, 20 [Data] in Module 2 and So on.
Least Significant Bit (LSB) provides the Address of the Module & Most significant bit
(MSB) provides the address of the data in the module.
For Example, to get 90 (Data) 1000 will be provided by the processor. This 00 will
indicate that the data is in module 00 (module 1) & 10 is the address of 90 in Module 00
(module 1). That is,

Module 1 Contains Data : 10, 50, 90, 130


Module 2 Contains Data : 20, 60, 100, 140
Module 3 Contains Data : 30, 70, 110, 150
Module 4 Contains Data : 40, 80, 120, 160
Why do we use Memory Interleaving? [Advantages]:
Whenever Processor requests Data from the main memory. A block (chunk) of Data is
Transferred to the cache and then to Processor. So whenever a cache miss occurs the
Data is to be fetched from the main memory. But main memory is relatively slower than
the cache. So to improve the access time of the main memory interleaving is used.

We can access all four Modules at the same time thus achieving Parallelism. From
Figure 2 the data can be acquired from the Module using the Higher bits. This method
Uses memory effectively.
Memory Hierarchy
Memory Hierarchy is an enhancement to organize the memory such that it can minimize
the access time. It was developed based on a program behavior known as locality of
references.
The figure below clearly demonstrates the different levels of memory hierarchy:

This Memory Hierarchy Design is divided into 2 main types:


1. External Memory or Secondary Memory –This includes peripheral storage devices
(Magnetic Disks, Optical Disks, Magnetic Tape) that the processor must access via an
I/O Module.

2. Internal Memory or Primary Memory – This includes memory that is directly


accessible by the processor (CPU Registers, Cache, and Main Memory).

There are typically four levels of memory in a memory hierarchy:

Registers: Registers are small, high-speed memory units located in the CPU. They are
used to store the most frequently used data and instructions. Registers have the fastest
access time and the smallest storage capacity(16 to 64 bits).
Cache Memory: Cache memory is a small, fast memory unit located close to the CPU. It
stores frequently used data and instructions that have been recently accessed from the
main memory. Cache memory is designed to minimize the time it takes to access data by
providing the CPU with quick access to frequently used data.
Main Memory: Main memory, also known as RAM (Random Access Memory), is the
primary memory of a computer system. It has a larger storage capacity than cache
memory, but it is slower. Main memory is used to store data and instructions that are
currently in use by the CPU.
Secondary Storage: Secondary storage, such as hard disk drives (HDD) and solid-state
drives (SSD), is a non-volatile memory unit that has a larger storage capacity than main
memory. It is used to store data and instructions that are not currently in use by the CPU.
Secondary storage has the slowest access time and is typically the least expensive type
of memory in the memory hierarchy.
Optical Disks & Magnetic Tape: The foundational layer used for massive, long-term
data backups.

We can infer the following characteristics of Memory Hierarchy Design from above
figure:
1. Capacity: It is the global volume of information the memory can store. As we move
from top to bottom in the Hierarchy, the capacity increases.
2. Access Time: It is the time interval between the read/write request and the availability
of the data. As we move from top to bottom in the Hierarchy, the access time
increases.
3. Performance: Earlier when the computer system was designed without Memory
Hierarchy design, the speed gap increases between the CPU registers and Main
Memory due to large difference in access time. This results in lower performance of
the system and thus, enhancement was required. This enhancement was made in the
form of Memory Hierarchy Design because of which the performance of the system
increases. One of the most significant ways to increase system performance is
minimizing how far down the memory hierarchy one has to go to manipulate data.
4. Cost per bit: As we move from bottom to top in the Hierarchy, the cost per bit
increases i.e. Internal Memory is costlier than External Memory.

Magnetic Disks
In a computer, the magnetic disks are circular plates that’s fabricated with plastic or metal with a magnetised
material. Two faces of a disk are frequently used, and many disks can be stacked on a single spindle by
read/write heads that are obtainable on every plane. The disks in a computer jointly turn at high speed.

Magnetic Tape
Magnetic tape refers to a normal magnetic recording designed with a slender magnetizable overlay that covers
an extended, thin strip of plastic film. It is used mainly to back up huge chunks of data. When a computer needs
to access a strip, it will first mount it to access the information. Once the information is allowed, it will then be
unmounted. The actual access time of a computer memory would be slower within a magnetic strip, and it will
take a few minutes for us to access a strip.

MAIN Memory
The main memory in a computer is called Random Access Memory. It is also
known as RAM. This is the part of the computer that stores operating system
software, software applications and other information for the central
processing unit (CPU) to have fast and direct access when needed to
perform tasks. It is called "random access" because the CPU can go directly
to any section of main memory, and does not have go about the process in a
sequential order.
RAM is one of the faster types of memory, and has the capacity to allow data
to be read and written. When the computer is shut down, all of the content
held in RAM is purged. Main memory is available in two types: Dynamic
Random Access Memory (DRAM) and Static Random Access Memory
(SRAM).00:30

Process
The central processing unit is one of the most important components in the
computer. It is where various tasks are performed and an output is
generated. When the microprocessor completes the execution of a set of
instructions, and is ready to carry out the next task, it retrieves the
information it needs from RAM. Typically, the directions include the address
where the information, which needs to be read, is located. The CPU
transmits the address to the RAM's controller, which goes through the
process of locating the address and reading the data.

DRAM
Dynamic random access memory (DRAM) is the most common kind of main
memory in a computer. It is a prevalent memory source in PCs, as well as
workstations. Dynamic random access memory is constantly restoring
whatever information is being held in memory. It refreshes the data by
sending millions of pulses per second to the memory storage cell.

SRAM
Static Random Access Memory (SRAM) is the second type of main memory
in a computer. It is commonly used as a source of memory in embedded
devices. Data held in SRAM does not have to be continually refreshed;
information in this main memory remains as a "static image" until it is
overwritten or is deleted when the power is switched off. Since SRAM is less
dense and more power-efficient when it is not in use; therefore, it is a better
choice than DRAM for certain uses like memory caches located in CPUs.
Conversely, DRAM's density makes it a better choice for main memory.
Adequate RAM
The CPU is often considered the most important element in the performance
of a personal computer. RAM probably comes in a close second. Having an
adequate amount of RAM has a direct effect on the speed of the computer. A
system that lacks enough main memory to run its applications must rely on
the operating system to create additional memory resources from the hard
drive by "swapping" data in and out. When the CPU must retrieve data from
the disk instead of RAM, it slows down the performance of the computer.
Many games, video-editing or graphics programs require a significant
amount of memory to function at an optimal level.

System Requirements
Having adequate main memory in a computer starts with meeting the
recommended amount of memory for the operating system. Windows Vista
Basic requires a minimum of 512MB of RAM; many computer experts
suggest at least 1GB. The minimum requirement for Windows Home
Premium, Business and Ultimate is 1GB. MAC OS 10.5 has a minimum
requirement of 1GB of main memory.

Examples of Primary Storage Devices


If you know what computer memory is, then you already know what a
primary storage device is – the latter term is a lot fancier, but they mean the
exact same thing. And no, "memory" is not the massive external hard drive
you use to store your out-of-control collection of the finest cat GIFs in the
world.

While a central processing unit (or CPU) performs the brainy functions of a
computer, carrying out calculations and delegating tasks, memory helps out
with those delegations by holding bits of data temporarily to keep the
programs you have open up and running. Primary storage devices come in a
few different forms, so strap in and put your memory cap on.
Primary Storage Devices
When it comes to examples of primary memory, random access memory (or
RAM) is probably the most commonplace. RAM is computer hardware,
usually in the form of memory modules like DRAM, from which data can be
temporarily stored and retrieved. While a disc or hard drive accesses data in
a specific sequence, RAM – as the name implies – is able to access it at
random, making it a fast and efficient form of primary memory.

Another primary memory example is cache. Cache, or CPU memory, serves


as a high-speed memory access area reserved on your computer's main
memory or storage device. Cache is actually a part of high-speed static RAM
(SRAM), which requires a constant power source to keep its high-speed
memory distribution going.

How Does RAM Work?


As soon as you boot your computer on, the CPU allocates parts of the

computer's operating system to the primary memory, which allows the CPU

to work faster and boot up your PC more quickly. This little microcosm is a

pretty good example of how RAM and primary memory works in a nutshell:

once the computer is up and running, the CPU continues to hand off various

tasks to the memory temporarily until you shut it off. Ideally, you're not

aware of the process but it's largely what keeps your computer running

smoothly and why high RAM amounts are so prominently advertised.

That means that when your computer is running slow or visibly struggling,
there's a good chance it doesn't have enough memory to tackle all the tasks
you're throwing at it. So close a few programs and trying shutting down at
least most of those 32 browser tabs you have open.

Secondary Storage
Remember that hard drive with the cat GIFs? Yeah, that's a type of
secondary storage. Secondary storage hard drives, which store data for the
long-term (while primary storage stores it for the short-term) include
internal and external types. Smaller hard drives even include USB thumb
drives or your smart phone when you hook it up to your computer for the
express purpose of viewing or transferring files.

Optical media is another type of secondary storage. Though many modern


computers lack optical disk drives, good old CDs and DVDs containing data
are also secondary storage devices (technically, so are 3.5-inch floppy disks
if you want to go really old-school, but we'll spare you that deep, deep dive
for the moment).

Which Type of Memory Loses Its Data When the

Computer Is Turned Off?


Your computer's RAM loses its data when the power goes off.

Your computer has different kinds of memory, some of which saves its data
when you turn the power off, some which does not. Computer scientists call
the former kind of memory non-volatile and the latter volatile. The reasons
have to do with the electrical properties of the memory. Generally, volatile
memory tends to be fast and expensive, and non-volatile memory tends to
be slow and inexpensive.

Memory Types
When you turn your computer on, the first thing it does is read instructions
from ROM, or read-only memory. This memory, programmed at the factory,
keeps its data without power, but cannot accept new data. The computer
reads and writes into random-access memory, or RAM, at high speeds. Most
RAM is volatile memory. Your computer stores large amounts of data to its
hard drive, which is relatively slow, but keeps its data when you turn the
power off.

Main RAM
Chances are, the computer sitting on your lap has more than one billion
characters of volatile RAM memory. Your browser, word processor and other
programs work in RAM and use it as a "scratch pad," adding, removing and
rewriting data rapidly. This memory consists of millions of tiny transistors
packed into integrated circuit chips. It works at moderately high speed,
reading and writing in 60 to 80 billionths of a second and retailing for about
$15 for a billion characters at 2011 prices.

Cache RAM
In addition to your computer's main RAM memory, its microprocessor has its
own, smaller, memory units, called cache. The microprocessor has up to
three stages of cache, called L1, L2 and L3, which work at speeds up to 1
billionth of a second, or 60 to 80 times faster than normal RAM. Because it is
more expensive than standard RAM, the microprocessor has one million
characters or less of this kind of memory. Like regular RAM, it loses its data
when the power goes off.

Older Technologies
In the 1950s and '60s, before transistors made computers inexpensive and
compact, engineers used other volatile technologies to store data bits. One,
called delay-line memory, stored data as a set of sound pulses in mercury or
quartz. The circuits recirculated the pulses in a continuous loop like cars in a
toy train set. This scheme stored several thousand memory bits at rates
about 1,000 times slower than today's RAM.

4 Main Parts of a Computer System


Although computers have evolved significantly over the past several
decades, the core functionality – and the hardware that enables these
functions – has undergone no fundamental redefinition. Because of this, it's
not overly difficult to gain competency in the basic operation of a computer
system and the primary components of a modern desktop or laptop
computer. The 4 main parts of a computer which ensure that users can
access a wide variety of tools and services include the central processing
unit, or CPU, the motherboard, the hard drive and random access memory,
or RAM. Understanding the role of these computer parts will help you better
understand how your computer gets the job done.

The 4 Main Parts of a Computer:

The Central Processing Unit


The central processing unit, or CPU, can be thought of as the "brain" of a
computer. Using a combination of arithmetic functions, logic processes and
input/output commands, the CPU receives instructions from various
computer programs in use and executes them as needed. The modern CPU
exists in the form of a microprocessor, which features a single integrated
circuit design. This is a dramatic departure from the earliest CPU units,
which featured a transistor-based construction. Compared to the CPUs used
in the second half of the 20th century, modern hardware is highly efficient,
portable and relatively inexpensive to manufacture.

The Motherboard
A CPU can't achieve its intended purpose without the assistance of the
motherboard. The motherboard is a printed circuit board, or PCB, found
inside a computer which not only hosts the CPU but also acts as a connected
gateway to various other computer peripherals, including sound cards, hard
drives, video cards and so on. The motherboard hosts a number of sockets
into which microprocessors, such as the CPU, can be plugged. The
motherboard is also connected to the computer's power supply and
distributes electrical voltage to the attached components. Simply put, a
motherboard provides a critical platform on which the rest of a CPU's
hardware can operate. Without the motherboard in place, a computer
couldn't function.

Hard Drives and RAM


The hard drive, often shortened to HD, stores data which can then be
accessed by various other programs at any given time. Hard drives provide
users with various levels of storage capacity, with more expensive units
often providing greater space for data storage and faster rates of data
transmission.

It's somewhat easy to confuse the function of the hard drive with that of
random access memory, or RAM. Unlike a hard drive, RAM is composed of a
series of chips which allow for temporary data storage only. Whereas a hard
drive will continue to store data even after a computer has been powered
off, RAM will be cleared. RAM is often used to act as a holding zone for open
files or critical data that a program may need to access intermittently during
use. RAM should not be thought of as storage, per say, but instead as a
"place holder" for valuable information. Nevertheless, it remains one of the 4
main parts of a computer that is still in use today.

What Are the Parts of RAM?


Random access memory (RAM) is a computer's operational memory. The
operational memory is where the components of the operating system that
are needed to run the computer are loaded and stored. RAM also houses
programs while they're being used. There have been many types of RAM but
with the evolution of memory technology, the type widely used today is
based on SDRAM (synchronous dynamic RAM) infrastructure. The latest DDR
(double data rate) 1, 2 and 3 are all based on SDRAM architecture.

Board
This is the circuit board on which all the hardware components of RAM are
soldered. It features a silicon-based semiconductor integrated circuitry
providing connections between the memory components as well as
interfacing with the computer to allow the processor and memory controller
to access the RAM.

Clock
Unlike conventional (asynchronous) DRAM, SDRAM's memory operations are
synchronized to a clock's signals, simplifying the control interface and
eliminating the need for generating pseudo analog signals required in
conventional DRAM. It also decreases manufacturing costs for the memory's
components because faster memory could be made at the same cost.

Mode Register
This on-chip register's function is the configuration of the basic device
operation. It controls the CAS (column address strobe) latency, burst length
and burst type, and is usually set up while the computer is first powering up.

Memory Banks
This is the section with the actual memory modules--cells--that store data. In
SDRAM, there are always two or more banks, allowing one bank to be
available for access while the other is being pre-charged. This eliminates the
latency caused by precharging a single bank, which results in increased
transfer rates. It also reduces the granularity of each bank, resulting in
higher performances at lower costs for 16MB and higher memory densities.

SPD Chip
SPD stands for serial presence detect. SDRAM features an on-board SPD chip
that contains information about the memory type, size, speed and access
time. This chip lets the computer access this information at start-up while it
goes through its power-on test cycle.

Burst Counter
The burst counter is an on-chip counter that keeps track of column
addresses to enable high speed burst access. It uses two burst types--
sequential and interleaved-- and different burst lengths, and these
parameters can be programmed using the mode register.

How Does a CPU Work?


The CPU of a computer, or central processing unit, is frequently compared to
the human brain since it's the central control of the computer. The CPU
performs computer operations by rapidly executing program instructions.
The speed of the CPU plays a large part in determining the power of a
computer. Each new generation of microprocessors features a more
powerful CPU that can execute instructions more quickly than the previous
generation.

How a Computer Processor Works


The working of the CPU is defined as a three-step process. First, an
instruction is fetched from memory. Second, the instruction is decoded and
the processor figures out what it's being told to do. Third, the instruction is
executed and an operation is performed. These three steps repeat in a cycle
that begins again with the CPU fetching the next instruction. The steps are
referred to as the instruction cycle of the CPU.

The CPU uses a program counter to keep track of which instruction to fetch
next. The counter is the address of the memory location that holds the next
instruction to be executed. It's stored in a register, which is a dedicated
memory location in the CPU itself. The program counter is incremented to
point to the next instruction after each fetch in the instruction cycle.

Operations Performed by a CPU


The CPU executes instructions that perform a set of basic operations. There
are arithmetic operations like addition, subtraction, multiplication and
division. Memory operations move data from one location to another. Logical
operations test a condition and make a decision based on the result. Control
operations affect other components of the computer. These basic types of
operations, executed very quickly, allow a computer to perform a wide
range of functions. The exact number of operations supported by a CPU
depends on its architecture.

How the CPU Uses Memory


Computer memory refers to the area where data and programs are stored.
Memory is not part of the CPU, but the CPU must interact closely with it.
There are two types of computer memory: primary, or main, and secondary.
The CPU relies heavily on main memory for storing program instructions and
the data the instructions operate on. Main memory is temporary in nature
and only holds instructions and data for a program while the program is
executing. Secondary memory is the more permanent storage provided by
hard drives and flash drives.

A component of the CPU known as the control unit is responsible for moving
instructions and data from secondary storage into main memory prior to
instruction execution. The control unit also moves the results of an
instruction to secondary storage.

What Is the Difference Between DRAM & SDRAM?


Dynamic random access memory (DRAM) is a simple way to store data on a
computer for a short period of time. Synchronous random access memory
(SDRAM) is the same as DRAM except that regular DRAM is asynchronous.
Synchronous random access memory stays synchronized with the
computer's clock which allows greater efficiency in storing and retrieving
data compared to asynchronous DRAM.

History
Dr. Robert Dennard invented DRAM in 1967 while working for IBM and
received a patent for this groundbreaking technology in 1968. Known as the
DRAM memory cell, Dennard's invention makes use of a single transistor
that reads from and writes to a capacitor that stores data. Many innovations
sprang from Dennard's single transistor memory cell technology, among
them SDRAM which synchronized to the computer's clock thereby increasing
efficiency when reading from or writing to the random access memory.

Significance
Previous forms of memory storage were as large as a room and required
constant cooling. However, as memory storage technology advanced, these
devices became smaller and cheaper. The invention of DRAM by Dr.
Dennard enabled a large leap forward in making computer technology
smaller, cheaper and therefore more accessible to the average consumer.

Types of Memory
There are several forms of memory storage such as DVDs, CDs, hard disks
and read only memory (ROM), but random access memory (RAM) is a faster
form of storage than most. That is why RAM is utilized as a kind of short
term memory on your computer as oppose to a hard disk which would be
comparable to long term memory. This short term memory is used to run
the operating system and any applications you may use, but once you shut
the computer down the RAM is wiped clean.

Function of DRAM
Dynamic random access memory utilizes one transistor to store data on one
capacitor, but that capacitor will lose the data as it loses its charge unless
the capacitor is periodically recharged. The recharging of the capacitors is
the reason the word dynamic is used in dynamic random access memory.
Once the capacitors no longer receive a charge, the data is lost. DRAM
operates asynchronously with the computer's clock sending instructions as
soon as it receives them from the user's interface instead of waiting to
synchronize with the computer system's clock like SDRAM.

Features of SDRAM
SDRAM is synchronized with the computer's clock to allow it to send
instructions more efficiently by joining a pipeline of other instructions the
computer is processing. The pipelining of information in a computer allows it
to receive another command before it has finished processing the previous
command. This allows SDRAM to operate at much higher speeds, making it
the most popular form of RAM offered on computers.
Difference Between Virtual Memory & Main

Memory
Main memory, also called RAM, is the physical memory unit in the computer.
Virtual memory also serves as computer memory, but is actually hard drive
space acting as temporary storage for computer processes.

Function
Computers use as much main memory as possible when storing data to be
accessed by the processor. When the computer runs out of physical RAM, it
uses virtual memory space set aside on the hard drive.

Benefits
Main memory speeds up a computer, while virtual memory tends to transfer
data at speeds much slower than physical RAM. Thus, you should only use
virtual memory when absolutely necessary.

Types
RAM comes in several different types. Old computers may use SDRAM, while
newer computers (as of 2010) use some form of DDR RAM--either DDR1,
DDR2 or DDR3. There are no different "types" of virtual memory, since it's
all drive space. But you can use just about any storage device for virtual
memory, including a thumb drive.

Why Is Virtual Memory Important?


The term "virtual memory" refers to space allocated on a hard drive where
data can be stored for rapid access. Virtual memory is slower than solid-
state memory chips so it is typically used as backup memory in certain
situations.

Multitasking
One important use of virtual memory is multitasking. When a computer user opens multiple
programs at once, the data for these programs must be stored in memory for quick access.
The more programs are open, the more memory is needed. When the computer's physical
memory is full, the excess data is stored in virtual memory.

Large Programs

In addition to multitasking, virtual memory allows programmers to create larger and more
complex applications. When these programs are running, they occupy physical memory as
well as virtual memory.

Flexibility
If computers only relied on memory chips, far less memory would be available and the
usefulness of many software programs would be severely limited. Even though virtual
memory is slower, it is still useful because it greatly expands a computer's functionality.

Changing Times
When virtual memory was first created, solid-state memory chips were much smaller and
more expensive. Today's memory chips can store many gigabytes of data at very low cost.
As memory chips continue to grow in capacity and prices fall, virtual memory is may be less
useful in the future.

Memory Types
In general, memory is of three types:
 Primary memory
 Secondary memory
 Cache memory

Now we discuss each type of memory one by one in detail:


1. Primary Memory: It is also known as the main memory of the computer system. It is
used to store data and programs or instructions during computer operations. It uses
semiconductor technology and hence is commonly called semiconductor memory.
Primary memory is of two types:
(i) RAM (Random Access Memory): It is a volatile memory. Volatile memory stores
information based on the power supply. If the power supply fails/ interrupted/stopped, all
the data & information on this memory will be lost. RAM is used for booting up or start the
computer. It temporarily stores programs/ data which has to be executed by the
processor. RAM is of two types:
 S RAM (Static RAM): It uses transistors and the circuits of this memory are capable
of retaining their state as long as the power is applied. This memory consists of the
number of flip flops with each flip flop storing 1 bit. It has less access time and hence,
it is faster.
 D RAM (Dynamic RAM): It uses capacitors and transistors and stores the data as a
charge on the capacitors. They contain thousands of memory cells. It needs
refreshing of charge on capacitor after a few milliseconds. This memory is slower than
S RAM.
(ii) ROM (Read Only Memory): It is a non-volatile memory. Non-volatile memory stores
information even when there is a power supply failed/ interrupted/stopped. ROM is used
to store information that is used to operate the system. As its name refers to read-only
memory, we can only read the programs and data that is stored on it. It contains some
electronic fuses that can be programmed for a piece of specific information. The
information stored in the ROM in binary format. It is also known as permanent memory.
ROM is of four types:
 MROM (Masked ROM): Hard-wired devices with a pre-programmed collection of data
or instructions were the first ROMs. Masked ROMs are a type of low-cost ROM that
works in this way.
 PROM (Programmable Read Only Memory): This read-only memory is modifiable
once by the user. The user purchases a blank PROM and uses a PROM program to
put the required contents into the PROM. Its content can’t be erased once written.
 EPROM (Erasable Programmable Read Only Memory): It is an extension to PROM
where you can erase the content of ROM by exposing it to Ultraviolet rays for nearly
40 minutes.
 EEPROM (Electrically Erasable Programmable Read Only Memory): Here the
written contents can be erased electrically. You can delete and reprogramme
EEPROM up to 10,000 times. Erasing and programming take very little time, i.e.,
nearly 4 -10 ms(milliseconds). Any area in an EEPROM can be wiped and
programmed selectively.
2. Secondary Memory: It is also known as auxiliary memory and backup memory. It is a
non-volatile memory and used to store a large amount of data or information. The data or
information stored in secondary memory is permanent, and it is slower than primary
memory. A CPU cannot access secondary memory directly. The data/information from
the auxiliary memory is first transferred to the main memory, and then the CPU can
access it.
Characteristics of Secondary Memory:
 It is a slow memory but reusable.
 It is a reliable and non-volatile memory.
 It is cheaper than primary memory.
 The storage capacity of secondary memory is large.
 A computer system can run without secondary memory.
 In secondary memory, data is stored permanently even when the power is off.
Types of secondary memory(Auxiliary Memory):
(i) Magnetic Tapes: Magnetic tape is a long, narrow strip of plastic film with a thin,
magnetic coating on it that is used for magnetic recording. Bits are recorded on tape as
magnetic patches called RECORDS that run along many tracks. Typically, 7 or 9 bits are
recorded concurrently. Each track has one read/write head, which allows data to be
recorded and read as a sequence of characters. It can be stopped, started moving
forward or backward, or rewound.
(ii) Magnetic Disks: A magnetic disc is a circular metal or a plastic plate and these
plates are coated with magnetic material. The disc is used on both sides. Bits are stored
in magnetized surfaces in locations called tracks that run in concentric rings. Sectors are
typically used to break tracks into pieces.
Hard discs are discs that are permanently attached and cannot be removed by a single
user.
(iii) Optical Disks: It’s a laser-based storage medium that can be written to and read. It
is reasonably priced and has a long lifespan. The optical disc can be taken out of the
computer by occasional users. Types of Optical Disks :
(a) CD – ROM:
 It’s called Compact Disk. Only read from memory.
 Information is written to the disc by using a controlled laser beam to burn pits on the
disc surface.
 It has a highly reflecting surface, which is usually aluminum.
 The diameter of the disc is 5.25 inches.
 16000 tracks per inch is the track density.
 The capacity of a CD-ROM is 600 MB, with each sector storing 2048 bytes of data.
 The data transfer rate is about 4800KB/sec. & the new access time is around 80
milliseconds.
(b) WORM-(WRITE ONCE READ MANY):
 A user can only write data once.
 The information is written on the disc using a laser beam.
 It is possible to read the written data as many times as desired.
 They keep lasting records of information but access time is high.
 It is possible to rewrite updated or new data to another part of the disc.
 Data that has already been written cannot be changed.
 Usual size – 5.25 inch or 3.5 inch diameter.
 The usual capacity of 5.25 inch disk is 650 MB,5.2GB etc.
(c) DVDs:
 The term “DVD” stands for “Digital Versatile/Video Disc,” and there are two sorts of
DVDs: (i)DVDR (writable) and (ii) DVDRW (Re-Writable)
 DVD-ROMS (Digital Versatile Discs): These are read-only memory (ROM) discs that
can be used in a variety of ways. When compared to CD-ROMs, they can store a lot
more data. It has a thick polycarbonate plastic layer that serves as a foundation for the
other layers. It’s an optical memory that can read and write data.
 DVD-R: It is a writable optical disc that can be used just once. It’s a DVD that can be
recorded. It’s a lot like WORM. DVD-ROMs have capacities ranging from 4.7 to 17
GB. The capacity of 3.5 inch disk is 1.3 GB.
3. Cache Memory: It is a type of high-speed semiconductor memory that can help the
CPU run faster. Between the CPU and the main memory, it serves as a buffer. It is used
to store the data and programs that the CPU uses the most frequently.
Advantages of cache memory:
 It is faster than the main memory.
 When compared to the main memory, it takes less time to access it.
 It keeps the programs that can be run in a short amount of time.
 It stores data in temporary use.
Disadvantages of cache memory:
 Because of the semiconductors used, it is very expensive.
 The size of the cache (amount of data it can store) is usually small.

Sample Problems

Question 1. What are the types of memories?


Solution:
There are three types of memory:
 Primary memory
 Secondary memory
 Cache memory
Question 2. What is Volatile and Non Volatile memory?
Solution:
Volatile memory is used to store information based on power supply. If the power supply
is off, all the data & information on this memory will be lost. For example, RAM (Random
Access Memory). Whereas non-volatile memory is used to store information even when
the power supply is off. For example, ROM (Read Only Memory).
Question 3. What is the full form of CD-ROM?
Solution:
CD-ROM is stands for compact disk read only memory
Question 4. How many 128 * 8 memory chips are required for a memory capacity of
4096*16?
Solution:
Number of chips required = Required RAM size/ Available chip capacity
= (4096 * 16)/(128 * 8) = 64
Question 5. Explain any four differences between RAM and ROM?
Solution:
RAM ROM

It stands for Random access memory. It stands for read only memory.

It is the fastest memory. It is slower memory as compare to RAM.

It is volatile memory. It is non-volatile memory.


RAM ROM

In this memory, data will erase when the In this memory, data will not erase even if the
power is off power is off

Question 6. How to erase data in EPROM?


Solution:
In EPROM, using ultraviolet rays we can easily erase data

Associative Memory
Associative memory is also known as content addressable memory (CAM) or associative
storage or associative array. It is a special type of memory that is optimized for performing
searches through data, as opposed to providing a simple direct access to the data based on
the address.
it can store the set of patterns as memories when the associative memory is being presented
with a key pattern, it responds by producing one of the stored pattern which closely
resembles or relates to the key pattern.
it can be viewed as data correlation here. input data is correlated with that of stored data
in the CAM.
it forms of two type:
1. auto associative memory network
2. hetero associative memory network
Associative memory of conventional semiconductor memory (usually RAM) with added
comparison circuity that enables a search operation to complete in a single clock cycle. It is
a hardware search engine, a special type of computer memory used in certain very high
searching applications. Applications of Associative memory :-
1. It can be only used in memory allocation format.
2. It is widely used in the database management systems, etc.
Advantages of Associative memory :-
1. It is used where search time needs to be less or short.
2. It is suitable for parallel searches.
3. It is often used to speedup databases.
4. It is used in page tables used by the virtual memory and used in neural networks.
Disadvantages of Associative memory :-
1. It is more expensive than RAM.
2. Each cell must have storage capability and logical circuits for matching its content with
external argument.

CACHE MEMORY
Cache memory is a chip-based computer component that makes retrieving data from
the computer's memory more efficient. It acts as a temporary storage area that the
computer's processor can retrieve data from easily. This temporary storage area,
known as a cache, is more readily available to the processor than the computer's main
memory source, typically some form of DRAM.

Cache memory is sometimes called CPU (central processing unit) memory because it
is typically integrated directly into the CPU chip or placed on a separate chip that has a
separate bus interconnect with the CPU. Therefore, it is more accessible to the
processor, and able to increase efficiency, because it's physically close to the
processor.

In order to be close to the processor, cache memory needs to be much smaller than
main memory. Consequently, it has less storage space. It is also more expensive than
main memory, as it is a more complex chip that yields higher performance.

What it sacrifices in size and price, it makes up for in speed. Cache memory operates
between 10 to 100 times faster than RAM, requiring only a few nanoseconds to
respond to a CPU request.

The name of the actual hardware that is used for cache memory is high-speed static
random access memory (SRAM). The name of the hardware that is used in a
computer's main memory is dynamic random access memory (DRAM).

Cache memory is not to be confused with the broader term cache. Caches are
temporary stores of data that can exist in both hardware and software. Cache memory
refers to the specific hardware component that allows computers to create caches at
various levels of the network.

Types of cache memory


Cache memory is fast and expensive. Traditionally, it is categorized as "levels" that describe its
closeness and accessibility to the microprocessor. There are three general cache levels:

L1 cache, or primary cache, is extremely fast but relatively small, and is usually embedded in
the processor chip as CPU cache.
L2 cache, or secondary cache, is often more capacious than L1. L2 cache may be embedded on
the CPU, or it can be on a separate chip or coprocessor and have a high-speed alternative system
bus connecting the cache and CPU. That way it doesn't get slowed by traffic on the main system
bus.

Level 3 (L3) cache is specialized memory developed to improve the performance of L1 and L2.
L1 or L2 can be significantly faster than L3, though L3 is usually double the speed of DRAM.
With multicore processors, each core can have dedicated L1 and L2 cache, but they can share an
L3 cache. If an L3 cache references an instruction, it is usually elevated to a higher level of
cache.

In the past, L1, L2 and L3 caches have been created using combined processor and motherboard
components. Recently, the trend has been toward consolidating all three levels of memory
caching on the CPU itself. That's why the primary means for increasing cache size has begun to
shift from the acquisition of a specific motherboard with different chipsets and bus architectures
to buying a CPU with the right amount of integrated L1, L2 and L3 cache.

Contrary to popular belief, implementing flash or more dynamic RAM (DRAM) on a system
won't increase cache memory. This can be confusing since the terms memory caching (hard disk
buffering) and cache memory are often used interchangeably. Memory caching, using DRAM or
flash to buffer disk reads, is meant to improve storage I/O by caching data that is frequently
referenced in a buffer ahead of slower magnetic disk or tape. Cache memory, on the other hand,
provides read buffering for the CPU.
A
diagram of the architecture and data flow of a typical cache memory unit.

Cache memory mapping


Caching configurations continue to evolve, but cache memory traditionally works under three
different configurations:

 Direct mapped cache has each block mapped to exactly one cache memory location.
Conceptually, a direct mapped cache is like rows in a table with three columns: the cache
block that contains the actual data fetched and stored, a tag with all or part of the address
of the data that was fetched, and a flag bit that shows the presence in the row entry of a
valid bit of data.

 Fully associative cache mapping is similar to direct mapping in structure but allows a
memory block to be mapped to any cache location rather than to a prespecified cache
memory location as is the case with direct mapping.

 Set associative cache mapping can be viewed as a compromise between direct mapping
and fully associative mapping in which each block is mapped to a subset of cache locations.
It is sometimes called N-way set associative mapping, which provides for a location in main
memory to be cached to any of "N" locations in the L1 cache.
Data writing policies
Data can be written to memory using a variety of techniques, but the two main ones involving
cache memory are:

 Write-through. Data is written to both the cache and main memory at the same time.

 Write-back. Data is only written to the cache initially. Data may then be written to main
memory, but this does not need to happen and does not inhibit the interaction from taking
place.

The way data is written to the cache impacts data consistency and efficiency. For example, when
using write-through, more writing needs to happen, which causes latency upfront. When using
write-back, operations may be more efficient, but data may not be consistent between the main
and cache memories.

One way a computer determines data consistency is by examining the dirty bit in memory. The
dirty bit is an extra bit included in memory blocks that indicates whether the information has
been modified. If data reaches the processor's register file with an active dirty bit, it means that it
is not up to date and there are more recent versions elsewhere. This scenario is more likely to
happen in a write-back scenario, because the data is written to the two storage areas
asynchronously.

Specialization and functionality


In addition to instruction and data caches, other caches are designed to provide specialized
system functions. According to some definitions, the L3 cache's shared design makes it a
specialized cache. Other definitions keep the instruction cache and the data cache separate and
refer to each as a specialized cache.

Translation lookaside buffers (TLBs) are also specialized memory caches whose function is to
record virtual address to physical address translations.

Still other caches are not, technically speaking, memory caches at all. Disk caches, for instance,
can use DRAM or flash memory to provide data caching similar to what memory caches do with
CPU instructions. If data is frequently accessed from the disk, it is cached into DRAM or flash-
based silicon storage technology for faster access time and response.

Specialized caches are also available for applications such as web browsers, databases, network
address binding and client-side Network File System protocol support. These types of caches
might be distributed across multiple networked hosts to provide greater scalability or
performance to an application that uses them.

A
depiction of the Pipeline Hazardsy and how it functions

Locality
The ability of cache memory to improve a computer's performance relies on the concept of
locality of reference. Locality describes various situations that make a system more predictable.
Cache memory takes advantage of these situations to create a pattern of memory access that it
can rely upon.

There are several types of locality. Two key ones for cache are:

 Temporal locality. This is when the same resources are accessed repeatedly in a short
amount of time.

 Spatial locality. This refers to accessing various data or resources that are near each other.
Performance
Cache memory is important because it improves the efficiency of data retrieval. It stores
program instructions and data that are used repeatedly in the operation of programs or
information that the CPU is likely to need next. The computer processor can access this
information more quickly from the cache than from the main memory. Fast access to these
instructions increases the overall speed of the program.

Aside from its main function of improving performance, cache memory is a valuable resource
for evaluating a computer's overall performance. Users can do this by looking at cache's hit-to-
miss ratio. Cache hits are instances in which the system successfully retrieves data from the
cache. A cache miss is when the system looks for the data in the cache, can't find it, and looks
somewhere else instead. In some cases, users can improve the hit-miss ratio by adjusting the
cache memory block size -- the size of data units stored.

Improved performance and ability to monitor performance are not just about improving general
convenience for the user. As technology advances and is increasingly relied upon in mission-
critical scenarios, having speed and reliability becomes crucial. Even a few milliseconds of
latency could potentially lead to enormous expenses, depending on the situation.

A chart
Cache vs. main memory
DRAM serves as a computer's main memory, performing calculations on data retrieved from
storage. Both DRAM and cache memory are volatile memories that lose their contents when the
power is turned off. DRAM is installed on the motherboard, and the CPU accesses it through a
bus connection.

DRAM is usually about half as fast as L1, L2 or L3 cache memory, and much less expensive. It
provides faster data access than flash storage, hard disk drives (HDD) and tape storage. It came
into use in the last few decades to provide a place to store frequently accessed disk data to
improve I/O performance.

DRAM must be refreshed every few milliseconds. Cache memory, which also is a type of
random access memory, does not need to be refreshed. It is built directly into the CPU to give
the processor the fastest possible access to memory locations and provides nanosecond speed
access time to frequently referenced instructions and data. SRAM is faster than DRAM, but
because it's a more complex chip, it's also more expensive to make.

Cache vs. virtual memory


A computer has a limited amount of DRAM and even less cache memory. When a large
program or multiple programs are running, it's possible for memory to be fully used. To
compensate for a shortage of physical memory, the computer's operating system (OS) can
create virtual memory.

To do this, the OS temporarily transfers inactive data from DRAM to disk storage. This
approach increases virtual address space by using active memory in DRAM and inactive
memory in HDDs to form contiguous addresses that hold both an application and its data.
Virtual memory lets a computer run larger programs or multiple programs simultaneously, and
each program operates as though it has unlimited memory.

In order to copy virtual memory into physical memory, the OS divides memory into page files
or swap files that contain a certain number of addresses. Those pages are stored on a disk and
when they're needed, the OS copies them from the disk to main memory and translates the
virtual memory address into a physical one. These translations are handled by a memory
management unit (MMU).
CACHE SIZE VS BLOCK SIZE

Cache size, Block size, Mapping function, Replacement algorithm, and Write
policy. These are explained as following below.

1. Cache Size:
It seems that moderately tiny caches will have a big impact on performance.
2. Block Size:
Block size is the unit of information changed between cache and main
memory.
As the block size will increase from terribly tiny to larger sizes, the hit
magnitude relation can initially increase as a result of the principle of
[Link] high chance that knowledge within the neck of the woods of a
documented word square measure possible to be documented within the
close to future. As the block size increases, a lot of helpful knowledge square
measure brought into the cache.
The hit magnitude relation can begin to decrease, however, because the
block becomes even larger and also the chance of victimization the new
fetched knowledge becomes but the chance of reusing the information that
ought to be abstracted of the cache to form area for the new block.
3. Mapping Function:
When a replacement block of data is scan into the cache, the mapping
performs determines that cache location the block will occupy. Two
constraints have an effect on the planning of the mapping perform. First,
once one block is scan in, another could be replaced.
We would wish to do that in such the simplest way to minimize the chance
that we are going to replace a block which will be required within the close
to future. A lot of versatile the mapping perform, a lot of scopes we’ve to
style a replacement algorithmic rule to maximize the hit magnitude relation.
Second, a lot of versatile the mapping perform, a lot of advanced is that the
electronic equipment needed to look the cache to see if a given block is
within the cache.
4. Replacement Algorithm:
The replacement algorithmic rule chooses, at intervals, the constraints of the
mapping perform, which block to interchange once a replacement block is to
be loaded into the cache and also the cache already has all slots full of
alternative blocks. We would wish to replace the block that’s least possible
to be required once more within the close to future. Although it’s impossible
to spot such a block, a fairly effective strategy is to interchange the block
that has been within the cache longest with no relevance.
This policy is spoken because of the least-recently-used (LRU) algorithmic
rule. Hardware mechanisms square measure required to spot the least-
recently-used block
5. Write Policy:
If the contents of a block within the cache square measure altered, then it’s
necessary to write down it back to main memory before exchange it. The
written policy dictates once the memory write operation takes place. At one
extreme, the writing will occur whenever the block is updated.
At the opposite extreme, the writing happens only if the block is replaced.
The latter policy minimizes memory write operations however leaves the
main memory in associate obsolete state. This can interfere with the
multiple-processor operation and with direct operation by I/O hardware
modules.
Memory Mapping and Concept of
Virtual Memory

The transformation of data from main memory to cache memory is


called mapping. There are 3 main types of mapping:

 Associative Mapping
 Direct Mapping
 Set Associative Mapping

Associative Mapping

The associative memory stores both address and data. The address
value of 15 bits is 5 digit octal numbers and data is of 12 bits word in
4 digit octal number. A CPU address of 15 bits is placed
in argument register and the associative memory is searched for
matching address.

Cpu Address 15 bit

Argument Register

Address Data
Match
Register

Output
Direct Mapping

The CPU address of 15 bits is divided into 2 fields. In this the 9 least
significant bits constitute the index field and the remaining 6 bits
constitute the tag field. The number of bits in index field is equal to
the number of address bits required to access cache memory.

TAG INDEX

Set Associative Mapping

The disadvantage of direct mapping is that two words with same


index address can't reside in cache memory at the same time. This
problem can be overcome by set associative mapping.

In this we can store two or more words of memory under the same
index address. Each data word is stored together with its tag and
this forms a set.

TAG DATA ADDRESS

Replacement Algorithms

Data is continuously replaced with new data in the cache memory


using replacement algorithms. Following are the 2 replacement
algorithms used:

 FIFO - First in First out. Oldest item is replaced with the latest
item.
 LRU - Least Recently Used. Item which is least recently used by
CPU is removed.

Virtual Memory

Virtual memory is the separation of logical memory from physical


memory. This separation provides large virtual memory for
programmers when only small physical memory is available.

Virtual memory is used to give programmers the illusion that they


have a very large ierarchmemory even though the computer has a
small main memory. It makes the task of programming easier
because the programmer no longer needs to worry about the
amount of physical memory available.

Why Need Virtual Memory?


Here, are reasons for using virtual memory:

 Whenever your computer doesn’t have space in the physical memory it writes
what it needs to remember to the hard disk in a swap file as virtual memory.
 If a computer running Windows needs more memory/RAM, then installed in the
system, it uses a small portion of the hard drive for this purpose.

How Virtual Memory Works?


In the modern world, virtual memory has become quite common these days. It is used
whenever some pages require to be loaded in the main memory for the execution, and
the memory is not available for those many pages.

So, in that case, instead of preventing pages from entering in the main memory, the OS
searches for the RAM space that are minimum used in the recent times or that are not
referenced into the secondary memory to make the space for the new pages in the
main memory.

For example:
Let’s assume that an OS requires 300 MB of memory to store all the running programs.
However, there’s currently only 50 MB of available physical memory stored on the
RAM.

 The OS will then set up 250 MB of virtual memory and use a program called the
Virtual Memory Manager(VMM) to manage that 250 MB.
 So, in this case, the VMM will create a file on the hard disk that is 250 MB in size
to store extra memory that is required.
 The OS will now proceed to address memory as it considers 300 MB of real
memory stored in the RAM, even if only 50 MB space is available.
 It is the job of the VMM to manage 300 MB memory even if just 50 MB of real
memory space is available.

What is Demand Paging?


A demand paging mechanism is very much similar to a paging system with swapping
where processes stored in the secondary memory and pages are loaded only on
demand, not in advance.

So, when a context switch occurs, the OS never copy any of the old program’s pages
from the disk or any of the new program’s pages into the main memory. Instead, it will
start executing the new program after loading the first page and fetches the program’s
pages, which are referenced.

During the program execution, if the program references a page that may not be
available in the main memory because it was swapped, then the processor considers it
as an invalid memory reference. That’s because the page fault and transfers send
control back from the program to the OS, which demands to store page back into the
memory.

Types of Page Replacement Methods


Here, are some important Page replacement methods

 FIFO
 Optimal Algorithm
 LRU Page Replacement

FIFO Page Replacement


FIFO (First-in-first-out) is a simple implementation method. In this method, memory
selects the page for a replacement that has been in the virtual address of the memory
for the longest time.
Features:
 Whenever a new page loaded, the page recently comes in the memory is
removed. So, it is easy to decide which page requires to be removed as its
identification number is always at the FIFO stack.
 The oldest page in the main memory is one that should be selected for
replacement first.

Optimal Algorithm
The optimal page replacement method selects that page for a replacement for which
the time to the next reference is the longest.

Features:
 Optimal algorithm results in the fewest number of page faults. This algorithm is
difficult to implement.
 An optimal page-replacement algorithm method has the lowest page-fault rate of
all algorithms. This algorithm exists and which should be called MIN or OPT.
 Replace the page which unlike to use for a longer period of time. It only uses the
time when a page needs to be used.

LRU Page Replacement


The full form of LRU is the Least Recently Used page. This method helps OS to find
page usage over a short period of time. This algorithm should be implemented by
associating a counter with an even- page.

How does it work?


 Page, which has not been used for the longest time in the main memory, is the
one that will be selected for replacement.
 Easy to implement, keep a list, replace pages by looking back into time.

Features:
 The LRU replacement method has the highest count. This counter is also called
aging registers, which specify their age and how much their associated pages
should also be referenced.
 The page which hasn’t been used for the longest time in the main memory is the
one that should be selected for replacement.
 It also keeps a list and replaces pages by looking back into time.

Fault rate
Fault rate is a frequency with which a designed system or component fails. It is
expressed in failures per unit of time. It is denoted by the Greek letter ? (lambda).
Advantages of Virtual Memory
Here, are pros/benefits of using Virtual Memory:

 Virtual memory helps to gain speed when only a particular segment of the
program is required for the execution of the program.
 It is very helpful in implementing a multiprogramming environment.
 It allows you to run more applications at once.
 It helps you to fit many large programs into smaller programs.
 Common data or code may be shared between memory.
 Process may become even larger than all of the physical memory.
 Data / code should be read from disk whenever required.
 The code can be placed anywhere in physical memory without requiring
relocation.
 More processes should be maintained in the main memory, which increases the
effective use of CPU.
 Each page is stored on a disk until it is required after that, it will be removed.
 It allows more applications to be run at the same time.
 There is no specific limit on the degree of multiprogramming.
 Large programs should be written, as virtual address space available is more
compared to physical memory.

Disadvantages of Virtual Memory


Here, are drawbacks/cons of using virtual memory:

 Applications may run slower if the system is using virtual memory.


 Likely takes more time to switch between applications.
 Offers lesser hard drive space for your use.
 It reduces system stability.
 It allows larger applications to run in systems that don’t offer enough physical
RAM alone to run them.
 It doesn’t offer the same performance as RAM.
 It negatively affects the overall performance of a system.
 Occupy the storage space, which may be used otherwise for long term data
storage.

Memory Management

Memory management is the functionality of an operating system which handles or manages


primary memory and moves processes back and forth between main memory and disk during
execution. Memory management keeps track of each and every memory location, regardless of
either it is allocated to some process or it is free. It checks how much memory is to be allocated to
processes. It decides which process will get memory at what time. It tracks whenever some
memory gets freed or unallocated and correspondingly it updates the status.
This tutorial will teach you basic concepts related to Memory Management.

Process Address Space


The process address space is the set of logical addresses that a process references in its code.
For example, when 32-bit addressing is in use, addresses can range from 0 to 0x7fffffff; that is,
2^31 possible numbers, for a total theoretical size of 2 gigabytes.
The operating system takes care of mapping the logical addresses to physical addresses at the
time of memory allocation to the program. There are three types of addresses used in a program
before and after memory is allocated −

S.N Memory Addresses & Description


.

1
Symbolic addresses
The addresses used in a source code. The variable names, constants, and
instruction labels are the basic elements of the symbolic address space.

2
Relative addresses
At the time of compilation, a compiler converts symbolic addresses into relative
addresses.

3
Physical addresses
The loader generates these addresses at the time when a program is loaded into
main memory.

Virtual and physical addresses are the same in compile-time and load-time address-binding
schemes. Virtual and physical addresses differ in execution-time address-binding scheme.
The set of all logical addresses generated by a program is referred to as a logical address
space. The set of all physical addresses corresponding to these logical addresses is referred to as
a physical address space.
The runtime mapping from virtual to physical address is done by the memory management unit
(MMU) which is a hardware device. MMU uses following mechanism to convert virtual address to
physical address.
 The value in the base register is added to every address generated by a user process,
which is treated as offset at the time it is sent to memory. For example, if the base register
value is 10000, then an attempt by the user to use address location 100 will be dynamically
reallocated to location 10100.
 The user program deals with virtual addresses; it never sees the real physical addresses.

Static vs Dynamic Loading


The choice between Static or Dynamic Loading is to be made at the time of computer program
being developed. If you have to load your program statically, then at the time of compilation, the
complete programs will be compiled and linked without leaving any external program or module
dependency. The linker combines the object program with other necessary object modules into an
absolute program, which also includes logical addresses.
If you are writing a Dynamically loaded program, then your compiler will compile the program and
for all the modules which you want to include dynamically, only references will be provided and
rest of the work will be done at the time of execution.
At the time of loading, with static loading, the absolute program (and data) is loaded into memory
in order for execution to start.
If you are using dynamic loading, dynamic routines of the library are stored on a disk in
relocatable form and are loaded into memory only when they are needed by the program.

Static vs Dynamic Linking


As explained above, when static linking is used, the linker combines all other modules needed by
a program into a single executable program to avoid any runtime dependency.
When dynamic linking is used, it is not required to link the actual module or library with the
program, rather a reference to the dynamic module is provided at the time of compilation and
linking. Dynamic Link Libraries (DLL) in Windows and Shared Objects in Unix are good examples
of dynamic libraries.

Swapping
Swapping is a mechanism in which a process can be swapped temporarily out of main memory (or
move) to secondary storage (disk) and make that memory available to other processes. At some
later time, the system swaps back the process from the secondary storage to main memory.
Though performance is usually affected by swapping process but it helps in running multiple and
big processes in parallel and that's the reason Swapping is also known as a technique for
memory compaction.
The total time taken by swapping process includes the time it takes to move the entire process to
a secondary disk and then to copy the process back to memory, as well as the time the process
takes to regain main memory.
Let us assume that the user process is of size 2048KB and on a standard hard disk where
swapping will take place has a data transfer rate around 1 MB per second. The actual transfer of
the 1000K process to or from memory will take
2048KB / 1024KB per second
= 2 seconds
= 2000 milliseconds
Now considering in and out time, it will take complete 4000 milliseconds plus other overhead
where the process competes to regain main memory.

Memory Allocation
Main memory usually has two partitions −
 Low Memory − Operating system resides in this memory.
 High Memory − User processes are held in high memory.
Operating system uses the following memory allocation mechanism.
S.N Memory Allocation & Description
.

1
Single-partition allocation
In this type of allocation, relocation-register scheme is used to protect user
processes from each other, and from changing operating-system code and data.
Relocation register contains value of smallest physical address whereas limit
register contains range of logical addresses. Each logical address must be less
than the limit register.

2
Multiple-partition allocation
In this type of allocation, main memory is divided into a number of fixed-sized
partitions where each partition should contain only one process. When a partition
is free, a process is selected from the input queue and is loaded into the free
partition. When the process terminates, the partition becomes available for
another process.

Fragmentation
As processes are loaded and removed from memory, the free memory space is broken into little
pieces. It happens after sometimes that processes cannot be allocated to memory blocks
considering their small size and memory blocks remains unused. This problem is known as
Fragmentation.
Fragmentation is of two types −

S.N Fragmentation & Description


.

1
External fragmentation
Total memory space is enough to satisfy a request or to reside a process in it, but
it is not contiguous, so it cannot be used.

2
Internal fragmentation
Memory block assigned to process is bigger. Some portion of memory is left
unused, as it cannot be used by another process.

The following diagram shows how fragmentation can cause waste of memory and a compaction
technique can be used to create more free memory out of fragmented memory −
External fragmentation can be reduced by compaction or shuffle memory contents to place all free
memory together in one large block. To make compaction feasible, relocation should be dynamic.
The internal fragmentation can be reduced by effectively assigning the smallest partition but large
enough for the process.

Paging
A computer can address more memory than the amount physically installed on the system. This
extra memory is actually called virtual memory and it is a section of a hard that's set up to emulate
the computer's RAM. Paging technique plays an important role in implementing virtual memory.
Paging is a memory management technique in which process address space is broken into blocks
of the same size called pages (size is power of 2, between 512 bytes and 8192 bytes). The size of
the process is measured in the number of pages.
Similarly, main memory is divided into small fixed-sized blocks of (physical) memory
called frames and the size of a frame is kept the same as that of a page to have optimum
utilization of the main memory and to avoid external fragmentation.
Address Translation
Page address is called logical address and represented by page number and the offset.
Logical Address = Page number + page offset
Frame address is called physical address and represented by a frame number and the offset.
Physical Address = Frame number + page offset
A data structure called page map table is used to keep track of the relation between a page of a
process to a frame in physical memory.
When the system allocates a frame to any page, it translates this logical address into a physical
address and create entry into the page table to be used throughout execution of the program.
When a process is to be executed, its corresponding pages are loaded into any available memory
frames. Suppose you have a program of 8Kb but your memory can accommodate only 5Kb at a
given point in time, then the paging concept will come into picture. When a computer runs out of
RAM, the operating system (OS) will move idle or unwanted pages of memory to secondary
memory to free up RAM for other processes and brings them back when needed by the program.
This process continues during the whole execution of the program where the OS keeps removing
idle pages from the main memory and write them onto the secondary memory and bring them
back when required by the program.
Advantages and Disadvantages of Paging
Here is a list of advantages and disadvantages of paging −
 Paging reduces external fragmentation, but still suffer from internal fragmentation.
 Paging is simple to implement and assumed as an efficient memory management
technique.
 Due to equal size of the pages and frames, swapping becomes very easy.
 Page table requires extra memory space, so may not be good for a system having small
RAM.

Segmentation
Segmentation is a memory management technique in which each job is divided into several
segments of different sizes, one for each module that contains pieces that perform related
functions. Each segment is actually a different logical address space of the program.
When a process is to be executed, its corresponding segmentation are loaded into non-contiguous
memory though every segment is loaded into a contiguous block of available memory.
Segmentation memory management works very similar to paging but here segments are of
variable-length where as in paging pages are of fixed size.
A program segment contains the program's main function, utility functions, data structures, and so
on. The operating system maintains a segment map table for every process and a list of free
memory blocks along with segment numbers, their size and corresponding memory locations in
main memory. For each segment, the table stores the starting address of the segment and the
length of the segment. A reference to a memory location includes a value that identifies a segment
and an offset.

You might also like