Input/Output Organization and Interfacing

SA
StudyAI
AI-generated study notes
· Published Updated Free model

From the Computer Organisation and Architecture curriculum

TL;DR

Input/Output (I/O) organization deals with how your computer system communicates with the outside world, from keyboards to hard drives. It involves hardware components like I/O modules and different methods like programmed I/O, interrupt-driven I/O, and Direct Memory Access (DMA) to manage data transfer efficiently. Interfacing defines the rules and connections for these devices to work together seamlessly.

1. The Mental Model

Think of I/O as the computer's senses and actions: it takes in information (input) and produces results (output). The I/O organization is how these "senses" and "actions" are structured, and interfacing is the "language" and "connection points" that allow everything to work together.

2. The Core Material

Your computer constantly needs to interact with external devices. These devices are much slower than the CPU and memory, so efficient I/O organization is crucial to prevent the CPU from idling.

I/O Modules

Detailed view of a green electronic memory module against a white background, showcasing modern technology.
Photo by William Warby on Pexels

An I/O module (or I/O controller) acts as a mediator between the CPU/memory and peripheral devices. It handles the low-level communication specifics for each device, freeing the CPU from this burden.

Key functions of an I/O module:
- Control & Timing: Synchronizes data flow between the CPU and peripherals.
- CPU Communication: Decodes commands, sends status reports, and transfers data.
- Device Communication: Manages specific commands, status, and data transfer for the attached device.
- Data Buffering: Temporarily stores data to compensate for speed differences.
- Error Detection: Reports issues like parity errors.

I/O Techniques

Technician performing precise soldering on a circuit board for electronics repair.
Photo by Maikol Herrera on Pexels

There are three main ways data is transferred between an I/O module and the CPU/memory:

1. Programmed I/O

In programmed I/O, the CPU directly controls the I/O operations. It constantly checks the status of the I/O module to see if a device is ready for data transfer. This is simple but very inefficient because the CPU wastes time polling.

Here's how it generally works:
1. CPU issues an I/O command.
2. CPU polls (repeatedly checks) the I/O module's status register.
3. If the device is ready, the CPU transfers data.
4. If not ready, the CPU waits, looping until it is.

2. Interrupt-Driven I/O

To improve efficiency, interrupt-driven I/O allows the CPU to perform other tasks while an I/O operation is in progress. When a device is ready, the I/O module sends an interrupt signal to the CPU. The CPU then suspends its current task, saves its context, and executes an Interrupt Service Routine (ISR) to handle the I/O.

This is more efficient than programmed I/O because the CPU isn't wasting cycles polling.

graph TD
    A["CPU running program"] --> B{"I/O command issued?"}
    B -- Yes --> C["I/O module starts operation"]
    C --> D["CPU continues other work"]
    D -- While I/O works --> E{"I/O operation complete?"}
    E -- No, not ready --> D
    E -- Yes, ready --> F["I/O module generates Interrupt"]
    F --> G["CPU receives Interrupt"]
    G --> H["CPU saves context"]
    H --> I["CPU executes Interrupt Service Routine (ISR)"]
    I --> J["Data transfer occurs (CPU controlled)"]
    J --> K["CPU restores context"]
    K --> A

3. Direct Memory Access (DMA)

Both programmed I/O and interrupt-driven I/O require the CPU to be actively involved in each data transfer. For large data transfers (e.g., from a hard drive), this still burdens the CPU. Direct Memory Access (DMA) is a technique where the I/O module can directly transfer data to and from memory without involving the CPU for each word.

A special component called the DMA controller manages this.
1. CPU tells the DMA controller:
* What operation to perform (read/write).
* The starting memory address.
* The number of bytes to transfer.
* The I/O device involved.
2. CPU continues with other tasks.
3. DMA controller takes control of the system bus and performs the data transfer directly between the I/O device and memory.
4. Once the entire transfer is complete, the DMA controller sends an interrupt to the CPU.

DMA is the most efficient method for high-volume data transfers.

I/O Interfacing

I/O interfacing refers to the connection between an I/O module and the peripheral device. It includes the electrical, logical, and physical characteristics that ensure compatibility. This involves:
- Addressing: How the CPU identifies and selects a specific I/O device or its registers.
* Memory-mapped I/O: I/O device registers are mapped into the same address space as memory. The CPU uses the same instructions for memory and I/O access.
* Isolated I/O: I/O devices have a separate address space, requiring special I/O instructions (e.g., IN and OUT in x86).
- Control Signals: Signals for commanding devices (e.g., read, write) and receiving status (e.g., busy, ready).
- Data Paths: The actual wires or lines over which data travels.
- Bus Architecture: The common pathway that connects the CPU, memory, and I/O modules. Examples include PCI Express (PCIe) and USB.

3. Worked Example

Let's consider saving a large file from memory to a hard drive using DMA.

  1. Application Request: A user saves a 1MB file. The operating system receives this request.
  2. CPU Setup: The OS, through the CPU, instructs the DMA controller:
    • "Transfer 1MB of data."
    • "Data starts at memory address 0x100000."
    • "Write this data to the hard drive, starting at block 0x500."
    • The CPU sends these parameters to the DMA controller's registers.
  3. CPU Frees Up: The CPU is now free to execute other instructions or run other programs.
  4. DMA Transfer:
    • The DMA controller requests control of the system bus.
    • Once granted, it fetches data from memory address 0x100000 (and subsequent addresses) in chunks.
    • It then transfers this data to the hard drive controller.
    • This process repeats, block by block, directly between memory and the hard drive, without CPU intervention for each byte or block. The DMA controller handles bus arbitration and memory addressing.
  5. Interrupt Notification: After the entire 1MB is transferred, the DMA controller sends an interrupt to the CPU.
  6. ISR Execution: The CPU temporarily stops its current task, jumps to the ISR for the DMA completion, checks the status (to ensure no errors occurred), and then resumes its previous task. The file save is complete.

4. Key Takeaways

  • I/O modules mediate communication between the CPU/memory and slower peripheral devices.
  • Programmed I/O involves the CPU constantly polling the I/O device, making it inefficient.
  • Interrupt-driven I/O lets the CPU do other work until an I/O device signals completion with an interrupt.
  • DMA offloads large data transfers from the CPU entirely, allowing direct memory-to-device transfers.
  • Memory-mapped I/O treats device registers as memory locations, using standard memory instructions.
  • Isolated I/O uses a separate address space and special instructions for I/O devices.

Common mistakes to avoid:
- Confusing the purpose of I/O modules with the CPU; the module offloads specific device control from the CPU.
- Underestimating the performance impact of choosing the wrong I/O technique; programmed I/O severely limits CPU throughput.
- Forgetting that even with DMA, the CPU is still involved in setting up the transfer and handling the final interrupt.
- Ignoring the role of buses; they are the physical pathways for all these data transfers.

5. Now Try It

Imagine your computer needs to read a single character typed from a keyboard. Describe the step-by-step process using interrupt-driven I/O. What components are involved, and what does each component do?

What success looks like: You should clearly explain how the CPU, keyboard, and I/O module interact, when an interrupt occurs, and what happens before and after it.

Frequently asked about Input/Output Organization and Interfacing

Input/Output (I/O) organization deals with how your computer system communicates with the outside world, from keyboards to hard drives. Read the full notes above for the details.

Input/Output Organization and Interfacing is a core topic in Computer Organisation and Architecture. Most exam papers test it via a mix of definitions, worked examples, and applied problems. The notes above cover the high-yield sub-topics, common pitfalls, and the kind of questions examiners typically set.

Yes — every note in the StudyAI Campus Hub is free to read in full, right here on this page, with no account needed. If you clone the plan into your own dashboard, the free plan shows a preview of each note there; Basic and above unlock the full notes in your dashboard, along with practice quizzes, flashcards and offline study. You can always come back here to read the complete note for free.

More from Computer Organisation and Architecture


Get the full Computer Organisation and Architecture curriculum

Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.

Save this course free