OS Primitives: Interrupt Handling#
IRQs And ISRs#
Interrupt service routine (ISR): callback
void(int irqnum)Attached to an Interrupt request (IRQ)
irqnumCalled asynchronously (run at the most inopportune time)
IRQ should safely be considered parallel (though varies per architecture)
#include <why-irq.h>
#include <why-time.h>
#include <print>
int main()
{
Why::init();
auto isr = [](int irqnum){
std::println("seeing interrupt #{}", irqnum);
};
Why::IRQ::connect(2, isr); // <-- activate ISR
Why::pause(); // <-- main loop
return 0;
}
In
why-shell#> irq 2
seeing interrupt #2
>