Bird
Raised Fist0
Operating Systemsknowledge~10 mins

Programmed I/O vs interrupt-driven I/O in Operating Systems - Visual Side-by-Side Comparison

Choose your learning style10 modes available
Concept Flow - Programmed I/O vs interrupt-driven I/O
Start I/O Operation
↓
Programmed I/O?
Yes→CPU waits and checks device status repeatedly
↓
Data transfer when ready
↓
Interrupt-driven I/O?
Yes→CPU does other work
↓
Device sends interrupt when ready
↓
Invalid method
↓
End
↓
End
The flow shows two ways CPU handles I/O: Programmed I/O where CPU waits actively, and Interrupt-driven I/O where CPU works and responds when device signals.
Execution Sample
Operating Systems
while (device_not_ready) {
  // wait and check device status
}
read_data_from_device();
This code shows Programmed I/O where CPU waits in a loop checking device readiness before reading data.
Analysis Table
StepCPU ActionDevice Status CheckCPU StateData Transfer
1Check device statusNot readyWaitingNo
2Check device statusNot readyWaitingNo
3Check device statusReadyProceedNo
4Read dataReadyReadingYes
5End---
💡 Device becomes ready at step 3, CPU stops waiting and reads data.
State Tracker
VariableStartAfter 1After 2After 3After 4Final
device_statusNot readyNot readyNot readyReadyReadyReady
CPU_stateIdleWaitingWaitingProceedReadingIdle
Key Insights - 2 Insights
Why does the CPU waste time in Programmed I/O?
Because it keeps checking device status repeatedly (see execution_table steps 1 and 2), it cannot do other work until device is ready.
How does Interrupt-driven I/O improve CPU efficiency?
CPU does other tasks and only stops when device sends an interrupt signal, avoiding constant checking (not shown in programmed I/O table but explained in concept_flow).
Visual Quiz - 3 Questions
Test your understanding
In the execution_table, what is the CPU state at step 2?
AReading
BWaiting
CIdle
DProceed
💡 Hint
Look at the 'CPU State' column in execution_table row for step 2.
At which step does the device become ready according to the execution_table?
AStep 3
BStep 4
CStep 1
DStep 5
💡 Hint
Check the 'Device Status Check' column to find when status changes to 'Ready'.
If the device never becomes ready, what happens to the CPU in Programmed I/O?
ACPU switches to other tasks automatically
BCPU shuts down
CCPU continues waiting indefinitely
DCPU reads data anyway
💡 Hint
Refer to execution_table steps 1 and 2 where CPU waits while device is not ready.
Concept Snapshot
Programmed I/O: CPU waits and checks device status in a loop, blocking other tasks.
Interrupt-driven I/O: CPU does other work and responds only when device sends an interrupt.
Programmed I/O wastes CPU time; interrupt-driven I/O improves efficiency.
Interrupts signal CPU to handle I/O asynchronously.
Use programmed I/O for simple devices; interrupts for multitasking systems.
Full Transcript
This visual execution compares Programmed I/O and Interrupt-driven I/O. Programmed I/O makes the CPU wait actively by checking device status repeatedly until the device is ready, shown in the execution table steps 1 to 3. The CPU state remains waiting until the device signals readiness, then it reads data. Interrupt-driven I/O lets the CPU do other work and only stop when the device sends an interrupt signal, improving efficiency. The variable tracker shows device status and CPU state changes over time. Key moments clarify why programmed I/O wastes CPU time and how interrupts help. The quiz tests understanding of CPU states and device readiness during execution.

Practice

(1/5)
1. Which of the following best describes programmed I/O?
easy
A. CPU ignores the device until a scheduled time
B. Device sends a signal to CPU only when it needs attention
C. CPU and device communicate using direct memory access
D. CPU continuously checks the device status until it is ready

Solution

  1. Step 1: Understand programmed I/O behavior

    Programmed I/O means the CPU actively checks the device repeatedly to see if it is ready.
  2. Step 2: Compare options with definition

    CPU continuously checks the device status until it is ready matches this behavior exactly, while others describe interrupt or other methods.
  3. Final Answer:

    CPU continuously checks the device status until it is ready -> Option D
  4. Quick Check:

    Programmed I/O = CPU polls device [OK]
Hint: Programmed I/O means CPU keeps checking device status [OK]
Common Mistakes:
  • Confusing programmed I/O with interrupt-driven I/O
  • Thinking device signals CPU in programmed I/O
  • Mixing up direct memory access with programmed I/O
2. Which of the following is the correct statement about interrupt-driven I/O?
easy
A. Device interrupts CPU only when it needs service
B. CPU waits in a loop checking device status
C. CPU ignores device signals completely
D. CPU uses programmed polling to check device

Solution

  1. Step 1: Recall interrupt-driven I/O definition

    Interrupt-driven I/O means the device sends a signal (interrupt) to the CPU when it needs attention.
  2. Step 2: Match options to definition

    Device interrupts CPU only when it needs service correctly states that the device interrupts the CPU only when service is needed.
  3. Final Answer:

    Device interrupts CPU only when it needs service -> Option A
  4. Quick Check:

    Interrupt-driven I/O = device signals CPU [OK]
Hint: Interrupt-driven means device signals CPU when ready [OK]
Common Mistakes:
  • Choosing options describing CPU polling
  • Assuming CPU ignores device signals
  • Confusing programmed I/O with interrupt-driven I/O
3. Consider this scenario: A CPU uses programmed I/O to read data from a device. What is the main effect on CPU usage?
medium
A. CPU can perform other tasks while waiting for device
B. CPU is busy checking device status and cannot do other work
C. CPU ignores the device until data is ready
D. CPU receives an interrupt when device is ready

Solution

  1. Step 1: Understand CPU behavior in programmed I/O

    In programmed I/O, CPU repeatedly checks device status, which keeps it busy and unable to do other tasks efficiently.
  2. Step 2: Analyze options for CPU usage

    CPU is busy checking device status and cannot do other work correctly states CPU is busy polling and cannot perform other work effectively.
  3. Final Answer:

    CPU is busy checking device status and cannot do other work -> Option B
  4. Quick Check:

    Programmed I/O = CPU busy polling device [OK]
Hint: Programmed I/O keeps CPU busy waiting, no multitasking [OK]
Common Mistakes:
  • Thinking CPU can multitask during programmed I/O
  • Confusing interrupt-driven I/O effects with programmed I/O
  • Assuming CPU ignores device in programmed I/O
4. A system uses interrupt-driven I/O but the CPU never responds to device interrupts. What is the likely problem?
medium
A. Interrupts are disabled or masked in the CPU
B. CPU is using programmed I/O instead
C. Device is not sending any interrupts
D. CPU is stuck in a loop polling the device

Solution

  1. Step 1: Identify why CPU ignores interrupts

    If CPU never responds to interrupts, a common cause is that interrupts are disabled or masked, preventing CPU from handling them.
  2. Step 2: Evaluate other options

    Interrupts are disabled or masked in the CPU correctly identifies this cause. Other options either contradict the interrupt-driven setup or describe different issues.
  3. Final Answer:

    Interrupts are disabled or masked in the CPU -> Option A
  4. Quick Check:

    CPU ignoring interrupts = interrupts disabled [OK]
Hint: CPU ignoring interrupts usually means interrupts are disabled [OK]
Common Mistakes:
  • Assuming device is not sending interrupts
  • Confusing programmed I/O with interrupt-driven I/O
  • Thinking CPU polls device in interrupt-driven mode
5. A system designer wants to maximize CPU efficiency while handling multiple I/O devices. Which approach is best and why?
hard
A. Use programmed I/O because CPU controls all device checks
B. Use programmed I/O with longer polling intervals to reduce CPU load
C. Use interrupt-driven I/O so CPU works on other tasks until interrupted
D. Use neither; rely on manual device checks by the user

Solution

  1. Step 1: Analyze CPU efficiency needs

    Maximizing CPU efficiency means CPU should not waste time waiting or polling devices unnecessarily.
  2. Step 2: Compare I/O methods for efficiency

    Interrupt-driven I/O allows CPU to do other work and only respond when device signals, improving efficiency.
  3. Step 3: Evaluate other options

    Programmed I/O wastes CPU cycles; manual checks are impractical. Longer polling reduces load but still wastes CPU time.
  4. Final Answer:

    Use interrupt-driven I/O so CPU works on other tasks until interrupted -> Option C
  5. Quick Check:

    Interrupt-driven I/O maximizes CPU efficiency [OK]
Hint: Interrupt-driven I/O lets CPU multitask efficiently [OK]
Common Mistakes:
  • Choosing programmed I/O for efficiency
  • Ignoring CPU multitasking benefits
  • Thinking manual checks improve performance
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard