I/O Techniques in Computer Architecture
What is Programmed I/O?
Programmed I/O is a way for the CPU to communicate with input/output devices directly by checking
their status one by one.
How does it work?
The CPU keeps asking the device, "Are you ready?"
If the device is not ready, the CPU keeps waiting and checking again and again (this is called busy
waiting).
When the device is ready, the CPU sends or receives data.
The CPU controls everything and does not get help from interrupts.
Easy Example:
Imagine you want to send a message to your friend.
You keep asking your friend, "Are you ready to get the message?"
If your friend says "No, not yet," you wait and keep asking.
When your friend says "Yes, Im ready," you send the message.
This is like how programmed I/O works the CPU waits and checks until the device is ready.
Drawbacks of Programmed I/O:
1. CPU Wastes Time: The CPU keeps checking (polling) the device again and again, which wastes
a lot of CPU time.
2. Not Efficient for Fast Devices: If the device is slow, CPU waits too much. If the device is fast, CPU
still wastes time checking unnecessarily.
3. CPU Cant Do Other Work: While waiting for the device, the CPU cannot do other important tasks
it is busy doing only input/output checking.
4. Not Good for Multiple Devices: If many devices are connected, CPU must check each one
continuously, which makes the system slow and inefficient.
What is Interrupt-Initiated I/O?
Interrupt-Initiated I/O is a method where the CPU doesnt keep checking the device again and again.
Instead, the device tells the CPU when it is ready by sending an interrupt signal.
How it works (CPU and Interrupts):
- The CPU starts doing its normal work (like calculations or running programs).
- When an input/output device becomes ready, it sends a signal called an interrupt to the CPU.
- The CPU pauses its current work and goes to handle the I/O task.
- After completing the I/O work, the CPU returns to its previous task and continues working.
Easy Example:
Imagine youre doing homework.
You tell your friend, When you're ready to talk, just tap my shoulder.
You dont keep looking at them. You focus on your work.
When they tap your shoulder (interrupt), you talk to them, and then go back to your homework.
Advantages of Interrupt-Initiated I/O:
1. Saves CPU time CPU does not waste time checking devices again and again.
2. More efficient CPU can do other work while waiting for I/O.
3. Faster response CPU quickly handles the device when it gets the interrupt.
4. Good for multiple devices CPU only responds when needed.
Disadvantages of Interrupt-Initiated I/O:
1. More complex Needs interrupt handling hardware and software.
2. Interrupts can disturb tasks CPU work is paused often.
3. Too many interrupts If too many devices interrupt, CPU can get overloaded.
4. Hard to manage Controlling multiple interrupts in order can be tricky.
Definition of DMA:
DMA (Direct Memory Access) is a method where data is transferred directly between I/O devices
and main memory without the continuous involvement of the CPU.
Instead of the CPU handling every byte of data, a special hardware unit called the DMA controller
manages the data transfer. The CPU only gives permission once and is notified when the transfer is
complete.
Types of DMA Transfer using DMA Controller:
1. Burst Mode (Block Transfer Mode):
- The DMA controller takes control of the system bus and transfers the entire block of data at once.
- CPU is stopped temporarily during the transfer.
- Fast but CPU is paused for longer time.
2. Cycle Stealing Mode:
- DMA controller transfers one byte at a time by stealing CPU cycles.
- CPU and DMA take turns using the system bus.
- CPU is not stopped completely but transfer is slower.
3. Transparent Mode:
- DMA transfers only when CPU is idle (not using the bus).
- So, CPU is never interrupted.
- CPU runs smoothly but data transfer is slower.
Advantages of DMA:
1. Frees up the CPU CPU can do other tasks while data transfer happens.
2. Faster transfer Especially good for large data movement.
3. Efficient system performance CPU isnt slowed down by I/O.
4. Good for real-time systems Like video, audio, etc.
Disadvantages of DMA:
1. Needs extra hardware A DMA controller must be added.
2. Complex to manage Requires coordination between CPU, memory, and devices.
3. Memory conflicts CPU and DMA may try to use memory at the same time.
4. Not suitable for small transfers Setup overhead may be more than the transfer itself.