Evrim Öztamur
Evrim Öztamur

Reputation: 47

How often do operating systems poll key inputs?

Is it at each screen refresh or exactly when keys are pressed (through interrupts etc.)?

Upvotes: 0

Views: 168

Answers (2)

user3344003
user3344003

Reputation: 21627

That largely depends on the device. There were effectively three generations of devices:

  1. Polling

  2. Character interrupts. Each key press generates an input.

  3. Programmed interrupts. The device is configurable so that it only generates an interrupt when necessary. For example, some terminal devices support programming such that the user can enter a string of characters (and even edit those characters) and there is only an interrupt when the user hits <RETURN>.

Upvotes: 2

Martin James
Martin James

Reputation: 24867

On all non-trivial systems, I/O events are signaled by hardware interrupts that cause drivers to be run. No polling is required or desired.

Any thread waiting on KB input will be made ready, and hopefully running, when the KB driver exits. It can then handle the KB event.

Upvotes: 0

Related Questions