Events
We all use keyboards in our everyday work life. We use them to write code and compose e-mails. There is no knowing when a certain key will be pressed. However, when a key is pressed, the user expects certain action to happen—for example, the letter indicated by the key should appear in the editor when we are writing code.
This seems natural enough, doesn't it? However, note that there is an elaborate mechanism at work here. The operating system piece needs to know which key was pressed. So, one way to find this out is to go and ask periodically whether any key was pressed, and if so, which one. This is called "polling" for any interesting information. When we poll, we go and ask the driver, at intervals about any status regarding whether a key was pressed or not, as shown in the following figure:
This polling approach is problematic for the following reasons:
- We really don't know whether the polling interval of a second...