3 ms·
Not the OP, and I have never done embedded programming, but you got me hooked with the sentence "passing along the marker" and my search engine skills sadly fai
by Lukas_Skywalker 9y ago
Not the OP, and I have never done embedded programming, but you got me hooked with the sentence "passing along the marker" and my search engine skills sadly failed me. Do you mean the preferred way is to do the actual work in the main routine and only set a marker that the work should be triggered in the IR?
- nothrabannosir 9y agoIdeally, 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.