What do the terms "asynchronous" and "synchronous" mean, with respect to the definition of an interrupt?
Quoted from http://en.wikipedia.org/wiki/Interrupt:
an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution.
I was wondering what "asynchronous" and "synchronous" mean?
When that Wikipedia article mentions an asynchronous interrupt, they are using the classical clocked vs. non-clocked definition of (a)synchronous, which applies to a digital circuit.
A digital circuit is said to be synchronous when every part of the logic is connected to a common clock (like in your CPU). At the rise or fall of every clock cycle, the state of the circuit is updated. An asynchronous digital circuit, on the other hand, is not clocked, but rather the next state is dependent on the current one (and will switch as soon as it can). Reading logic from other circuits that don't share the same common clock can also be defined as asynchronous, but with respect to the other circuit.
If an asynchronous interrupt is triggered, it means that the processor will (most likely at the next clock cycle) save its current executing environment, and service the interrupt request. This is an example of a hardware interrupt (one that is triggered by an external connection to the processor). All software interrupts, as mentioned in the article, are technically synchronous, since they are initiated by the CPU itself - which is a synchronous circuit.
Since no external devices share the same common clock as the CPU, all external interrupts can be said to be asynchronous. Even though the device that triggered the interrupt may be a synchronous circuit, from the CPU's point-of-view, those interrupts are triggered asynchronously (since it is not sharing a common clock signal with the device).
The actual external interrupt signal itself is asynchronous, but all CPU interrupt handlers are synchronous, they will only detect an interrupt on the next clock tick, since that's the point of a synchronous system (to only allow the system's state to change together). If you're curious as to how a processor handles interrupts, see this great resource from Intel (specifically, Volume 3, Part 1).
From the Etymology Dictionary for Synchronous
,
1660s, "existing or happening at the same time,"
from L.L. synchronus "simultaneous,"
from Gk. synchronos "happening at the same time,"
from syn- "together" + khronos "time."
Meaning "recurring at the same successive instants of time" is attested from 1670
asynchronous
means "not synchronous".
Now you read all that in the context of interrupts
again.
The asynchronous interrupt would be not directly related to the activity at hands -- think of it like, you are reading this and suddenly you hear a noise behind you; you turn around -- that is because you were asynchronously interrupted to do so :-)
Now, if you are reading the wikipedia page for interrupts, and you see the word asynchronous
, you look it up (as above) -- that is a synchronous interrupt in your flow of thought; the cause of this interrupt was what you read -- as a result, you stopped reading, looked up the word, and eventually came back to reading this.
Basically, it is a way to get the attention of the kernel or a program.
An example: Lets say i have a program download a file. I want my program to still be responsive while the file is downloading and I need to tell my program that I am done. In the meantime however, my program should continue doing whatever it wants, until it is ** interrupted** by the completion of a downloaded file. It then does whatever it needs to do. It in asynchronous because it will not happen at a predefined time or in a predefined order.
Sync means you expected it to happen next. Async means you didn't know when or if it would happen.