Program Interrupt

Input-Output Programming using Interrupt

🎯 What is Program Interrupt?

Program Interrupt is an alternative method to programmed control for managing input-output (I/O) communication, specifically designed to improve efficiency in computer systems.

Interactive Demonstration

IEN Flag
Disabled
FGI (Input)
Ready
FGO (Output)
Ready
CPU Status
Processing

⚡ The Efficiency Problem

50K
Flag checks per second
100ms
I/O transfer time per character
10
Characters per second
90%
Wasted CPU time

❌ Programmed Control - Polling Method (Inefficient)

The CPU constantly checks a flag bit to determine if an I/O device is ready. This continuous checking wastes valuable processing time since I/O devices are significantly slower than the CPU.

  • Constant flag checking
  • CPU waits idly
  • Wasted processing cycles
  • Poor resource utilization

✅ Program Interrupt (Efficient)

The CPU continues executing other tasks and is only interrupted when the I/O device is ready. This maximizes CPU utilization and system efficiency.

  • Event-driven processing
  • CPU performs other tasks
  • Optimal resource usage
  • Improved system performance

🔧 How Program Interrupt Works

1. Setup

Enable interrupts using ION instruction

2. Normal Execution

CPU executes main program

3. I/O Ready

Device sets flag (FGI/FGO)

4. Interrupt

CPU stops current task

5. Service

Handle I/O operation

🎛️ Key Components

Interrupt Enable Flip-Flop (IEN) +

A special flip-flop that controls whether the computer can be interrupted:


ION - Sets IEN to 1 (enables interrupts)
IOF - Clears IEN to 0 (disables interrupts)

When IEN = 0, all interrupt requests are ignored, giving the programmer full control over when interrupts can occur.

I/O Device Flags +

Special flags that indicate device status:

  • FGI (Flag Input): Set when input device (keyboard) has data ready
  • FGO (Flag Output): Set when output device (printer) is ready to accept data

These flags work in conjunction with IEN to determine when an interrupt should occur.

Interrupt Condition +

An interrupt occurs when:

IEN = 1 AND (FGI = 1 OR FGO = 1)

If IEN = 0, no interrupts can occur regardless of device flags, ensuring the main program has complete control when needed.

💡 Benefits of Program Interrupt

🚀 Improved Efficiency

CPU can perform other useful computations instead of constantly checking I/O flags, leading to better overall system performance.

⚙️ Better Resource Utilization

Maximum utilization of CPU cycles by eliminating idle waiting time during slow I/O operations.

🎯 Event-Driven Processing

Responds immediately to I/O events without wasting time on unnecessary polling operations.

Start Learning Interrupt Service Routine