GATE 2023 CS – Question 34
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 μs (micro seconds) for each poll. If it is determined after polling that a key has been pressed, the system consumes an additional 200 μs to process the keystroke. Let $T_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 $T_2$ denote the fraction of a second spent in servicing the interrupt and processing a keystroke. The ratio $T_1/T_2$ is ______. (Rounded off to one decimal place)
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: 10.2
Explanation
**Polling.** The keyboard is polled every 10 ms, i.e. $\dfrac{1\text{ s}}{10\text{ ms}}=100$ times per second. Each poll costs $100\ \mu s$:
$$100\times100\ \mu s=10\text{ ms}.$$
One keystroke per second also costs $200\ \mu s=0.2$ ms of processing. So
$$T_1=10+0.2=10.2\text{ ms per second}.$$
**Interrupt.** One interrupt per keystroke costs 1 ms: $T_2=1$ ms per second.
$$\frac{T_1}{T_2}=\frac{10.2}{1}=\mathbf{10.2}.$$