Chapter 7 Memory Organization
Chapter 7 Memory Organization
Memory Organization
Characteristic of Memory
• Memory is unit used for storage, and retrieval of data and instructions.
• A typical computer system is equipped with a hierarchy of memory subsystems, some
internal to the system and some external.
• Internal memory systems are accessible by the CPU directly and external memory
systems are accessible by the CPU through an I/O module.
• Memory systems are classified according to their key characteristics, as stated below:
1. Location:
• Registers: The CPU requires its own local memory in the form of registers and
also control unit requires local memories which are fast accessible.
• Internal (main): is often equated with the main memory (RAM).
• External (secondary): consists of peripheral storage devices like Hard disks,
magnetic tapes, etc. 2
… Cont’d
2. Capacity
• It is measured in bytes.
• Since the capacity of memory in a typical memory is very large, the prefixes kilo
(K), mega (M), and giga(G).
• A kilobyte is 210 = 1024 bytes, a megabyte is 220 bytes, and a giga byte is 230 bytes.
3. Unit of Transfer: is equal to the number of data lines into and out of memory module.
• Word: For internal memory, unit of transfer is equal to the number of data lines into
and out of the memory module.
• Block: For external memory, data are often transferred in much larger units than a
word, and these are referred to as blocks.
4. Access Method
• Sequential: Tape units have sequential access. 3
… Cont’d
• For nonrandom-access memory, access time is the time it takes to position the read-write
mechanism at the desired location.
• Transfer rate: This is the rate at which data can be transferred into or out of a memory unit.
6. Physical Type
• Semiconductor: Main memory, cache. RAM, ROM.
• Magnetic: Magnetic disks (hard disks), magnetic tape units.
• Optical: CD, DVD.
7. Physical Characteristics
• Volatile/nonvolatile: In a volatile memory, information decays naturally or is lost when
electrical power is switched off. RAM is erasable.
• Erasable/nonerasable: Nonerasable memory cannot be altered (except by destroying the
storage unit). ROM’s are nonerasable.
5
Memory Hierarchy
6
Figure 7.1: Memory Hierarchy
• The CPU initiates a memory operation by loading the appropriate data into registers
MDR and MAR, and setting either Read or Write memory control line to 1.
• When the required operation is completed the memory control circuitry sends Memory
Function Completed (MFC) signal to CPU. 12
… Cont’d
• The time that elapses between the initiation of an operation and completion of
that operation is called memory access time.
• The minimum time delay between two successive memory operations is
called memory cycle time.
• The cycle time is usually slightly lower than the access time.
13
Cache Memory
• Cache memory is a small, high-speed RAM buffer located between the CPU and main
memory.
• Cache memory holds a copy of the instructions (instruction cache) or data (operand or
data cache) currently being used by the CPU.
• The main purpose of a cache is to accelerate your computer while keeping the price of
the computer low.
Hit Ratio
• The ratio of the total number of hits divided by the total CPU accesses to memory (i.e. hits
plus misses) is called Hit Ratio.
• Hit Ratio = Total Number of Hits / (Total Number of Hits + Total Number of
Miss)
• Example: A system with 512 x 12 cache and 32 K x 12 of main memory.
• Replacement algorithms are used when there is no available space in a cache in which
to place a data.
• Four cache replacement algorithms are:
1. Least Recently Used (LRU): selects for replacement the item that has been least
recently used by the CPU.
2. First-In-First-Out (FIFO): selects for replacement the item that has been in the cache
from the longest time.
3. Least Frequently Used (LFU): selects for replacement the item that has been least
frequently used by the CPU.
4. Random: selects for replacement the item randomly.
22
… Cont’d
• The I/O devices communicating through DMA receive the most recent data.
2. Write-Back: only the cache memory is updated during a write operation.
• The updated locations in the cache memory are marked by a flag so that later
on, when the word is removed from the cache, it is copied into the main
memory.
• The words are removed from the cache time to time to make room for a new
block of words.
24
Virtual Memory
• Virtual Memory refers to something which appears to be present but actually it is not.
• The virtual memory technique allows users to use more memory for a program than the
real memory of a computer.
• So, virtual memory is the concept that gives the illusion to the user that they will have
main memory equal to the capacity of secondary storage media.
• The program is stored in the secondary memory.
• The memory management unit (MMU) transfers the currently needed part of the
program from the secondary memory to the main memory for execution.
• This to and from movement of instructions and data between the main memory and the
secondary memory is called Swapping.
25
Address Space and Memory Space
• Virtual address is the address used by the programmer and the set of such addresses is called
the address space or virtual memory.
• An address in main memory is called a location or physical address.
• The set of such locations in main memory is called the memory space or physical memory.
• CPU generated logical address consisting of a logical page number plus the location within
that page (x).
• It must be mapped onto an actual (physical) main memory address by the operating system
using mapper.
• If the page is present in the main memory, CPU gets the required data from the main memory.
• If the mapper detects that the requested page is not present in main memory, a page fault
occurs and the page must be read from secondary storage (4, 5) into a page frame in main
26
memory.
… Cont’d
28
Page Replacement Algorithms
29
… Cont’d
1. FIFO Algorithm
• Consider a paging system having capacity of 3 pages.
• The execution of a program requires references to five distinct pages P1, P2, P3,
P4 and P5.
• The pages are executed in the following sequence:
P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2
• Page hit = 3
• Page fault = 9
• Total number of reference page (Page hit + Page fault ) = 12
• Hit ratio = (Page hit / Page hit + Page fault ) *100
= (3/12) * 100
= 25%
• Page Fault ratio = (Page fault / Page hit + Page fault ) *100
= (9/12) * 100
= 75%
31
… Cont’d
• Page hit = 5
• Page fault = 7
• Total number of reference page (Page hit + Page fault ) = 12
• Hit ratio = (Page hit / Page hit + Page fault ) *100
= (5/12) * 100
= 41.67%
• Page Fault ratio = (Page fault / Page hit + Page fault ) *100
= (7/12) * 100
= 58.33%
34
… Cont’d
2. Optimal (OPT)
• The optimal policy selects that page for replacement for which the time to the next
reference is longest.
• results in fewest number of page faults.
• But, this algorithm is impossible to implement.
• At the time of page fault, the operating system has no way of knowing when each
of the pages will be referenced next.
• However, it does serve as a standard against which to judge other algorithms.
• Consider a paging system having capacity of 3 pages.
• The execution of a program requires references to five distinct pages P1, P2, P3,
P4 and P5.
35
… Cont’d
36
… Cont’d
• Page hit = 6
• Page fault = 6
• Total number of reference page (Page hit + Page fault ) = 12
• Hit ratio = (Page hit / Page hit + Page fault ) *100
= (6/12) * 100
= 50%
• Page Fault ratio = (Page fault / Page hit + Page fault ) *100
= (6/12) * 100
= 50%
37
External Memory
• More suitable than magnetic tapes for a wider range of applications because they
support direct access of data.
• Due to their low cost and high data recording densities, the cost per it of storage is low
for magnetic disks.
Benefit of magnetic disks
• Can be erased and reused many times.
• Suitable for both on-line and off-line storage of data.
• Floppy disks are compact and light in weight.
• Hence they are easy to handle and store.
• Very large amount of data can be stored in a small storage space.
• Data transfer rate for a magnetic disk system is normally higher than a tape
system. 40
… Cont’d
1. Floppy Disk
• Also known as floppies or diskettes.
• It was introduced by IBM in 1972.
• It is a portable, inexpensive, storage medium that consists of thin,
circular, flexible plastic Mylar film.
• Standard floppy disk has storage capacity up to 1.44MB.
• Floppy disks are compact, lightweight and easily portable from one place
to another.
• Most popular and inexpensive secondary storage medium used in small
computers. 41
… Cont’d
2. Hard Disk
• Round, flat piece of rigid metal (frequently aluminum) disks coated with magnetic
oxide.
• It is a storage device that contains one or more inflexible, circular patterns that
store data, instructions & information.
• We can store documents, presentation, database, e-mails, messages, music, video,
software etc.
• Come in many sizes, ranging from 1 to 14-inch diameter.
• Hard disk of capacities 10GB, 20GB, 40GB, 500GB, 1TB and even more are
easily available.
42
RAID(Redundant Array of Independent Disks) Technology
• RAID is a set of physical disk drives viewed by the operating system as a single logical
drive.
• Data are distributed across the physical drives of an array.
• Redundant disk capacity is used to store parity information which guarantees data
recoverability in case of a disk failure.
43
Optical Disks
• Consists of a circular disk, which is coated with a thin metal or some other material that is
highly reflective.
• Laser beam technology for recording and reading of data on the disk.
• Also known as laser disk / optical laser disk, due to the use of laser beam technology.
• Proved to be a promising random access medium for high capacity secondary storage because
it can store extremely large amounts of data in a limited space.
• Access times are typically in the range of 100 to 300 milliseconds and that of hard disks are in
the range of 10 to 30 milliseconds.
• The most popular optical disk uses a disk of 5.25-inch diameter with storage capacity of
around 650 Megabytes.
• The optical disk became the preferred medium for music, movies and software programs
44
because of its many advantages.
… Cont’d
• Compact, lightweight, durable and digital, the optical disk also provides a
minimum of 650 MB of data storage.
Types of Optical Disks
1. CD: Compact Disk.
• A non-erasable disk that stores digitized audio information.
• The standard system uses 12-cm disks and can record more than 60
minutes of uninterrupted playing time.
i. CD-ROM: Compact Disk-Read Only Memory
• A non-erasable disk used for storing computer data.
• The standard system uses 12-cm disks and can hold more than 650
45
Megabytes.
… Cont’d
Due to their compact size and light weight, optical disks are easy to
handle, store, and port from one place to another.
Music CDs can be played on a computer having a CD-ROM drive
along with a sound board and speakers.
• This allows computer systems to be also used as music systems.
As data once stored on an optical disk becomes permanent, danger of
stored data getting inadvertently erased/overwritten is removed.
49
… Cont’d
50
Magnetic Tape
• Magnetic Tape is a plastic ribbon which is usually ½ inch or ¼ inch wide & 50 to 2400 feet
long.
It is coated with iron-oxide material.
It is similar to the tape of audio cassettes of tape recorders.
Data is stored as binary digits.
Data is accessed sequentially so searching becomes difficult.
Advantages
• Store data up to few gigabytes and Low cost.
• Magnetic tape used by both mainframes and microcomputers
Disadvantages:
• Sequential access so searching becomes difficult.
51
• We can either read or write data at one time.