Module 4
Module 4
1. Functionality:
◦ Input Devices: Allow users to send data to the computer (e.g., a keyboard sends text input).
◦ Output Devices: Enable the computer to send data to users or other systems (e.g., a printer produces documents).
◦ Storage Devices: Store or retrieve data for the computer (e.g., external hard drives).
2. Connection Type:
◦ Wired: Connected to the computer through cables (e.g., USB, HDMI(High-definition Multimedia interface- digital video
and audio to from the source device to display device monitor or projector ).
◦ Wireless: Connected through wireless technologies (e.g., Bluetooth, Wi-Fi).
3. Data Transfer Modes:
◦ Serial: Data is transmitted one bit at a time, usually used for long-distance communication (e.g., USB).
◦ Parallel: Multiple bits are transferred simultaneously, typically over short distances (e.g., older printer connections).
4. Data Direction:
I/O Device Interface
The I/O (Input/Output) Device Interface serves as a bridge between the computer's
central processing unit (CPU) and external devices (such as keyboards, printers, and storage
drives). It allows communication between the CPU, memory, and peripheral devices.
Key Components of I/O Interfaces:
•Controller: A hardware component that manages the interaction between the CPU and the
device.
•Data Registers: Store data that is to be transferred to/from the device.
•Status Registers: Hold the status of the device (e.g., ready, busy, or error states).
•Command Registers: Allow the CPU to issue commands to the device (e.g., read, write).
Common I/O Interfaces:
•USB (Universal Serial Bus): For external devices like flash drives, keyboards, and
printers.
•SATA (Serial Advanced Technology Attachment): Primarily for connecting storage
devices. is a type of interface primarily used to connect storage devices, like
hard drives, solid-state drives (SSDs)
•PCIe (Peripheral Component Interconnect Express): High-speed interface for
devices like graphics and network cards.
•HDMI (High-Definition Multimedia Interface): For transferring high-quality audio
and video to monitors and TVs.
I/O Transfers
In computer systems, data transfers between I/O devices and memory are essential operations, handled through various methods:
program-controlled, interrupt-driven, and Direct Memory Access (DMA). Each of
these I/O transfer methods has its own unique characteristics and is suited to different scenarios based on the requirements of the system,
efficiency, and the workload involved.
1. Program-Controlled I/O (Polling)
•Mechanism: In program-controlled I/O, the processor (CPU) actively controls data transfer by continually checking the status of an
I/O device to see if it is ready to read or write data. This process is known as polling.
•Operation: The CPU runs a loop that checks the I/O device's status register. When the device is ready, the CPU proceeds with data
transfer by executing instructions directly to read from or write to the device.
Pros:
•Simple to implement; no additional hardware needed.
•Suitable for simple, low-speed devices where data transfer speed isn't critical.
Cons :
b. Interrupt-Driven I/O
An interrupt is a signal sent by a device or software to the CPU, indicating that it needs
attention.
When the CPU receives this signal, it pauses its current tasks, saves the state, and
addresses the interrupt
Interrupt-driven I/O is an I/O technique that leverages interrupts to manage input and
output operations more efficiently. Here's how it works:
1.When a device (like a keyboard or printer) is ready to send or receive data, it sends an
interrupt signal to the CPU.
2.The CPU temporarily stops its current tasks to handle the I/O operation.
3.After handling the I/O, the CPU resumes its previous tasks.
•Advantages:
◦More efficient than polling, as the CPU is not continuously checking the device
status.
•Disadvantages:
◦Requires an interrupt handling mechanism to manage device requests.
DMA (Direct Memory Access)
•Executed only in Kernel Mode (supervisor mode), these instructions have direct access to
critical system resources such as memory, hardware, and I/O devices.
•Examples include memory management, interrupt control, and I/O management.
Uses:
◦Protect the system from untrusted user applications.
•Examples:
◦Enable/disable interrupts.
◦Access I/O ports.
◦Control hardware devices.
b. Non-Privileged Instructions
•Executed in User Mode, these instructions are limited in scope and cannot
directly access system resources or hardware.
•Used for general user programs that don’t require hardware access.
Examples:
◦Arithmetic operations.
◦Accessing local variables.
◦Memory read and write within allowed regions.
4. Software Interrupts and Exceptions
a. Software Interrupts
• Triggered by Programs: Also known as traps, software interrupts are intentionally generated by a running program
to request services from the operating system.
• Used for system calls (e.g., requesting I/O, file operations, process management).
Examples:
◦ A program needing file access generates a software interrupt to invoke an OS service for opening the file.
b. Exceptions
• Automatic Interrupts: These occur when the CPU detects an abnormal condition during
execution, such as an error or illegal operation.
• Examples include division by zero, invalid memory access, and invalid opcode.
Types of Exceptions:
◦ Faults: Can be corrected, and the process is restarted (e.g., page faults in memory management).
◦ Traps: Can be intentional or managed, where the program continues after handling the event.
Here’s a breakdown of the process:
1.Program Execution: A program is running and encounters a division by zero
operation.
2.Software Interrupt Generation: The CPU detects this illegal operation and
triggers an exception (a type of software interrupt) because division by zero is
undefined.
3.Interrupt Handling: Control is transferred to an interrupt handler (also called an
exception handler) predefined by the operating system, which can log the error, notify
the user, or terminate the offending program gracefully.
DMA Transfer
In modern computer systems, transferring data between input/output devices and memory can be a
slow process if the CPU is required to manage every step.
To address this, a Direct Memory Access (DMA) Controller is utilized.
A Direct Memory Access (DMA) Controller solves this by allowing I/O devices to transfer data
directly to memory, reducing CPU involvement.
This increases system efficiency and speeds up data transfers, freeing the CPU to focus on other
tasks.
DMA controller needs the same old circuits of an interface to communicate with the CPU and
Input/Output devices.
What is a DMA Controller?
Direct Memory Access (DMA) uses hardware for accessing the memory,
that hardware is called a DMA Controller.
It has the work of transferring the data between Input Output devices and main
memory with very less interaction with the processor.
The direct Memory Access Controller is a control unit, which has the work of
transferring data.
DMA Controller in Computer Architecture
DMA Controller is a type of control unit that works as an interface for the data bus and the I/O Devices
DMA Controller has the work of transferring the data without the intervention of the processors, processors can
control the data transfer
DMA Controller also contains an address unit, which generates the address and selects an I/O device for the
transfer of data
BLOCK DIAGRAM OF DMA CONTROLLER
Working of DMA Controller
The starting address of the memory block where the data is available (to read) or where data
are to be stored (to write).
It also sends word count which is the number of words in the memory block to be read or
written.
Control to define the mode of transfer such as read or write.
A control to begin the DMA transfer
Key Components and Connections
Data Bus Buffer:
Acts as a temporary holding area for data transferred between the memory and I/O devices.
Connected to the data bus and controlled by the internal bus, allowing data flow between components.
Address Bus Buffers:
Holds address information temporarily before it is sent to the memory or I/O devices.
Connected to the address bus and receives inputs from various registers.
Control Logic:
The core decision-making part of the DMA controller that manages data transfers.
Controls the operations of reading, writing, and DMA requests.
Receives various signals such as:
DS (DMA Select): Chooses the DMA channel.
RS (Register Select): Selects the specific register to be used.
RD (Read): Initiates data read from memory.
WR (Write): Initiates data write to memory.
BR (Bus Request): Requests control of the bus to start data transfer.
BG (Bus Grant): Acknowledges control of the bus.
Interrupt: Signals the CPU that the data transfer is complete.
Registers:
Address Register: Holds the memory address to where data is to be transferred or received.
Word Count Register: Maintains a count of the number of words (data units) to be transferred.
Control Register: Stores control information to manage DMA operations.
Signals:
DMA Request: Sent to the CPU, asking for permission to access the memory.
DMA Acknowledge: Confirms permission to access memory, allowing data transfer to I/O devices.
How DMA Transfer Works:
1. Setup:
◦ The CPU initializes the DMA controller by specifying key parameters, such as:
▪ Source Address: Where the data will be read from (e.g., memory or I/O device).
▪ Destination Address: Where the data will be written to.
▪ Data Size: The number of bytes to transfer.
◦ The CPU sends this information to the DMA controller and then proceeds with other tasks.
2. Data Transfer:
◦ The DMA controller takes control of the system bus, transferring data directly between memory and the I/O device.
◦ The CPU does not participate in the actual transfer, freeing it to perform other operations.
3. Completion:
◦ When the DMA transfer is complete, the DMA controller signals the CPU using an interrupt, informing it that the
transfer is finished.
Types of DMA Transfers
1. Burst Mode (Block Transfer Mode):
◦ The DMA controller transfers a block of data in a single burst, without allowing the CPU to use the bus during the transfer.
◦ Advantage: Fast and efficient transfer for large data blocks.
◦ Disadvantage: The CPU is temporarily denied access to the system bus, which may affect performance for other
processes.
2. Cycle Stealing Mode:
◦ The DMA controller transfers one byte of data at a time, releasing control of the bus to the CPU after each byte.
◦ Advantage: The CPU can still access the bus between transfers, ensuring minimal disruption to other tasks.
◦ Disadvantage: Slower than burst mode, as data is transferred in small chunks.
3. Transparent Mode:
◦ The DMA controller transfers data only when the CPU is idle and not using the bus.
◦ Advantage: The CPU performance is not impacted at all.
Advantages of DMA Transfer
1. Increased Efficiency:
◦ DMA allows data to be transferred between devices and memory without constantly engaging the CPU, increasing
overall system efficiency.
2. Reduced CPU Overhead:
◦ Since the CPU is free to execute other tasks while data transfer takes place, it improves multitasking and processing
speed, especially for real-time applications.
3. High-Speed Data Transfer:
◦ DMA is faster compared to CPU-controlled transfers because the data is moved directly between memory and
devices without intermediate steps.
4. Minimized Latency:
◦ DMA can handle high-speed data transfer with minimal delays, which is particularly useful for multimedia
applications like audio and video streaming.