A keyboard connected to a computer is used at a rate of 1 keystroke per…
2023
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 T1 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 T2 denote the fraction of a second spent in servicing the interrupt and processing a keystroke.
The ratio T1/T2 is . (Rounded off to one decimal place)
Attempted by 81 students.
Show answer & explanation
Correct answer: 10.2
Compute T1 (polling): determine the time spent per second on polling and on processing the detected keystroke.
Polls occur every 10 ms → 1/0.01 = 100 polls per second.
Each poll costs 100 μs = 100×10⁻⁶ s, so polling time per second = 100 × 100×10⁻⁶ = 0.01 s.
Processing after a detected key press costs 200 μs = 0.0002 s. With 1 keystroke/s this adds 0.0002 s.
So T1 = 0.01 + 0.0002 = 0.0102 s (fraction of a second).
Compute T2 (interrupts): each keystroke raises an interrupt that takes 1 ms = 0.001 s to service and process.
With 1 keystroke/s, T2 = 0.001 s.
Ratio T1/T2: T1/T2 = 0.0102 / 0.001 = 10.2. Rounded to one decimal place: 10.2.