I am trying to create an event loop that ideally does something based on a hardware interrupt (like VSync) but I would also like a software equivalent that simulates the hardware interrupt so I could replicate the same behavior. What are some ways to do this? The time resolution I’m looking for is of the order of 100Hz or so. I have multiple threads to spare so it’s fine if I have to lock one thread for this, but the interrupt has to be consumed by other threads to do their tasks.
Curious how the whole system would even work in this place. Any MWE could be helpful.
So you will need some external (C/C++) library to handle the interrupt and to trigger a Julia task based on it.
Another issue is that the Julia garbage collector can cause large delays (10-200ms). One way to avoid this is to write code that doesn’t allocate. Which is possible, but challenging.
I have a C library that does handle the interrupts that acts as a blocking call until the interrupt is received and wrapped the function in Julia. So the task with the hardware interrupt is like
while true
get_interrupt(interrupt_source)
do_something
end
The do something should be launched in a different thread so that it can function while I look for the next interrupt. Ideally, I am looking for some reactivity to an interrupt.
And for software interrupt,
I should have something that mimics generating these interrupt signals at similar time intervals and use the same function. I could potentially do this also as a C library and wrap it (unsure what libraries to use). Is it possible to do this part in Julia.