Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Chapter 7

This document outlines memory organization and caching techniques in computer systems. It discusses the memory hierarchy from fast cache memory to main memory to slower external storage. It describes direct, associative, and set associative mapping of memory blocks to cache lines. Direct mapping allows each block to map to only one cache line, while associative mapping allows blocks to map to any line. Set associative mapping groups lines into sets, allowing blocks to map to any line within a set. This improves on direct mapping by reducing conflicts from blocks mapping to the same line.

Uploaded by

gemedakelbesa9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Chapter 7

This document outlines memory organization and caching techniques in computer systems. It discusses the memory hierarchy from fast cache memory to main memory to slower external storage. It describes direct, associative, and set associative mapping of memory blocks to cache lines. Direct mapping allows each block to map to only one cache line, while associative mapping allows blocks to map to any line. Set associative mapping groups lines into sets, allowing blocks to map to any line within a set. This improves on direct mapping by reducing conflicts from blocks mapping to the same line.

Uploaded by

gemedakelbesa9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

Chapter 7:

Memory Organization
Chapter Objectives
7.1. Memory Hierarchy
7.2. Main memory
7.3. Cache memory
7.4. Mapping functions
7.4.1. Direct mapping
7.4.2. Associative mapping
7.4.3. Set associative mapping
7.5. External memory
7.5.1. Magnetic disks
7.5.2. RAID technology
7.5.3. Optical disks
7.5.4. Magnetic tape
• Memory Organization in Computer Architecture
• The memory is divided into cells; each of them is identified by a unique number
called an address. The CPU generates the memory request in order to access the
instruction. When the CPU wants to read or write an address, it generates control
signals such as “read” and “write,” which each cell can identify. Because the
program is present in memory, the instruction must be transferred from memory
to the CPU whenever the CPU executes the program.
• Memory Request
• The address and control signals are included in the memory request. When
inserting data and information into the stack, each block uses memory (in the
form of RAM), and the number of memory cells is determined by the memory
chip’s capacity.
Example
• We will find the number of cells present in the 64k*8 memory chips.
• Here, the size of each cell = 8
• And the number of bytes present in 64k = (2^6)*(2^10)
• Thus, Total number of cells here = 2^16 cells
• Along with the total number of cells, the total number of address lines that are
needed to enable any cell can be determined here.
• Word Size
• It refers to the maximum amount of bits a CPU
can handle at one time, and it fluctuates by the
processor. The hardware or the instruction set of a
processor handles a fixed amount of data as a unit
called word size.
• Because of generation and current technology,
word size varies based on processor architectures;
it could be as small as 4-bits or as large as 64-bits,
depending on what a given processor can handle.
Addresses, Registers, Fixed-point numbers, and
Floating-point numbers are all examples of
notions that require word size.
7.1. Memory Hierarchy
• The total memory capacity of a computer can be visualized by hierarchy of
components. The memory hierarchy system consists of all storage devices
contained in a computer system from the slow Auxiliary Memory to fast Main
Memory and to smaller Cache memory.
• Auxillary memory access time is generally 1000 times that of the main
memory, hence it is at the bottom of the hierarchy.
• The main memory occupies the central position because it is equipped to
communicate directly with the CPU and with auxiliary memory devices
through Input/output processor (I/O).
• When the program not residing in main memory is needed by the CPU, they
are brought in from auxiliary memory. Programs not currently needed in main
memory are transferred into auxiliary memory to provide space in main
memory for other programs that are currently in use.
• The cache memory is used to store program data which is currently being
executed in the CPU. Approximate access time ratio between cache memory
and main memory is about 1 to 7~10
• The cache memory is very small, relatively expensive, and has very high
access speed. The CPU has direct access to both cache and main memory but
not to auxiliary memory.
Memory Access Methods:
• Each memory type, is a collection of numerous
memory locations. To access data from any memory,
first it must be located and then the data is read from
the memory location. Following are the methods to
access information from memory locations:
• Random Access: Main memories are random access
memories, in which each memory location has a
unique address. Using this unique address any
memory location can be reached in the same amount
of time in any order.
• Sequential Access: This methods allows memory
access in a sequence or in order.
• Direct Access: In this mode, information is stored in
tracks, with each track having a separate read/write
head.
7.2. Main memory
• The memory unit that communicates directly within the CPU,
Auxillary memory and Cache memory, is called main memory. It is
the central storage unit of the computer system. It is a large and fast
memory used to store data during computer operations. Main
memory is made up of RAM and ROM, with RAM integrated
circuit chips holing the major share.
• RAM: Random Access Memory
– DRAM: Dynamic RAM, is made of capacitors and transistors,
and must be refreshed every 10~100 ms. It is slower and cheaper
than SRAM.
– SRAM: Static RAM, has a six transistor circuit in each cell and
retains data, until powered off.
– NVRAM: Non-Volatile RAM, retains its data, even when turned
off. Example: Flash memory.
• ROM: Read Only Memory, is non-volatile and is more like a
permanent storage for information. It also stores the bootstrap
loader program, to load and start the operating system when
computer is turned on.
• PROM(Programmable ROM), EPROM(Erasable PROM)
Auxiliary Memory
• Devices that provide backup storage are called
auxiliary memory. For example: Magnetic
disks and tapes are commonly used auxiliary
devices. Other devices used as auxiliary
memory are magnetic drums, magnetic
bubble memory and optical disks.
• It is not directly accessible to the CPU, and is
accessed using the Input/Output channels.
7.3. Cache memory
• The data or contents of the main memory that are used again
and again by CPU, are stored in the cache memory so that we
can easily access that data in shorter time.
• Whenever the CPU needs to access memory, it first checks the
cache memory. If the data is not found in cache memory then
the CPU moves onto the main memory. It also transfers block
of recent data into the cache and keeps on deleting the old data
in cache to accomodate the new one.
• Hit Ratio:
• The performance of cache memory is measured in terms of a
quantity called hit ratio. When the CPU refers to memory and
finds the word in cache it is said to produce a hit. If the word
is not found in cache, it is in main memory then it counts as
a miss.
• The ratio of the number of hits to the total CPU references to
memory is called hit ratio.
• Hit Ratio = Hit/(Hit + Miss)

Hit Ratio(H) = hit / (hit + miss) = no. of hits/total accesses
Miss Ratio = miss / (hit + miss) = no. of miss/total accesses = 1 - hit ratio(H)
Case 1 : System Design without Cache Memory

Case 2 : System Design with Cache Memory

Case 3 : System Design with Multilevel Cache Memory


• Solution is Tag: To handle above problem, more
information is stored in cache to tell which block
of memory is stored in cache. We store additional
information as Tag
7.4. Mapping functions
• The transformation of data from main
memory to cache memory is called
mapping.
There are 3 main types of mapping:
• Direct Mapping
• Associative Mapping
• Set Associative Mapping
.
• 1. 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.
• An address space is split into two parts index field and a
tag field.
• The cache is used to store the tag field whereas the rest is
stored in the main memory.
• Direct mapping`s performance is directly proportional to
the Hit ratio.
• i = j modulo m
where i = cache line number
• j = main memory block number
• 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.

• The above arrangement is Direct Mapped Cache
and it has following problem We have discussed
above that last few bits of memory addresses are
being used to address in cache and remaining bits
are stored as tag. Now imagine that cache is very
small and addresses of 2 bits.
• Suppose we use the last two bits of main
memory address to decide the cache (as shown
in below diagram). So if a program accesses 2, 6,
2, 6, 2, …, every access would cause a hit as 2 and
6 have to be stored in same location in cache.
2. Associative Mapping
• In this type of mapping, associative memory is used
to store the content and addresses of the memory
word.
• Any block can go into any line of the cache. This
means that the word id bits are used to identify
which word in the block is needed, but the tag
becomes all of the remaining bits.
• This enables the placement of any word at any
place in the cache memory. It is considered to be
the fastest and most flexible mapping form. In
associative mapping, the index bits are zero.
• A CPU address of 15 bits is placed in argument
register and the associative memory is searched for
matching address.
3. Set-Associative Mapping
• This form of mapping is an enhanced form of direct mapping
where the drawbacks of direct mapping are removed.
• Set associative addresses the problem of possible thrashing in the
direct mapping method. It does this by saying that instead of
having exactly one line that a block can map to in the cache, we
will group a few lines together creating a set.
• Then a block in memory can map to any one of the lines of a
specific set.
• Set-associative mapping allows each word that is present in the
cache can have two or more words in the main memory for the
same index address.
• Set associative cache mapping combines the best of direct and
associative cache mapping techniques.
• In set associative mapping the index bits are given by the set
offset bits. In this case, the cache consists of a number of sets,
each of which consists of a number of lines.
Relationships in the Set-Associative Mapping can be defined as:
m=v*k
i= j mod v
where
i = cache set number
j = main memory block number
v = number of sets
m = number of lines in the cache number of sets
k = number of lines in each set
Application of Cache Memory
• Here are some of the applications of Cache Memory.
• Primary Cache: A primary cache is always located on the
processor chip. This cache is small and its access time is
comparable to that of processor registers.
• Secondary Cache: Secondary cache is placed between the
primary cache and the rest of the memory. It is referred to as the
level 2 (L2) cache. Often, the Level 2 cache is also housed on the
processor chip.
• Spatial Locality of Reference: Spatial Locality of Reference says
that there is a chance that the element will be present in close
proximity to the reference point and next time if again searched
then more close proximity to the point of reference.
• Temporal Locality of Reference: Temporal Locality of
Reference uses the Least recently used algorithm will be used.
Whenever there is page fault occurs within a word will not only
load the word in the main memory but the complete page fault will
be loaded because the spatial locality of reference rule says that if
you are referring to any word next word will be referred to in its
register that’s why we load complete page table so the complete
block will be loaded.
Advantages of Cache Memory
• Cache Memory is faster in comparison to main memory and
secondary memory.
• Programs stored by Cache Memory can be executed in less time.
• The data access time of Cache Memory is less than that of the main
memory.
• Cache Memory stored data and instructions that are regularly used
by the CPU, therefore it increases the performance of the CPU.
Disadvantages of Cache Memory
• Cache Memory is costlier than primary memory and secondary
memory.
• Data is stored on a temporary basis in Cache Memory.
• Whenever the system is turned off, data and instructions stored in
cache memory get destroyed.
• The high cost of cache memory increases the price of the Computer
System.
7.5. External memory
What is Secondary Memory?
• Memory in a computer refers to the physical components that
are used to temporarily or permanently store programmes or
data. It’s a collection of registers.
• Primary memory is very volatile and has a finite amount of
storage space. As a result, having a second type of memory
with a bigger storage capacity- from which programs and data
are not lost whenever the computer is turned off is critical.
• Secondary memory is the term for this form of memory.
Programs and data are stored in secondary memory. Auxiliary
memory is another name for it. It differs from primary memory
in that it is non-volatile and not directly accessible by the CPU.
Secondary storage devices, often known as external storage
devices, have substantially more storage space and are less
expensive than primary memory.
Types of Secondary Memory
• There are two types of secondary memory:
1. Fixed Storage
• A fixed storage device in secondary memory is an internal
media device used to store data in a computer system. Fixed
storage is sometimes known as hard drives or the fixed disc
drives. In most cases, the computer system’s data is saved in
the fixed storage device that’s incorporated into a given
system. Fixed storage does not preclude their removal from
the computer system; with the assistance of an expert or
engineer, you may remove the fixed storage device for
repairs, upgrades, or maintenance, among other things.
Types of fixed storage:
• Here are the different types of fixed storage:
• Hard disk drives (HDD)
• SSD (solid-state disk)
• Internal flash memory (rare)
2. Removable Storage
• Removable storage refers to an external media device that is mainly
used to store data on a computer system in secondary memory. The
disk drives or the external drives are common names for removable
storage. It’s a removable storage device that can be inserted or
withdrawn from the computer as needed. We can uninstall them
effortlessly from a computer system while it’s still running. We can
transfer data from any computer to another one simply using
removable storage devices because they are portable. Also,
removable storage devices provide high data and information
transfer speeds that the storage area networks (or SANs) are known
for.
• Types of Removable Storage:
• Here are the types of removable storage:
• Optical discs (such as DVDs, CDs, Blu-ray discs, etc.)
• Floppy disks
• Memory cards
• Disk packs
• Magnetic tapes
• Paper storage (such as punched cards, punched tapes, etc.)
• The magnetic and optical disks are the storage devices that
provide a way to store data for a long duration. Both are
categorized under the category of secondary storage devices.
• Magneticdisk:

A magnetic disk is a storage device that uses a magnetization
process to read, write, rewrite and access data. The Magnetic disk
is made of a set of circular platters. It is covered with a magnetic
coating and stores data in the form of tracks, spots, and sectors.
Hard disks, zip disks, and floppy disks are common examples
of magnetic disks. The number of bits stored on each track does
not change by using the simplest constant angular velocity.
• Optical disk:
An optical disk is any computer disk that uses optical storage
techniques and technology to read and write data. It is a storage
device for optical (light) energy. It is a computer storage disk that
stores data digitally and uses laser beams to read and write data.
It uses optical technology in which laser light is centered to the
spinning disks. Examples include CD,DVD,Blue-ray, and more.
Magnetic tape:
• Magnetic tape, similar to the tape used in tape
recorders, has also been used for auxiliary
storage, primarily for archiving data. Tape is
cheap, but access time is far slower than that of a
magnetic disk because it is sequential-access
memory—i.e., data must be sequentially read and
written as a tape is unwound, rather than retrieved
directly from the desired point on the tape.
Servers may also use large collections of tapes or
optical discs, with robotic devices to select and
load them, rather like old-fashioned jukeboxes.
What is RAID
• RAID (originally redundant array of inexpensive disks;
now commonly redundant array of independent disks)
is a data storage virtualization technology that
combines multiple disk drive components into a logical
unit for the purposes of data redundancy or
performance improvement.
• Data is distributed across the drives in one of several
ways, referred to as RAID levels, depending on the
specific level of redundancy and performance required.
The different schemes or architectures are named by the
word RAID followed by a number (e.g. RAID 0, RAID
1). Each scheme provides a different balance between
the key goals: reliability, availability, performance, and
capacity. RAID levels greater than RAID 0 provide
protection against unrecoverable (sector) read errors, as
well as a whole disk failure.
• Many RAID levels employ an error protection
scheme called 'parity', a widely used method in
information technology to provide fault
tolerance in a given set of data.
• Fault tolerance is the property that enables a
system to continue operating properly in the
event of the failure of (or one or more faults
within) some of its components. So if either
one of the drives in such a unit fails, the other
continues to function as a single drive until the
failed drive is replaced.

You might also like