Question:medium

A keyboard connected to a computer is used at a rate of 1 keystroke per second. The computer polls the keyboard every 10 ms, each poll takes 100 \(\mu s\). If a key is detected, an additional 200 \(\mu s\) is used for processing. Let \(T_1\) be the fraction of a second spent in polling and processing a keystroke. In an alternative implementation with interrupts, each keystroke requires 1 ms to service and process. Let \(T_2\) be the fraction of a second in the interrupt method. Find the ratio \(T_1/T_2\).

Show Hint

Polling wastes CPU time because it repeatedly checks the device even when idle, while interrupts only use CPU when actual input arrives. This is why interrupt-driven I/O is far more efficient in practice.
Updated On: Feb 3, 2026
Show Solution

Solution and Explanation

Step 1: Compute CPU time used by polling in one second

The device is checked every 10 ms.
So, number of checks per second:

1 / 0.01 = 100 checks

Each check occupies the CPU for 100 μs.

100 × 100 μs = 10,000 μs = 0.01 s

In addition, one actual key press per second requires extra processing time of 200 μs:

0.01 + 0.0002 = 0.0102 s

Hence, the fraction of CPU time used with polling:

T1 = 0.0102


Step 2: Compute CPU time used by interrupts in one second

With interrupts, CPU time is consumed only when a key is pressed.

Each interrupt handling (including processing) takes 1 ms. Since only one key is pressed per second:

1 ms = 0.001 s

Thus, CPU time fraction used:

T2 = 0.001


Step 3: Compare the two approaches

T1 / T2 = 0.0102 / 0.001 = 10.2


Final Answer:

10.2

Was this answer helpful?
0