3 ms·
Ideally, an IR should just collect whatever information is necessary for the main thread to actually handle the routine. Compare this to raising and handling an
by nothrabannosir 9y ago
Ideally, an IR should just collect whatever information is necessary for the main thread to actually handle the routine. Compare this to raising and handling an event in e.g. javascript: the event payload is handled by the main thread, the IR would just be responsible for creating that event payload object. (this is a horrible comparison, to be honest)
The problem with IRs is they put the processor in a very fragile state. Different chips handle e.g. stacked interrupts (an interrupt which occurs while another interrupt was being handled) differently, but no matter how they do it, you won't like it. Sometimes it turns off certain types of memory access protection, or other important (hardware) peripherals which might be ignored (because they, themselves, operate using those same interrupts under the hood); it's all madness.
Hence the interrupt just puts together some event data, sets some flag, and the main event loop can handle it when the time is there.