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