1. Gyanastra
  2. Computer Organisation and Architecture
  3. I/O Interface and Interrupts
  4. MIPS and CPU Speed vs Slow I/O Devices
Free lesson, no account needed 6 min read 2 practice questions after it
Asked in past papers2 times
  • ISRO2013
  • UGC NET2015

Computer Organisation and Architecture · I/O Interface and Interrupts

MIPS and CPU Speed vs Slow I/O Devices

Overview

The CPU executes millions of instructions per second, while I/O devices such as a keyboard supply data at only a few characters per second.
Under programmed I/O the CPU polls the device's status flag in a loop, so almost all of its execution capability is spent waiting rather than doing useful work.

Key concepts

  • MIPS (Million Instructions Per Second): a measure of CPU speed — the number of instructions the CPU can execute in one second, expressed in millions. Executing 10610^6 instructions per second is 1 MIPS.
  • Speed mismatch problem: the CPU is extremely fast but I/O devices are very slow; this mismatch holds for most devices. A program that makes the CPU wait for a slow device wastes almost all of the CPU's capability.
  • Busy waiting: continuously checking the status flag in a loop. The CPU does no useful work; it simply checks the flag again and again. (The term also appears in Operating Systems.)
  • Programmed I/O: the polling approach in which the CPU repeatedly checks the device status; its main disadvantage is the massive waste of CPU time when devices are slow.

How it works

The programmed I/O loop that reads one character from the keyboard into the input register consists of three instructions:

  1. Read/check the status flag (is input ready?).
  2. Branch back to step 1 if the flag is not set (loop).
  3. Move the character from the input register into the ALU (the actual data transfer).

Reasoning:

  1. The CPU can execute 10610^6 instructions per second (1 MIPS).
  2. Each execution of the "move input to ALU" instruction transfers exactly one character.
  3. So in one second the CPU has the capacity to read 10610^6 characters (1 million characters per second).
  4. But the input is typed by a human at only 10 characters per second.
  5. In the time the CPU could have executed 10610^6 instructions (read 10610^6 characters), it actually reads only 10 characters; the rest of the time is spent waiting.
  6. After each character arrives, the flag is set to 1. At 10 characters per second, one character arrives every 0.1 second.
  7. During that 0.1 second the CPU keeps checking the flag continuously — it repeatedly executes the check and branch instructions.
  8. In 0.1 second the CPU could execute 10510^5 instructions, and all of them are just the two loop instructions (check flag, branch).
    So out of every 10510^5 instructions, only one word is actually transferred; the remaining instructions are wasted.
  9. To transfer just one word, the CPU executes 10510^5 instructions: the check-flag instruction 105/210^5/2 times and the branch instruction 105/210^5/2 times. Only then is one input moved.
Figure. At 1 MIPS the CPU can execute 10^5 instructions in the 0.1 second between keystrokes. All of them are check-flag and branch loop instructions, so only one word is actually transferred.

Formulas

  • Instructions per second == clock rate // CPI (standard relation; the result is stated directly as 10610^6 instructions/second)

MIPS=instructions per second106\text{MIPS} = \frac{\text{instructions per second}}{10^6}

time per character=1characters per second\text{time per character} = \frac{1}{\text{characters per second}}

instructions executed while waiting=(instructions per second)×(time per character)\text{instructions executed while waiting} = (\text{instructions per second}) \times (\text{time per character})

wasted instructions per word=(instructions executed while waiting)−(instructions needed for the transfer)\text{wasted instructions per word} = (\text{instructions executed while waiting}) - (\text{instructions needed for the transfer})

  • Symbols:
  • characters per second — rate at which the I/O device supplies input
  • time per character — interval between two successive inputs
  • instructions per second — CPU execution capability

Worked examples

CPU capability vs keyboard input rate

Given:

  • CPU speed =106= 10^6 instructions per second =1= 1 MIPS
  • Each input instruction reads 1 character
  • Keyboard input rate =10= 10 characters per second

Step 1 — CPU capacity in characters per second: 106 instructions/second×1 character/instruction=106 characters/second=110^6 \text{ instructions/second} \times 1 \text{ character/instruction} = 10^6 \text{ characters/second} = 1 million characters/second.

Step 2 — Time to receive one character: 1/10 characters per second=0.11 / 10 \text{ characters per second} = 0.1 second. 0.1 s=1050.1 \text{ s} = 10^5 microseconds (since 0.1×106 μs=105 μs0.1 \times 10^6\ \mu s = 10^5\ \mu s; equivalently 105×10−610^5 \times 10^{-6} s).

Step 3 — Instructions the CPU could execute in that 0.1 second: 106 instructions/second×0.1 second=10510^6 \text{ instructions/second} \times 0.1 \text{ second} = 10^5 instructions.

Step 4 — What those 10510^5 instructions actually are: All of them are the two loop instructions (check flag, branch):

  • Check-flag instruction executed 105/210^5/2 times
  • Branch instruction executed 105/210^5/2 times
  • Only then is 1 word (1 character) moved into the ALU.

Step 5 — Conclusion: Out of every 10510^5 instructions, only one word is transferred; the rest are wasted. The CPU is busy waiting, not doing useful work.

Comparison

AspectCPUI/O device (keyboard)
Speed10610^6 instructions/second (1 MIPS)10 characters/second
Capacity per second10610^6 characters10 characters
Time per unit1 µs per instruction0.1 s per character
Utilisation during transferAlmost fully wasted in the polling loopWorking at its own slow rate

Revision summary

  • MIPS = million instructions per second; 10610^6 instructions/second = 1 MIPS.
  • One input instruction transfers one character, so the CPU's read capacity equals its instruction rate (10610^6 characters/second here).
  • A slow device (10 characters/second) forces the CPU to wait 0.1 second per character.
  • In 0.1 second the CPU executes 10510^5 instructions, all of them check-flag and branch loop instructions — only one word is transferred.
  • Continuously checking the flag is busy waiting: the CPU does no useful work.
  • The check-flag instruction runs 105/210^5/2 times and the branch instruction 105/210^5/2 times for every single word transferred.
  • Programmed I/O's main disadvantage is the massive waste of CPU time when devices are slow.

Previous-year exam insights

  • MIPS = clock rate / (CPI x 10610^{6});
    equivalently execution time = instruction count x CPI / clock rate.
    MIPS alone is not a reliable speed measure because it ignores instruction mix and CPI differences.
    Asked inUGC NET 2015
  • For DMA/block transfer, the maximum transfer rate is limited by the fraction of memory-bus (or CPU) cycles available to the device: transfer rate = (bus cycles per second available to I/O) x (bytes per cycle).
    Cycles used by the CPU for instruction fetch/execute are unavailable to the device.
    Asked inUGC NET 2015
  • In programmed I/O the CPU polls the status flag;
    the fraction of CPU time wasted is (time spent polling)/(time per character), and useful CPU utilisation = transfer instruction time / total time per character.
  • Interrupt-driven I/O removes busy waiting: the CPU does useful work until the device raises an interrupt, then services it; DMA further removes per-word CPU involvement by transferring blocks directly between device and memory.
  • Average machine cycles per instruction and the fraction of cycles using the memory bus determine effective memory bandwidth: memory accesses per second = (instructions per second) x (cycles per instruction) x (fraction of cycles that are memory cycles).
    Asked inUGC NET 2015
  • 1 MIPS means 10610^{6} instructions per second;
    time per instruction = 1 µs at 1 MIPS. Convert rates carefully: 1 byte/s = 8 bits/s, and K=103,M=106K = 10^{3}, M = 10^{6} in these rate problems.
Pages 1–2 of 2