Question

A keyboard connected to a computer is used at a rate of 1 keystroke per second. The computer system polls the keyboard every 10 ms (milli seconds) to check for a keystroke and consumes 100 μ\mus (micro seconds) for each poll. If it is determined after polling that a key has been pressed, the system consumes an additional 200 μ\mus to process the keystroke. Let T1T_1 denote the fraction of a second spent in polling and processing a keystroke.

In an alternative implementation, the system uses interrupts instead of polling. An interrupt is raised for every keystroke. It takes a total of 1 ms for servicing an interrupt and processing a keystroke. Let T2T_2 denote the fraction of a second spent in servicing the interrupt and processing a keystroke.

The ratio T1T2\frac{T_1}{T_2} is _______. (Rounded off to one decimal place)

Official answer and solution
Official answer
10.2
From
Official GATE 2023 answer key

Solution

Compute the time fractions T1T_1 (polling overhead) and T2T_2 (interrupt overhead) per second and take their ratio.

  1. Polling Mode (T1T_1):

    • Polling frequency: every 10 ms=0.01 s10\text{ ms} = 0.01\text{ s}, which is 1000/10=1001000 / 10 = 100 polls per second.
    • Polling check cost: 100×100 μs=10 000 μs=10 ms100 \times 100\,\mu\text{s} = 10\,000\,\mu\text{s} = 10\text{ ms}.
    • Keystroke processing: 1 keystroke per second adds 200 μs=0.2 ms200\,\mu\text{s} = 0.2\text{ ms}.
    • Total time spent in 1 second: T1=10 ms+0.2 ms=10.2 ms=0.0102 sT_1 = 10\text{ ms} + 0.2\text{ ms} = 10.2\text{ ms} = 0.0102\text{ s}.
  2. Interrupt Mode (T2T_2):

    • 1 keystroke per second generates 1 interrupt.
    • Total time to service interrupt and process keystroke is 1 ms=0.001 s1\text{ ms} = 0.001\text{ s}.
    • Total time spent in 1 second: T2=1 ms=0.001 sT_2 = 1\text{ ms} = 0.001\text{ s}.
  3. Ratio:

    T1T2=10.2 ms1 ms=10.2\frac{T_1}{T_2} = \frac{10.2\text{ ms}}{1\text{ ms}} = 10.2
Final answer

10.2

Common trap

Forgetting the 200 μs200\,\mu\text{s} keystroke processing time in the polling implementation, which would erroneously give 10.010.0.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2023 Computer Science and Information Technology (CS)
Question
34 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.