edited by
7,845 views
11 votes
11 votes
A keyboard connected to a computer is used at a rate of $1$ keystroke per second. The computer system polls the keyboard every $10 \mathrm{~ms}$ (milli seconds) to check for a keystroke and consumes $100\; \mu \mathrm{s}$ (micro seconds) for each poll. If it is determined after polling that a key has been pressed, the system consumes an additional $200\; \mu \mathrm{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 \mathrm{~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 $\dfrac{T_{1}}{T_{2}}$ is _____________. (Rounded off to one decimal place)
edited by

2 Answers

24 votes
24 votes

The answer Should be 10.2

1 Keystroke per second.

  1. Polling System (T1)

CPU Polls (ask) keyboard every 10 ms and asks did you get any keystrokes.? Keyboard Answers “Yes” only once per second. 

In One second, the CPU Polls the Keyboard 100 times (1 Sec = 1000 ms, and the CPU polls every 10 ms). 

Time Spent in Polling = 100 * 100microsec = 10000 microseconds or 10 milesec. 

Time Spent in Processing the Keystroke (Only once per second) = 200microsec or 0.2 milisec. 

CPU’s Time wasted in Polling System = Time Spend in Polling + Time Spent in Processing = 10.2 ms

  1. Interrupt System (T2) 

CPU doesn’t ask Keyboard periodically about the keystroke, but Keyboard tells CPU via interrupt about a Keystroke. 

Whenever, there is a keystroke, Keyboard interrupts CPU. CPU Executes corresponding Interrupt Service Routine (ISR) which takes 1ms. Thats all. 

 

Speed Up of Interrupt over polling system (S) = T1/T2 = 10.2 ms / 1 ms = 10.2 

 

Example: 

Let's consider Rubina is personal assistant of Pathaan; Pathaan assigns some tasks to Rubina. Now Pathaan is a very busy man and his every minute is very important.  

Pathaan needs the status of the work that he assigned to Rubina. Pathaan can take the status of the work in two ways: 

  1. Using Polling System 
  2. Using Interrupt System

If Pathaan uses Polling System, Pathaan will keep asking Rubina about the status of the work every 10 ms. 100 microsec of Pathaan are wasted in talking to Rubina, but Rubina answers Yes only once a second, If Rubina answer Yes then Pathaan spends another 200 microsec to review the work done by Rubina. So in this case Pathaan waste 100*100 microsec in talking to Rubina (Because he calls her every 10 ms and spends 100 microsec in talking so in one sec he waste 100*100 Microsec). Rubina completes work only once per second (Means she answers Yes only once out of 100 times that Pathaan asks in 1 sec). If Rubina answer Yes, Pathaan spends another 200 microsec to review the work done by Rubina. So Total time wasted by Pathaan is 10 ms + 0.2 ms. 

 

  1. Better approach will be : Pathaan Assign work to Rubina and sits back and wait for Rubina to tell him work is done. (Rubina Interrupts Pathaan). Rubina interrupts Pathaan once per second and Pathaan spends 1 ms in reviewing the work . (So Lots of time saved of Pathaan)

So, We can say second approach is 10.2 times faster than first approach.

 

Pathaan == CPU

Rubina == Input/Output. 

 

 

8 votes
8 votes

The computer System polls the keyboard after every 10 ms. 

10 ms → 1 poll       [1 ms = 10^(-3) s]

10 * $10^{-3}$ seconds → 1 poll

$10^{-2}$ seconds → 1 poll

1 second → 100 polls.

So, In every second system is conducting polls for 100 times.

For each poll it is consuming 100 microsec. So, for 100 pools it will consumes : 100 * 100 microsec = 10000 microsec.

Now, it is saying that system consumes 200 mircosec to process the keystroke and It is mentioned

in the question that keyboard is type at speed of 1 keystroke/sec, which means it will consume

200 microsec only.

For T1 : Fraction of a second spent in polling and processing a keystroke.

So, T1 = Total Time consumed In polling + TIme consumed In processing of keystroke

= 10000 microsec + 200 microsec = 10200 microsec or 10.2 millisec.

T1 = 10.2 ms.

For T2 : Fraction of a second spent in servicing the interrupt and processing a keystroke.

In alternative implementation system is taking total 1 ms for servicing the interrupt & processing the keystroke.

So, T2 = 1 ms.

Now, T1 / T2 = 10.2 ms / 1 ms = 10.2.

So, Answer will be 10.2.

edited by
Answer:

Related questions

12 votes
12 votes
4 answers
2
5 votes
5 votes
2 answers
4
admin asked Feb 15, 2023
8,526 views
The value of the definite integral \[\int_{-3}^{3} \int_{-2}^{2} \int_{-1}^{1}\left(4 x^{2} y-z^{3}\right) \mathrm{d} z \mathrm{~d} y \mathrm{~d} x\]is _________. (Rounde...