Module 3 Coa
Module 3 Coa
MODULE-3
MEMORY ORGANIZATION
MEMORY HIERARCHY
Page 1
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
Main Memory
The main memory is the central storage unit in a computer system. It is a relatively
large and fast memory used to store programs and data during the computer
operation. The principal technology used for the main memory is based on
semiconductor integrated circuits. Integrated circuit RAM chips are available in
two possible operating modes, static and dynamic. The static RAM consists
essentially of internal flip-flops that store the binary information. The stored
information remains valid as long as power is applied to the unit. The dynamic
RAM stores the binary information in the form of electric charges that are applied
to capacitors. The dynamic RAM offers reduced power consumption and larger
storage capacity in a single memory chip. The static RAM is easier to use and has
shorter read and write cycles. Most of the main memory in a general-purpose
computer is made up of RAM integrated circuit chips, but a portion of the memory
may be constructed with ROM chips. Originally, RAM was used to refer to a
Page 2
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
The ROM portion of main memory is needed for storing an initial program called a
bootstrap loader. The bootstrap loader is a program whose function is to start the
computer software operating when power is turned on. Since RAM is volatile, its
contents are destroyed when power is turned off. The contents of ROM remain
unchanged after power is turned off and on again. The startup of a computer
consists of turning the power on and starting the execution of an initial program.
Page 3
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
A RAM chip is better suited for communication with the CPU if it has one or
more control inputs that select the chip only when needed. Another common
feature is a bidirectional data bus that allows the transfer of data either from
memory to CPU during a read operation or from CPU to memory during a write
operation. A bidirectional bus can be constructed with three-state buffers. A three-
state buffer output can be placed in one of three possible states: a signal equivalent
to logic 1, a signal equivalent to logic 0, or a highimpedance state. The logic 1 and
0 are normal digital signals. The highimpedance state behaves like an open circuit,
which means that the output does not carry a signal and has no logic significance.
The capacity of the memory is 128 words of eight bits (one byte) per word. This
requires a 7-bit address and an 8-bit bidirectional data bus. The read and write
inputs specifies the memory operation and the two chips select (CS) control inputs
are for enabling the chip only when it is selected by the microprocessor. The
availability of more than one control input to select the chip facilitates the
decoding the address lines when multiple chips are used in the microcomputer. The
read and write inputs are sometimes combined into one line labeled R/W. When
the chip is selected, the two binary states in this line specify the two operations of
read or write.
Page 4
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
Page 5
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
Auxiliary Memory
The most common auxiliary memory devices used in computer systems are
magnetic disks and tapes. Other components used, but not as frequently, are
magnetic drums, magnetic bubble memory, and optical disks. The important
characteristics of any device are its access mode, access time, transfer rate,
capacity, and cost. The average time required to reach a storage location in
memory and obtain its contents is called the access time. In electromechanical
devices with moving parts such as disks and tapes, the access time consists of a
seek time required to position the read-write head to a location and a transfer
time required to transfer data to or from the device. Because the seek time is
usually much longer than the transfer time, auxiliary storage is organized in
records or blocks. A record is a specified number of characters or words. Reading
or writing is always done on entire records. The transfer rate is the number of
characters or words that the device can transfer per second, after it has been
positioned at the beginning of the record. Bits are recorded as magnetic spots on
the surface as it passes a stationary mechanism called a write head. Stored bits are
Page 6
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
Magnetic Disks
A disk system is addressed by address bits that specify the disk number, the disk
surface, the sector number and the track within the sector. After the read/write
heads are positioned in the specified track, the system has to wait until the rotating
disk reaches the specified sector under the read/write head. Information transfer is
Page 7
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
very fast once the beginning of a sector has been reached. Disks may have multiple
heads and simultaneous transfer of bits from several tracks at the same time.
Disks that are permanently attached to the unit assembly and cannot be removed by
the occasional user are called hard disks. A disk drive with removable disks is
called a floppy disk. The disks used with a floppy disk drive are small removable
disks made of plastic coated with magnetic recording material. Floppy disks are
extensively used in personal computers as a medium for distributing software to
computer users.
Magnetic Tape
Cache Memory
Analysis of a large number of typical programs has shown that the references to
memory at any given interval of time tend to be confined within a few localized
areas in memory. This phenomenon is known as the property of locality of
reference. If the active portions of the program and data are placed in a fast small
memory, the average memory access time can be reduced, thus reducing the total
Page 8
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
execution time of the program. Such a fast small memory is referred to as a cache
memory. It is placed between the CPU and main memory. The cache memory
access time is less than the access time of main memory by a factor of 5 to 10. The
cache is the fastest component in the memory hierarchy and approaches the speed
of CPU components. The fundamental idea of cache organization is that by
keeping the most frequently accessed instructions and data in the fast cache
memory, the average memory access time will approach the access time of the
cache. Although the cache is only a small fraction of the size of main memory, a
large fraction of memory requests will be found in the fast cache memory because
of the locality of reference property of programs. When the CPU needs to access
memory, the cache is examined. If the word is found in the cache, it is read from
the fast memory. If the word addressed by the CPU is not found in the cache, the
main memory is accessed to read the word. A block of words containing the one
just accessed is then transferred from main memory to cache memory. The block
size may vary from one word (the one just accessed) to about 16 words adjacent to
the one just accessed. In this manner, some data are transferred to cache so that
future references to memory find the required words in the fast cache memory. The
performance of cache memory is frequently 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 and it counts
as a miss. The ratio of the number of hits divided by the total CPU references to
memory (hits plus misses) is the hit ratio.
Page 9
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
The basic characteristic of cache memory is its fast access time. Therefore, very
little or no time must be wasted when searching for words in the cache. The
transformation of data from main memory to cache memory is referred to as a
mapping process. Organization of cache memory can classified into three type of
mapping process
1. Associative mapping
2. Direct mapping
3. Set-associative mapping
1. Associative Mapping
The fastest and most flexible cache organization uses an associative memory. The
associative memory stores both the address and content (data) of the memory
word. This permits any location in cache to store any word from main memory. A
CPU address of 15 bits is placed in the argument register and the associative
memory is searched for a matching address. If the address is found, the
corresponding 12-bit data is read and sent to the CPU. If no match occurs, the main
memory is accessed for the word. The address--data pair is then transferred to the
associative cache memory. If the cache is full, an address--data pair must be
displaced to make room for a pair that is needed and not presently in the cache.
2. Direct Mapping
Page 10
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
In the general case, there are 2k words in cache memory and 2" words in main
memory. The n-bit memory address is divided into two fields: k bits for the index
field and n - k bits for the tag field. The direct mapping cache organization uses the
n-bit address to access the main memory and the k-bit index to access the cache.
Each word in cache consists of the data word and its associated tag. When a new
word is first brought into the cache, the tag bits are stored alongside the data bits.
When the CPU generates a memory request, the index field is used for the address
to access the cache. The tag field of the CPU address is compared with the tag in
the word read from the cache. If the two tags match, there is a hit and the desired
data word is in cache. If there is no match, there is a miss and the required word is
read from main memory.
3. Set-Associative Mapping
Page 11
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
Cache Initialization
One more aspect of cache organization that must be taken into consideration is the
problem of initialization. The cache is initialized when power is applied to the
computer or when the main memory is loaded with a complete set of programs
from auxiliary memory. After initialization the cache is considered to be empty,
but in effect it contains some nonvalid data. It is customary to include with each
word in cache a valid bit to indicate whether or not the word contains valid data.
The cache is initialized by clearing all the valid bits to 0. The valid bit of a
particular cache word is set to 1 the first time this word is loaded from main
memory and stays set unless the cache has to be initialized again.
Page 12
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
Virtual Memory
Virtual memory is a concept used in some large computer systems that permit the
user to construct programs as though a large Memory space were available, equal
to the totality of auxiliary memory. Each address that is referenced by the CPU
goes through an address mapping from the so-called virtual address to a physical
address in main memory. Virtual memory is used to give programmers the illusion
that they have a very large memory at their disposal, even though the computer
actually has a relatively small main memory. A virtual memory system provides a
mechanism for translating program-generated addresses into correct main memory
locations. This is done dynamically, while programs are being executed in the
CPU. The translation or mapping is handled automatically by the hardware by
means of a mapping table.
An address used by a programmer will be called a virtual address, and the set of
such addresses the address space. An address in main memory is called a location
or physical address. The set of such locations is called the memory space. Thus
the address space is the set of addresses generated by programs as they reference
instructions and data the memory space consists of the actual main memory
locations directly addressable for processing. In most computers the address and
memory spaces are identical. The address space is allowed to be larger than the
memory space in computers with virtual memory. In a virtual memory system,
programmers are told that they have the total address space at their disposal.
Moreover, the address field of the instruction code has a sufficient number of bits
to specify all virtual addresses.
Page 13
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
Page Replacement
(1) Which page in main memory ought to be removed to make room for a new
page
(2) When a new page is to be transferred from auxiliary memory to main memory
Page 14
ST.ANTONYS COLLEGE PERUVANTHANAM DEPT.OF COMPUTERSCIENCE COA[SEM II}
The hardware mapping mechanism and the memory management software together
constitute the architecture of a virtual memory. When a program starts execution,
one or more pages are transferred into main memory and the page table is set to
indicate their position. The program is executed from main memory until it
attempts to reference a page that is still in auxiliary memory. This condition is
called page fault. When a page fault occurs in a virtual memory system, it signifies
that the page referenced by the CPU is not in main memory. A new page is then
transferred from auxiliary memory to main memory. If main memory is full, it
would be necessary to remove a page from a memory block to make room for the
new page. The policy for choosing pages to remove is determined from the
replacement algorithm that is used. Two of the most common replacement
algorithms used are the first-in, first-out (FIFO) and the least recently used (LRU).
Page 15