0
0
Operating Systemsknowledge~6 mins

Programmed I/O vs interrupt-driven I/O in Operating Systems - Key Differences Explained

Choose your learning style9 modes available
Introduction
Imagine you want to get data from a device like a keyboard or a disk. The problem is how the computer should wait for this data without wasting time or missing it. Two common ways to handle this are programmed input/output and interrupt-driven input/output.
Explanation
Programmed I/O
In programmed I/O, the computer's processor actively checks the device repeatedly to see if it is ready to send or receive data. This checking is called polling. The processor waits in a loop until the device is ready, which can waste time because the processor cannot do other tasks during this waiting.
Programmed I/O makes the processor wait and check the device continuously, which can waste processing time.
Interrupt-driven I/O
In interrupt-driven I/O, the device tells the processor when it is ready by sending an interrupt signal. The processor can do other work and only stops to handle the device when it receives this signal. This way, the processor is not wasting time waiting and can be more efficient.
Interrupt-driven I/O lets the device notify the processor, so the processor can work on other tasks until needed.
Processor Involvement
Programmed I/O requires the processor to be involved constantly, checking the device status. Interrupt-driven I/O reduces this involvement by allowing the processor to respond only when the device signals it, freeing the processor for other work.
Interrupt-driven I/O reduces processor involvement compared to programmed I/O.
Efficiency and Use Cases
Programmed I/O is simple but inefficient for slow devices because the processor wastes time polling. Interrupt-driven I/O is more efficient, especially when devices are slow or data comes irregularly, as it allows better multitasking and resource use.
Interrupt-driven I/O is more efficient and better for multitasking than programmed I/O.
Real World Analogy

Imagine you are waiting for a friend to arrive. In programmed I/O, you keep looking out the window every minute to see if they are there, which wastes your time. In interrupt-driven I/O, you do your work and your friend calls you when they arrive, so you only stop when needed.

Programmed I/O → Looking out the window repeatedly to check if the friend has arrived
Interrupt-driven I/O → Friend calling you to announce their arrival
Processor Involvement → Your attention being fully on watching the window versus doing other tasks
Efficiency and Use Cases → Wasting time watching the window versus using time effectively until called
Diagram
Diagram
┌─────────────────────┐          ┌─────────────────────┐
│    Programmed I/O    │          │ Interrupt-driven I/O│
├─────────────────────┤          ├─────────────────────┤
│ Processor polls      │          │ Device sends        │
│ device status in a   │          │ interrupt signal    │
│ loop, waiting        │          │ when ready          │
│                     │          │                     │
│ Processor busy       │          │ Processor does other │
│ waiting              │          │ work until interrupt│
└─────────┬───────────┘          └─────────┬───────────┘
          │                                │
          │                                │
          ▼                                ▼
   Device ready                     Device ready
   data transfer                   data transfer
This diagram compares how programmed I/O keeps the processor busy polling the device, while interrupt-driven I/O lets the processor work until the device signals readiness.
Key Facts
Programmed I/OProcessor continuously checks device status in a loop to transfer data.
Interrupt-driven I/ODevice sends an interrupt signal to processor when it is ready for data transfer.
PollingThe process of repeatedly checking the status of a device.
InterruptA signal from a device that alerts the processor to stop current work and handle the device.
Processor EfficiencyInterrupt-driven I/O improves efficiency by freeing the processor from constant checking.
Common Confusions
Thinking programmed I/O allows the processor to do other tasks while waiting.
Thinking programmed I/O allows the processor to do other tasks while waiting. In programmed I/O, the processor is busy polling and cannot perform other tasks effectively during this time.
Believing interrupts cause the processor to stop all work immediately.
Believing interrupts cause the processor to stop all work immediately. Interrupts pause the current task briefly to handle the device, then the processor resumes its previous work.
Summary
Programmed I/O wastes processor time by making it check the device repeatedly.
Interrupt-driven I/O lets the device notify the processor, improving efficiency and multitasking.
Choosing between these methods depends on device speed and system needs.