CO - Unit 4
CO - Unit 4
Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Unit 4
The Memory Organization
Basic Concepts
Memory organization is an important aspect of computer architecture. It refers to the way that
the computer’s memory is arranged and managed.
The memory of system can be thought of as a large number of addressable storage locations.
Each location can store a fixed amount of data, typically measured in bits or bytes.
The way these locations are organized and accessed can have a notable impact on the overall
production and functionality of the system.
Memory organization is also important for the efficient management of data and instructions
within a computer system.
It involves techniques such as memory allocation, virtual memory management, and cache
management. These techniques help to optimize the use of memory and improve system
performance.
Types: There are several types of memory organization used in computer systems, each with its own
advantages and disadvantages.
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:
1. 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.
2. Sequential Access: This method allows memory access in a sequence or in order.
3. Direct Access: In this mode, information is stored in tracks, with each track having a separate
read/write head.
Main Memory
Page 1
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
The memory unit that communicates directly within the CPU 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.
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.
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 accommodate the new one.
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)
Register: Register memory is the smallest and fastest memory in a computer. It is not a part of the
main memory and is located in the CPU in the form of registers, which are the smallest data holding
elements. A register temporarily holds frequently used data, instructions, and memory address that
are to be used by CPU.
Page 2
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Random Access Memory(RAM)
Read-Only Memory(ROM)
RAM
Random Access Memory is a form of semiconductor memory technology that is applied for
reading and writing data in any order and any number of times.
In RAM the memory location is arranged in such a way that any memory location requires
equal time for reading and writing.
RAM is volatile (Volatile memories are those memories that store the data tentatively. Data
saved in volatile memory remains only till the power supply is ON. Once the supply gets OFF
the stored data would get lost).
RAM are lightning-fast access in a flash and can be easily programmed, erased and
reprogrammed by the user.
Page 3
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Types of RAM
1) SRAM (Static Random Access Memory)
2) DRAM (Dynamic Random Access Memory)
SRAM:
The word static implies that the memory holds its contents as long as the electricity is being
supplied and the data is dumped when the power gets down because of its volatile nature.
It possesses an array of flip-flops that are used to save the data.
SRAM’s are more expensive, consume more power and have higher speeds than D-RAMs
Page 4
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
DRAM
DRAM stores the data in the form of charges in the capacitor and transistor pair available in
the memory cell.
DRAM is implemented using Metal Oxide Semiconductor Field Effect Transistor
(MOSFETs).
DRAM needs to be regularly refreshed so that the data should be maintained. This is achieved
by installing the memory on a refresh circuit that rewrites the content several hundred times
every second.
Cheap, smaller and operates at a slower rate
Page 5
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Synchronous DRAM (SDRAM)
SDRAM is a type of DRAM and works in sync with the CPU clock, which implies it waits
for the clock signal before acknowledging the data input.
Mostly applied in Computer memory, video game consoles, etc.
Flash Memory
Flash memory is a sort of non-volatile storage that holds all data after power off also.
popularly used in digital cameras, smartphones and tablets, hand-operated gaming systems
and toys.
ROM
ROM, which stands for read only memory, is a memory device or storage medium that stores
information permanently.
It is called read only memory as we can only read the programs and data stored on it but
cannot write on it.
The manufacturer of ROM fills the programs into the ROM at the time of manufacturing the
ROM. After this, the content of the ROM can't be altered, which means you can't reprogram,
rewrite, or erase its content later. However, there are some types of ROM where you can
modify the data.
ROM contains special internal electronic fuses that can be programmed for a specific
interconnection pattern (information).
The binary information stored in the chip is specified by the designer and then embedded in
the unit at the time of manufacturing to form the required interconnection pattern
(information).
Page 6
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Once the pattern (information) is established, it stays within the unit even when the power is
turned off. So, it is a non-volatile memory as it holds the information even when the power is
turned off, or you shut down your computer.
The block of ROM has 'n' input lines and 'm' output lines. Each bit combination of the input
variables is known as an address. Each bit combination that comes out through output lines is
called a word. The number of bits per word is equal to the number of output lines, m.
The internal structure comprises two basic components: decoder and OR gates. A decoder is a
circuit that decodes an encoded form (such as binary coded decimal, BCD) to a decimal form.
So, the input is in binary form, and the output is its decimal equivalent. All the OR gates
present in the ROM will have outputs of the decoder as their output. Let us take an example
of 64 x 4 ROM. The structure is shown in the following image
Page 7
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Types of ROM
Masked Read Only Memory (MROM):
It is the oldest type of read only memory (ROM) made of integrated circuits. It has become
obsolete so it is not used anywhere in today's world.
It is a hardware memory device in which programs and instructions are stored at the time of
manufacturing by the manufacturer and can't be modified, reprogrammed, or erased later.
Chips send a current through a particular input-output pathway determined by the location of
fuses among the rows and columns on the chip.
The current has to pass along a fuse-enabled path, so it can return only via the output the
manufacturer chooses. This is the reason the rewriting and any other modification is not
impossible in this memory.
Page 8
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
EPROM is a type of ROM that can be reprogramed and erased many times. The method to
erase the data is very different; it comes with a quartz window through which a specific
frequency of ultraviolet light is passed for around 40 minutes to erase the data.
So, it retains its content until it is exposed to the ultraviolet light. You need a special device
called a PROM programmer or PROM burner to reprogram the EPROM.
It is used in some micro-controllers to store program, e.g., some versions of Intel 8048 and
the Freescale 68HC11.
FLASH ROM:
It is an advanced version of EEPROM. It stores information in an arrangement or array of
memory cells made from floating-gate transistors. The advantage of using this memory is that
you can delete or write blocks of data around 512 bytes at a particular time. Whereas, in
EEPROM, you can delete or write only 1 byte of data at a time. So, this memory is faster than
EEPROM.
It can be reprogrammed without removing it from the computer. Its access time is very high,
around 45 to 90 nanoseconds. It is also highly durable as it can bear high temperature and
intense pressure.
Uses: It is used for storage and transferring data between a personal computer and digital
devices. It is used in USB flash drives, MP3 players, digital cameras, modems and solid-state
drives (SSDs). The BIOS of many modern computers are stored on a flash memory chip,
called flash BIOS.
Advantages of ROM
1. Data Retention
2. Permanent Storage
3. Reliable Performance
4. Non-Volatile Memory
5. Stability
6. Data Security
7. Instant Accessibility
8. Simple Design and Manufacturing
9. Cost-Effectiveness
10. Compatibility
Disadvantages of ROM
1. Immutability
2. Limited Flexibility
3. Manufacturing Challenges
Page 9
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
4. Design Constraints
5. Time-Consuming Development
6. Higher Costs for Small-Scale Production
7. Lack of Upgradability
8. Storage Inefficiency
9. Limited Error Correction
10. Reduced Versatility
Level-0 – Registers
Registers are tiny unit of memory which stores 1 bit of memory, data stored in registers can
be accessed very fast and data stored in registers are temporary.
Speed: Fastest memory in the system (nanoseconds or less).
Size: Very small, typically in the order of a few bytes (a handful of registers, e.g., 16–64
registers).
Cost: Most expensive per bit due to their integration within the CPU.
Use: Temporary storage for immediate processing data within the CPU.
Implementation: implemented by using Flip-Flops.
Level-1 – Cache
Page 10
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Page 11
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Page 12
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Need for replacement algorithm
Page 13
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
3) Set-Associative Mapping
Page 14
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Replacement Algorithm
Page 15
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Level-3 – Secondary memory
A larger storage capacity and from which data and programs are not lost when the computer
is turned off. Such a type of memory is called secondary memory.
It is also called auxiliary memory and not directly accessible through the CPU and it is non-
volatile.
Uses
1) Permanent storage
2) Large Storage
3) Portable
Types
1) Fixed:
Internal flash memory (rare)
SSD (solid-state disk)
Hard disk drives (HDD)
2) Removable
Optical discs (like CDs, DVDs, Blu-ray discs, etc.)
Memory cards
Floppy disks
Magnetic tapes
Disk packs
Paper storage (like punched tapes, punched cards, etc.)
Performance Considerations
A key design objective of a computer system is to achieve the best possible performance at
the lowest possible cost.
Performance of a processor depends on:
How fast machine instructions can be brought into the processor for execution.
How fast the instructions can be executed.
Interleaving
Divides the memory system into a number of memory modules. Each module has its own
address buffer register (ABR) and data buffer register (DBR).
Page 16
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Arranges addressing so that successive words in the address space are placed in different
modules.
When requests for memory access involve consecutive addresses, the access will be to
different modules.
Since parallel access to these modules is possible, the average rate of fetching words from the
main memory can be increased.
Example Problem
Page 17
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Page 18
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Virtual Memories
Virtual memory was developed in approximately 1959 – 1962, at the University of
Manchester for the Atlas Computer, completed in 1962. In 1961, Burroughs released the
B5000, the first commercial computer with virtual memory.
In the most of the computer system, the physical main memory is not as large as address
space of the processor.
Suppose user tries to run a program. If the program run by the user does not completely fit
into the main memory then the parts of its currently being executed are stored in main
memory and remaining portion is stored in secondary storage device such as HDD.
When a new part of program is to be brought into main memory for execution and if the
memory is full, it must replace another part which is already is in main memory.
As this secondary memory is not actually part of system memory, so for CPU, secondary
memory is considered as Virtual Memory.
Page 19
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Virtual memory is a memory management technique that is implemented using both hardware
and software. It maps memory addresses used by a program, called virtual addresses, into
physical addresses in computer memory.
Page 20
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Page 21
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Page 22
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Hence, we may need to relocate the processes to a different section of the memory. This
relocation can occur when a program is moved to the main memory due to swapping.
The above figure illustrates a process image occupying a contiguous region in the main
memory. The operating system needs to know various things like the location of process
control information, code entry, and execution stack. Within a program, there are multiple
memory references in different instructions, referred to as logical addresses.
Once the program is loaded into the main memory, both the operating system and the
processor must be able to translate these logical addresses into physical addresses.
Branch instructions contain the address of the next instruction to be executed, while data
reference instructions contain the addresses of the referenced data word or byte.
2) Protection
Running multiple programs simultaneously poses a risk: one program might overwrite the
memory space of another. Therefore, every process must be protected against unwanted
interferences from other processes.
It's a balancing act between relocation and protection requirements - meeting the needs of
relocation can make it harder to satisfy the protection requirement.
Since it's impossible to predict a program's location in the main memory, we can't verify the
absolute address at compile time for protection. Most programming languages allow dynamic
calculation of addresses at runtime.
Therefore, the processor, not the operating system, must satisfy the memory protection
requirement, as the OS has limited control over a process when it's using the processor. This
means that the validity of a memory reference can be checked.
3) Sharing
Some protection mechanisms allow different processes to access the same section of main memory.
This means multiple processes can access the same copy of a program, rather than each having their
own separate copy, which can be more efficient.
For example, multiple processes might need to use the same system file. It makes sense to load a
single copy of this file into the main memory and allow these processes to share it. It's up to memory
management to allow for this kind of shared memory access in a controlled manner, without
sacrificing protection.
4) Logical organization
The main memory can be organized as a linear or one-dimensional address space, consisting of a
sequence of words or bytes. Most programs can be broken down into modules, some of which are
unmodifiable (execute-only, read-only) and some contain modifiable data. To effectively manage
user programs, both the operating system and computer hardware need to support a basic module.
This provides the necessary sharing and protection and has several advantages:
Page 23
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
o Modules can be independently written and compiled. Any references from one module
to another are resolved by the system at runtime.
o Different levels of protection can be provided for different modules.
o Various mechanisms allow modules to be shared among different processes. Sharing
can be done at the module level, allowing the user to specify the desired level of
sharing.
5) Physical organization
The structure of a computer's memory consists of two levels, referred to as the main memory and
secondary memory. The main memory is faster but more expensive than secondary memory and is
volatile. Therefore, secondary memory is typically used for long-term data storage, while the main
memory holds the programs currently in use. The primary concern between the secondary memory
and the main memory is the flow of information. It is not practical for a programmer to manage this
for two reasons:
o If the main memory available for a program and its data is insufficient, a programmer
may resort to overlaying. This allows different modules to be assigned to the same
memory region. The main downside of this is that it can be time-consuming for the
programmer.
o In a multiprogramming environment, a programmer doesn't know how much space
will be available at coding time or where that space is in the memory.
Secondary Storage
Primary memory has two main limitations: Limited storage capacity and volatility. To
overcome these limitations almost all computers use additional memory called secondary or
auxiliary memory. Secondary memory is permanent, cheap and provides high storage
capacity.
There are two methods of accessing information from secondary storage devices: direct
access and sequential access.
In sequential access the desired information is accessed by searching the data in the
sequential manner starting from the first record until the desired record is found, thus
the access time here depends upon the distance of the desired information from the
beginning.
In direct access method the information is directly fetched from its storage location. In
this case search time is independent from the location of the data storage.
Page 24
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
1. Magnetic disks: A magnetic disk is a storage device that uses a magnetization process to write,
rewrite and access data. 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.
i. Floppy Disk: A floppy disk is a flexible disk with a magnetic coating on it, and it is packaged
inside a protective plastic envelope. These are among the oldest portable storage devices that
could store up to 1.44 MB of data, but now they are not used due to very little memory
storage.
ii. Hard Disk Drive (HDD): Hard disk drive comprises a series of circular disks
called platters arranged one over the other almost ½ inches apart around a spindle. Disks are
made of non-magnetic material like aluminium alloy and coated with 10-20 nm magnetic
material. The standard diameter of these disks is 14 inches, and they rotate with speeds
varying from 4200 rpm (rotations per minute) for personal computers to 15000 rpm for
servers.
Data is stored by magnetizing or demagnetizing the magnetic coating. A magnetic reader arm
is used to read data from and write data to the disks. A typical modern HDD has a capacity in
terabytes (TB).
2. Optical Disk: An optical disk is any computer disk that uses optical storage techniques and
technology to read and write data. It is a computer storage disk that stores data digitally and uses
laser beams to read and write data.
i. CD Drive: CD stands for Compact Disk. CDs are circular disks that use optical rays, usually
lasers, to read and write data. They are very cheap as you can get 700 MB of storage space for
less than a dollar. CDs are inserted in CD drives built into the CPU cabinet. They are portable
as you can eject the drive, remove the CD and carry it with you. There are three types of CDs:
o CD-ROM (Compact Disk - Read Only Memory): The manufacturer recorded the
data on these CDs. Proprietary Software, audio or video are released on CD-ROMs.
o CD-R (Compact Disk - Recordable): The user can write data once on the CD-R. It
cannot be deleted or modified later.
o CD-RW (Compact Disk - Rewritable): Data can repeatedly be written and deleted
on these optical disks.
ii. DVD Drive: DVD stands for digital video display. DVD is an optical device that can store 15
times the data held by CDs. They are usually used to store rich multimedia files that need
high storage capacity. DVDs also come in three varieties - read-only, recordable and
rewritable.
iii. Blu Ray Disk: Blu Ray Disk (BD) is an optical storage media that stores high definition
(HD) video and other multimedia files. BD uses a shorter wavelength laser than CD/DVD,
enabling the writing arm to focus more tightly on the disk and pack in more data. BDs can
store up to 128 GB of data
3. Memory Storage Devices: A memory device contains trillions of interconnected memory cells
that store data. When switched on or off, these cells hold millions of transistors representing 1s and
0s in binary code, allowing a computer to read and write information. It includes USB drives, flash
memory devices, SD and memory cards, which you'll recognize as the storage medium used in digital
cameras.
i. Flash Drive: A flash drive is a small, ultra-portable storage device. USB flash drives were
essential for easily moving files from one device to another. Flash drives connect to
computers and other devices via a built-in USB Type-Aor USB-C plug, making one a USB
device and cable combination.
Flash drives are often referred to as pen drives, thumb drives, or jump drives. The terms USB
Page 25
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
drive and solid-state drive (SSD) are also sometimes used, but most of the time, those refer to
larger, not-so-mobile USB-based storage devices like external hard drives.
These days, a USB flash drive can hold up to 2 TB of storage. They're more expensive per
gigabyte than an external hard drive, but they have prevailed as a simple, convenient solution
for storing and transferring smaller files.
Pen drive has the following advantages in computer organization, such as:
o Transfer Files: A pen drive is a device plugged into a USB port of the system that is
used to transfer files, documents, and photos to a PC and vice versa.
o Portability: The lightweight nature and smaller size of a pen drive make it possible to
carry it from place to place, making data transportation an easier task.
o Backup Storage: Most of the pen drives now come with the feature of having
password encryption, important information related to family, medical records, and
photos can be stored on them as a backup.
o Transport Data: Professionals or Students can now easily transport large data files
and video, audio lectures on a pen drive and access them from anywhere. Independent
PC technicians can store work-related utility tools, various programs, and files on a
high-speed 64 GB pen drive and move from one site to another.
ii. Memory card: A memory card or memory cartridge is an electronic data storage device used
for storing digital information, typically using flash memory. These are commonly used in
portable electronic devices, such as digital cameras, mobile phones, laptop computers, tablets,
PDAs, portable media players, video game consoles, synthesizers, electronic keyboards and
digital pianos, and allow adding memory to such devices without compromising ergonomy, as
the card is usually contained within the device rather than protruding like USB flash drives.
Page 26