0% found this document useful (0 votes)
313 views5 pages

6 Programmed IO, Interrupt-Driven IO, DMA

Uploaded by

rkeditors47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
313 views5 pages

6 Programmed IO, Interrupt-Driven IO, DMA

Uploaded by

rkeditors47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Programmed I/O

Programmed I/O (PIO) is a method of performing input/output operations in a


computer system where the CPU directly controls the data transfer between I/O
devices and memory. In programmed I/O, the CPU executes instructions to read
from or write to I/O devices, and each byte or word of data is transferred individually
under the control of the CPU. Here's a detailed explanation of Programmed I/O:
Overview:
• In programmed I/O, the CPU is responsible for initiating, controlling,
and monitoring I/O operations.
• When an I/O operation is needed, the CPU executes specific
instructions to communicate with the I/O device.
• Each data transfer between the CPU and the I/O device involves
multiple instructions, typically including reading or writing data to a
specific I/O port or memory location.
Steps in Programmed I/O:
• Initialization: Before initiating an I/O operation, the CPU may need to
initialize the I/O device and configure any necessary control registers.
• Data Transfer: The CPU transfers data to or from the I/O device by
reading from or writing to specific I/O ports or memory locations. Each
data transfer typically involves multiple instructions.
• Polling: After initiating the data transfer, the CPU may need to wait for
the I/O device to complete the operation. This is often done through
polling, where the CPU repeatedly checks the status of the device until
the operation is complete.
• Error Handling: If an error occurs during the I/O operation, the CPU
must handle it appropriately. This may involve retrying the operation,
notifying the operating system or application, or taking corrective
action.
Characteristics:
• Synchronous Operation: Programmed I/O is synchronous, meaning
that the CPU actively controls each step of the I/O operation and waits
for the device to complete each transfer before proceeding.
• High CPU Overhead: Since the CPU is directly involved in every
aspect of the I/O operation, programmed I/O can result in high CPU
overhead, especially for devices that transfer data at relatively slow
speeds.
• Simplicity: Programmed I/O is relatively simple to implement and
understand compared to other I/O techniques such as DMA or interrupt-
driven I/O.
Applications:
• Programmed I/O is commonly used for low-speed or simple I/O devices
where the overhead of more sophisticated techniques is not justified.
• Examples of devices that may use programmed I/O include keyboards,
mice, serial ports, and certain types of sensors or actuators in embedded
systems.
Limitations:
• Programmed I/O can be inefficient for high-speed or high-volume data
transfers due to the overhead of CPU involvement in each transfer.
• It can also lead to poor system performance if the CPU is tied up
performing I/O operations instead of executing application code.

Interrupt-Driven I/O:
• Overview: In interrupt-driven I/O, the CPU doesn't continuously poll
or wait for I/O devices to be ready. Instead, it allows the CPU to perform
other tasks while waiting for I/O operations to complete. When an I/O
operation completes or requires attention, the device signals the CPU
by generating an interrupt.
• Interrupt Handling: When an interrupt occurs, the CPU temporarily
suspends its current task, saves its state (registers, program counter,
etc.), and jumps to an interrupt service routine (ISR) specified by the
interrupt vector table. The ISR then handles the interrupt, which may
involve servicing the I/O request, acknowledging the completion of an
operation, or handling errors.
• Asynchronous Operation: Interrupt-driven I/O allows devices to
operate asynchronously with respect to the CPU, meaning that I/O
operations can occur independently of the CPU's execution. This
asynchronous operation improves system performance by allowing the
CPU to perform other tasks while waiting for I/O operations to
complete.
• Example: Consider a disk I/O operation where data needs to be read
from or written to a disk. Instead of continuously polling the disk to
check if the operation is complete, the CPU can initiate the operation
and continue executing other tasks. When the disk operation completes,
the disk controller interrupts the CPU, allowing it to handle the
completion of the operation.

Direct Memory Access (DMA):


• Overview: DMA is a technique used to transfer data between devices
(such as disk drives, network interfaces, or sound cards) and memory
without involving the CPU for every data transfer. DMA controllers are
specialized hardware units that manage these data transfers
independently of the CPU.
• Operation: In DMA, the CPU sets up the DMA controller by
specifying the transfer parameters (source address, destination address,
transfer size, etc.) and then initiates the transfer. The DMA controller
then takes control of the system bus and directly transfers data between
the device and memory without CPU intervention.
• Efficiency: DMA significantly improves system performance by
offloading data transfer tasks from the CPU. Instead of the CPU
performing data transfers byte by byte or word by word, the DMA
controller can transfer large blocks of data at a much faster rate,
allowing the CPU to focus on other tasks.
• Interrupts: Although DMA transfers do not require constant CPU
involvement, DMA controllers can still generate interrupts to signal the
CPU when a transfer is complete or when an error occurs. This allows
the CPU to handle any necessary cleanup or additional processing
related to the DMA transfer.
• Example: In a network interface card (NIC), DMA can be used to
transfer incoming data packets directly to memory without involving
the CPU for each packet. Similarly, DMA can be used to transfer data
between disk drives and memory during disk I/O operations, freeing the
CPU to perform other tasks.

Figure 1: Three Techniques for Input of a Block of Data


The figure gives an example of the use of programmed I/O to read in a block of data
from a peripheral device (e.g., a record from tape) into memory. Data is read in one
word (e.g., 16 bits) at a time. For each word that is read in, the processor must remain
in a status-checking cycle until it determines that the word is available in the I/O
module’s data register. This flowchart highlights the main disadvantage of this
technique: it is a time-consuming process that keeps the processor busy needlessly.
Interrupt-driven I/O and DMA are techniques used to improve system performance
by allowing devices to operate asynchronously with respect to the CPU and by
offloading data transfer tasks from the CPU to specialized hardware controllers.
These techniques are essential for efficiently managing I/O operations in modern
computer systems.

You might also like