2 ms·
>Some of the things that you need to do in embedded device code, like handling IRQs, don’t seem to really be accounted for in any language I know of (at least n
by mikewarot 4y ago
>Some of the things that you need to do in embedded device code, like handling IRQs, don’t seem to really be accounted for in any language I know of (at least not in a simple or elegant way).
That's because there's a lot of details to be managed to set up an interrupt handler, and reprogram the hardware to enable the interrupt to even happen. Interrupt code has to preserve the entire CPU state, and have no unknown side effects, or the machine will become unstable. There's a lot to manage.
Cooperative multitasking has far fewer restrictions, I did it in Turbo Pascal back in the MS-DOS days... it was just a matter of allocating space on the heap, and copying the entire stack... the hardest part was figuring out that it was actually working as designed when fork() returned twice.
The C++ IDE supporting Arduino seems to have a pretty good set of interrupt handling basics, it might be worth implementing something like that for your system.