0
0
Operating Systemsknowledge~3 mins

Programmed I/O vs interrupt-driven I/O in Operating Systems - When to Use Which

Choose your learning style9 modes available
The Big Idea

What if your computer could stop wasting time waiting and start working smarter instead?

The Scenario

Imagine you are waiting by the phone, staring at it constantly to catch a call. You can't do anything else because you must answer immediately when it rings.

The Problem

This constant waiting wastes your time and energy. You might miss other important tasks because you are stuck watching the phone. It is tiring and inefficient.

The Solution

Now imagine the phone rings and instead of you watching it, a friend taps your shoulder to tell you. You can focus on your work and only respond when needed. This is how interrupt-driven I/O works, making the system more efficient.

Before vs After
Before
while (device_not_ready()) { /* keep checking */ } read_data();
After
enable_interrupt(); // CPU does other tasks
on_interrupt() { read_data(); }
What It Enables

This approach lets the computer do many things at once, improving speed and saving energy.

Real Life Example

When you type on a keyboard, the computer doesn't watch the keyboard all the time. Instead, it waits for a signal (interrupt) when a key is pressed, then processes it.

Key Takeaways

Programmed I/O wastes time by constant checking.

Interrupt-driven I/O notifies the CPU only when needed.

Interrupts improve efficiency and multitasking.