Question:

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: Aug 26, 2025
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Step 1: Polling implementation (T1)
- Polling frequency = once every \(10\,\text{ms}\).
- In 1 second = \(\tfrac{1}{0.01} = 100\) polls.
- Each poll consumes \(100 \mu s = 0.0001 \,\text{s}\).
- Total polling overhead in 1 second = \(100 \times 0.0001 = 0.01 \,\text{s}\).
- Additionally, when a key is pressed (once per second), extra \(200 \mu s = 0.0002 \,\text{s}\) is used.
- Total time spent = \(0.01 + 0.0002 = 0.0102 \,\text{s}\).
- Thus, \(T_1 = 0.0102\).
Step 2: Interrupt implementation (T2)
- For each keystroke, interrupt servicing + processing = \(1 \,\text{ms} = 0.001 \,\text{s}\).
- Since keystroke rate = 1 per second, total fraction per second = \(0.001\).
- Thus, \(T_2 = 0.001\).
Step 3: Ratio
\[ \frac{T_1}{T_2} = \frac{0.0102}{0.001} = 10.2 \] \[ \boxed{10.2} \]
Was this answer helpful?
0
0

Questions Asked in GATE CS exam

View More Questions