Unit 5
I/O systems and memory
A peripheral device is any external device connected to a
computer that adds functionality but is not part of the core
computer system. These devices typically handle input,
output, or both, and are also known as input-output (I/O)
devices. While not essential for a computer to perform its
basic operations, peripherals enhance the user's experience
by expanding the system’s capabilities. Common examples
include keyboards, mice, printers, and external drives.
Although the term is sometimes used loosely, it generally
refers to devices located outside the computer case.
Classification of Peripheral Devices
It is generally classified into four basic categories which are
given below:
1. Input Devices:
An input device is defined as a device that converts incoming
data and instructions into a pattern of electrical signals in
binary code that are comprehensible to a digital computer.
Keyboard: A keyboard is an input device that allows users
to enter text and commands into a computer system.
Mouse: A mouse is an input device that allows users to
control the cursor on a computer screen.
Scanner: A scanner is an input device that allows users to
convert physical documents and images into digital files.
Microphone: A microphone is an input device that allows
users to record audio.
2. Output Devices:
An output device is generally the reverse of the input process
and generally translates the digitized signals into a form
intelligible to the user. The output device is also performed for
sending data from one computer system to another. For some
time punched card and paper tape readers were extensively
used for input, but these have now been replaced by more
efficient devices. Example:
Monitor: It is an output device that displays visual
information from a computer system.
Printer: It is an output device that produces physical
copies of documents or images.
Speaker: It is an output device that produces audio.
3. Storage Devices:
Storage devices are used to store data in the system which is
required for performing any operation in the system. The
storage device is one of the most required devices and also
provides better compatibility. Example:
Hard Drive: A hard drive is a storage device that stores
data and files on a computer system.
USB Drive: A USB drive is a small, portable storage
device that connects to a computer system to provide
additional storage space.
Memory Card: A memory card is a small, portable storage
device that is commonly used in digital cameras and smart
phones.
External Hard Drive: An external hard drive is a storage
device that connects to a computer system to provide
additional storage space.
4. Communication Devices:
Communication devices are hardware devices that enables
data exchange between computer systems or networks.
These include:
Modem: A modem is a communication device that allows
a computer system to connect to the internet.
Network Card: A network card is a communication device
that allows a computer system to connect to a network.
Router: A router is a communication device that allows
multiple devices to connect to a network.
Peripheral Devices Connecting Options
Peripheral devices can connect to a computer through various
methods. Each offers different speeds, ranges, and
compatibility. Common connecting options include:
USB: USB is common for keyboards, mice, printers, and
external storage devices; supports both wired and wireless
connections.
Bluetooth: Bluetooth is wireless connection for devices
like headphones, speakers, and mice.
Wi-Fi: Wi-Fi is used for wireless networked devices like
printers and cameras.
HDMI: HDMI connects monitors, projectors, and TVs for
high-definition video and audio.
Ethernet: Wired connection for network communication,
often for internet or LAN access.
Thunderbolt: High-speed connection for external devices
like storage drives and monitors.
VGA: VGA is older connection for monitors or projectors,
supports lower video resolutions.
Display Port: Similar to HDMI, used for connecting high-
definition monitors.
Importance of Peripheral Devices
Peripheral devices are important for enhancing functionality of
a computer. Here's why peripheral devices are so important:
Enhanced Functionality: Peripheral devices expand a
computer's capabilities, enabling it to perform various
tasks.
User Interaction: Input devices like keyboards and mice
allow users to control and interact with the system.
Data Output: Output devices such as monitors and
printers display or present processed data.
Data Storage: Storage devices ensure important data is
saved and can be accessed or backed up when needed.
Communication: Communication devices enable network
connectivity, allowing the computer to communicate with
other systems or networks.
Increased Efficiency: Peripherals improve the overall
efficiency and usability of the computer by adding
specialized functions.
Input-Output Interface
It is used as a method which helps in transferring information
between the internal storage devices, i.e., memory, and the
external peripheral device. A peripheral device provides input
and output for the computer; it is also called an Input-Output
device.
For Example, A keyboard and mouse, which provide input to
the computer, are called input devices while a monitor and
printer provide output to the computer, are called output
devices.
Functions of Input-Output Interface:
1. It is used to synchronize the operating speed of CPU with
respect to input-output devices.
2. It selects the input-output device which is appropriate for
the interpretation of the input-output signal.
3. It is capable of providing signals like control and timing
signals.
4. In this data buffering can be possible through data bus.
5. There are various error detectors.
6. It converts serial data into parallel data and vice-versa.
7. It also convert digital data into analog signal and vice-
versa.
Data transfer schemes
The CPU executes the I/O instructions & accepts the data
temporarily but finally, the source/ destination will be any
memory unit. There are various modes in which data transfer
could take place between CPU & I/O devices. Data transfer to
& from peripherals can be handled in one of the 3 given
modes as follows.
1. Programmed I/O
2. Interrupt — Driven I/O
3. Direct Memory Access (DMA)
Let's discuss them one by one.
1. Programmed I/O:
In program-controlled I/O, the processor program controls
the complete data transfer. So only when an I/O transfer
instruction is executed, the transfer could take place. It is
required to check that device is ready/not for the data
transfer in most cases. Usually, the transfer is to & from a
CPU register & peripheral. Here, CPU constantly monitors
the peripheral. Here, until the I/O unit indicates that it is
ready for transfer, the CPU wait & stays in a loop. It is
time-consuming as it keeps the CPU busy needlessly.
2. Interrupt—Driven I/O:
To overcome the disadvantage of Programmed I/O ,i.e.,
keeping CPU busy needlessly, Interrupt — Driven I/O is
used. In this approach, when a peripheral sends an
interrupt signal to the CPU whenever it is ready to transfer
data. This indicates that the I/O data transfer is initiated by
the external I/O device. The processor stops the execution
of the current program & transfers the control to interrupt
the service routine when interrupted. The interrupt service
routine then performs the data transfer. After the
completion of data transfer, it returns control to the main
program to the point it was interrupted.
3. DMA — Direct Memory Access:
DMA transfer is used for large data transfers. Here, a
memory bus is used by the interface to transfer data in &
out of a memory unit. The CPU provides starting address &
number of bytes to be transferred to the interface to initiate
the transfer, after that it proceeds to execute other tasks.
DMA requests a memory cycle through the memory bus
when the transfer is made. DMA transfers the data directly
into the memory when the request is granted by the
memory controller. To allow direct memory transfer(I/O),
the CPU delays its memory access operation. So, DMA
allows I/O devices to directly access memory with less
intervention of the CPU.
Difference between I/O Program Controlled
Transfer & DMA Transfer
Here we will discuss the difference between I/O Program
Controlled Transfer v/s DMA Transfer:
I/O Program Controlled
[Link]. Transfer DMA Transfer
1. It is software control data transfer It is hardware control data transfer
2. Data transfer speed is slow Data transfer speed is fast.
CPU is involved in the complete CPU is not involved in the complete
3.
transfer. transfer.
DMA controller is required for data
4. Extra hardware is not required.
transfer.
Data is routed through the processor, Data is not routed through the
5.
during the data transfer. processor, during the data transfer.
6. Used for small data transfer. Used for large data transfer.
Memory Hierarchy
In the Computer System Design, Memory Hierarchy is an
enhancement to organize the memory such that it can
minimize the access time. The Memory Hierarchy was
developed based on a program behavior known as locality of
references (same data or nearby data is likely to be accessed
again and again). The figure below clearly demonstrates the
different levels of the memory hierarchy.
Types of Memory Hierarchy
This Memory Hierarchy Design is divided into 2 main types:
External Memory or Secondary Memory: Comprising of
Magnetic Disk, Optical Disk, and Magnetic Tape i.e.
peripheral storage devices which are accessible by the
processor via an I/O Module.
Internal Memory or Primary Memory: Comprising of
Main Memory, Cache Memory & CPU registers. This is
directly accessible by the processor.
Characteristics of Memory Hierarchy
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.
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.
Performance: The Memory Hierarch design ensures that
frequently accessed data is stored in faster memory to
improve system performance.
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.
System-Supported Memory Standards
According to the memory Hierarchy, the system-supported memory
standards are defined below:
Advantages of Memory Hierarchy
Performance: Frequently used data is stored in faster memory
(like cache), reducing access time and improving overall system
performance.
Cost Efficiency: By combining small, fast memory (like
registers and cache) with larger, slower memory (like RAM and
HDD), the system achieves a balance between cost and
performance. It saves the consumer's price and time.
Optimized Resource Utilization: Combines the benefits of
small, fast memory and large, cost-effective storage to
maximize system performance.
Efficient Data Management: Frequently accessed data is kept
closer to the CPU, while less frequently used data is stored in
larger, slower memory, ensuring efficient data handling.
Disadvantages of Memory Hierarchy
Complex Design: Managing and coordinating data across
different levels of the hierarchy adds complexity to the system's
design and operation.
Cost: Faster memory components like registers and cache are
expensive, limiting their size and increasing the overall cost of
the system.
Latency: Accessing data stored in slower memory (like
secondary or tertiary storage) increases the latency and reduces
system performance.
Maintenance Overhead: Managing and maintaining different
types of memory adds overhead in terms of hardware and
software.
Auxiliary Memory
An Auxiliary memory is referred to as the lowest-cost, highest-
space, and slowest-approach storage in a computer system. It is
where programs and information are preserved for long-term
storage or when not in direct use. The most typical auxiliary
memory devices used in computer systems are magnetic
disks and tapes.
Magnetic Disks
A magnetic disk is a round plate generated of metal or plastic
coated with magnetized material. There are both sides of the disk
are used and multiple disks can be stacked on one spindle with
read/write heads accessible on each surface.
All disks revolve together at high speed and are not stopped or
initiated for access purposes. Bits are saved in the magnetized
surface in marks along concentric circles known as tracks. The
tracks are frequently divided into areas known as sectors.
In this system, the lowest quantity of data that can be sent is a
sector. The subdivision of one disk surface into tracks and sectors
is displayed in the figure.
Magnetic Tape
Magnetic tape transport includes the robotic, mechanical, and
electronic components to support the methods and control
structure for a magnetic tape unit. The tape is a layer of plastic
coated with a magnetic documentation medium.
Bits are listed as a magnetic stain on the tape along various
tracks. There are seven or nine bits are recorded together to form
a character together with a parity bit. Read/write heads are
mounted one in each track therefore that information can be
recorded and read as a series of characters.
Magnetic tape units can be stopped, initiated to move forward, or
in the opposite, or it can be reversed. However, they cannot be
initiated or stopped fast enough between single characters. For
this reason, data is recorded in blocks defined as records. Gaps of
unrecorded tape are added between records where the tape can
be stopped.
The tape begins affecting while in a gap and achieves its
permanent speed by the time it arrives at the next record. Each
record on tape has a recognition bit design at the starting and
end. By reading the bit design at the starting, the tape control
recognizes the data number.
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 : An auto-associative
memory network, also known as a recurrent neural
network, is a type of associative memory that is used to
recall a pattern from partial or degraded inputs. In an auto-
associative network, the output of the network is fed back
into the input, allowing the network to learn and remember
the patterns it has been trained on. This type of memory
network is commonly used in applications such as speech
and image recognition, where the input data may be
incomplete or noisy.
2. hetero associative memory network : A hetero-associative
memory network is a type of associative memory that is
used to associate one set of patterns with another. In a
hetero-associative network, the input pattern is associated
with a different output pattern, allowing the network to learn
and remember the associations between the two sets of
patterns. This type of memory network is commonly used
in applications such as data compression and data
retrieval.
Argument Register: It contains words to be searched. It
contains 'n' number of bits.
Match Register: It has m-bits, One bit corresponding to
each word in the memory array. After the making process,
the bits corresponding to matching words in match register
are set to '1'.
Key Register: It provides a mask of choosing a particular
field/key in argument register. It specifies which parts of
the argument word need to be compared with words in
memory.
Associative Memory Array: It combines word in that are to
be compared with the arguments word in parallel. It
contains 'm' words with 'n' bit per word.
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
1. Each cell must have storage capability and logical circuits
for matching its content with external argument.
Interleaving
Memory Interleaving is an abstraction technique which
divides memory into a number of modules such that
successive words in the address space are placed in the
different module. Suppose a 64 MB memory made up of the
4 MB chips as shown in the below:
We organize the memory into 4 MB banks, each having
eight of the 4 MB chips. The memory thus has 16 banks,
each of 4 MB. 64 MB memory = 2^26, so 26 bits are used for
addressing. 16 = 2^4, so 4 bits of address select the bank,
and 4 MB = 2^22, so 22 bits of address to each chip. In
general, an N-bit address, with N = L + M, is broken into two
parts:
1. L-bit bank select, used to activate one of the 2^L banks of
memory, and
2. M-bit address that is sent to each of the memory banks.
When one of the memory banks is active, the other (2L - 1)
are inactive. All banks receive the M-bit address, but the
inactive one do not respond to it. Classification of Memory
Interleaving: Memory interleaving is classified into two
types:
1. High Order Interleaving - In high-order interleaving, the
most significant bits of the address select the memory chip.
The least significant bits are sent as addresses to each chip.
One problem is that consecutive addresses tend to be in the
same chip. The maximum rate of data transfer is limited by
the memory cycle time. It is also known as Memory Banking.
2. Low Order Interleaving - In low-order interleaving, the
least significant bits select the memory bank (module). In
this, consecutive memory addresses are in different memory
modules. This allows memory access at much faster rates
than allowed by the cycle time.
Virtual Memory
Virtual memory is a memory management technique used by
operating systems to give the appearance of a large,
continuous block of memory to applications, even if the
physical memory (RAM) is limited and not necessarily
allocated in contiguous manner. The main idea is to divide the
process in pages, use disk space to move out the pages if
space in main memory is required and bring back the pages
when needed.
Objectives of Virtual Memory
A program doesn’t need to be fully loaded in memory to
run. Only the needed parts are loaded.
Programs can be bigger than the physical memory
available in the system.
Virtual memory creates the illusion of a large memory,
even if the actual memory (RAM) is small.
It uses both RAM and disk storage to manage memory,
loading only parts of programs into RAM as needed.
This allows the system to run more programs at once and
manage memory more efficiently.
Types of Virtual Memory
In a computer, virtual memory is managed by the Memory
Management Unit (MMU), which is often built into the CPU.
The CPU generates virtual addresses that the MMU
translates into physical addresses. There are two main types
of virtual memory:
1. Paging
2. Segmentation
1. Paging
Paging divides memory into small fixed-size blocks called
pages. When the computer runs out of RAM, pages that aren't
currently in use are moved to the hard drive, into an area
called a swap file. Here,
The swap file acts as an extension of RAM.
When a page is needed again, it is swapped back into
RAM, a process known as page swapping.
This ensures that the operating system (OS) and
applications have enough memory to run.
Page Fault Service Time: The time taken to service the page
fault is called page fault service time. The page fault service
time includes the time taken to perform all the above six
steps.
Let Main memory access time is: m
Page fault service time is: s
Page fault rate is : p
Then, Effective memory access time = (p∗s)+(1−p)∗m
Page and Frame: Page is a fixed size block of data in virtual
memory and a frame is a fixed size block of physical memory
in RAM where these pages are loaded.
Think of a page as a piece of a puzzle (virtual memory)
While, a frame as the spot where it fits on the board
(physical memory).
When a program runs its pages are mapped to available
frames so the program can run even if the program size is
larger than physical memory.
2. Segmentation
Segmentation divides virtual memory into segments of
different sizes. Segments that aren't currently needed can be
moved to the hard drive. Here,
The system uses a segment table to keep track of each
segment's status, including whether it's in memory, if it's
been modified and its physical address.
Segments are mapped into a process's address space only
when needed.
Applications of Virtual memory
Increased Effective Memory: It enables a computer to
have more memory than the physical memory using the
disk space. This allows for the running of larger
applications.
Memory Isolation: Virtual memory allocates a unique
address space to each process, such separation increases
safety and reliability based on the fact that one process
cannot interact with another.
Efficient Memory Management: Virtual memory also
helps in better utilization of the physical memories through
methods that include paging and segmentation.
Simplified Program Development: For case of
programmers, they can program ‘as if’ there is one big
block of memory and this makes the programming easier
and more efficient in delivering more complex applications.
Benefits of Using Virtual Memory
Supports Multiprogramming & Larger Programs
Maximizes Application Capacity
Eliminates Physical Memory
Boosts Security & Isolation
Improves CPU & System Performance
Enhances Memory Management Efficiency
Limitation of Virtual Memory
Slower Performance
Risk of Data Loss
More Complex System
Memory Management
Memory management is the process of controlling and
organizing a computer’s memory by allocating portions, called
blocks, to different executing programs to improve the overall
system performance.
The most important function of an operating system is to
manage primary memory.
Supports multiple processes simultaneously in memory.
Protects processes from unauthorized access.
Enables swapping and virtual memory efficiently.
Techniques in Memory Allocation
Used by an operating system to efficiently allocate, utilize,
and manage memory resources for processes. Various
techniques help the operating system manage memory
effectively. They can be broadly categorized into:
Contiguous Memory Allocation
Each process is allocated a single continuous block of
memory. All instructions and data of a process are stored in
adjacent memory locations.
Single Contiguous Memory Allocation
Simplest form of memory management. In this technique, the
main memory is divided into two parts:
One part is reserved for the Operating System
The remaining part is allocated to a single user process
Characteristics
Only one user process can reside in memory at a time
The operating system occupies a fixed portion of memory
No multiprogramming is possible
Simple to implement and manage
Advantages
Simple memory management
No fragmentation issues
Disadvantages
Poor memory utilization
No support for multitasking or multiprogramming
Partitioned Memory Allocation
Main memory is divided into multiple contiguous partitions,
and each partition can hold one process. This technique
supports multiprogramming.
Partitioned memory allocation is further classified into:
Fixed Partition Allocation
Memory is divided into a fixed number of partitions
Each partition has a fixed size
Each partition can store only one process
Leads to internal fragmentation
Once partitions are defined operating system keeps track
of the status of memory partitions it is done through a data
structure called a partition table.
Starting Address of Partition Size of Partition Status
0k 200k allocated
Starting Address of Partition Size of Partition Status
200k 100k free
300k 150k free
450k 250k allocated
Variable Partition Allocation
Memory is divided into partitions dynamically based on
process size
Reduces internal fragmentation
Suffers from external fragmentation
Advantages
Supports multiprogramming
Better memory utilization compared to single contiguous
allocation
Disadvantages
Fragmentation issues
Complex memory management compared to single
contiguous allocation
Non-Contiguous Memory Allocation
Memory management technique in which a process is divided
into smaller parts and these parts are stored in different, non-
adjacent locations in main memory. Unlike contiguous
allocation, the entire process does not need to be placed in a
single continuous block of memory.
This technique is widely used in modern operating systems
because it improves memory utilization and reduces
fragmentation problems.
Features of Non-Contiguous Memory Allocation
A process can be stored in multiple memory locations
Improves utilization of available memory
Reduces external fragmentation
Requires address translation using hardware support
(MMU)
Advantages
Better memory utilization
Supports large programs
Eliminates the need for contiguous free memory
Disadvantages
More complex than contiguous allocation
Additional overhead for address translation
Requires extra memory for tables (page table / segment
table)