# How to create a reliable event loop in Julia (few ms)?

**URL:** https://discourse.julialang.org/t/how-to-create-a-reliable-event-loop-in-julia-few-ms/133153
**Category:** General Usage
**Created:** [October 14, 2025, 8:02pm UTC](https://discourse.julialang.org/t/how-to-create-a-reliable-event-loop-in-julia-few-ms/133153 "2025-10-14T20:02:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mj2984](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mj2984/32/43833_2.png) [@mj2984](https://discourse.julialang.org/u/mj2984)
#### Post date: [October 14, 2025, 8:02pm UTC](https://discourse.julialang.org/t/how-to-create-a-reliable-event-loop-in-julia-few-ms/133153/1 "2025-10-14T20:02:14Z")

</div>

Hi,

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.

Thanks and Regards,  
Jenkin.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [October 14, 2025, 8:13pm UTC](https://discourse.julialang.org/t/how-to-create-a-reliable-event-loop-in-julia-few-ms/133153/2 "2025-10-14T20:13:58Z")

</div>

Hardware interrupts are currently not supported by Julia, even though there was some effort to allow this, see for example: [https://github.com/JuliaLang/julia/pull/49541](https://github.com/JuliaLang/julia/pull/49541)

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.

---

<div class="post-metadata">

### Author: ![mj2984](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mj2984/32/43833_2.png) [@mj2984](https://discourse.julialang.org/u/mj2984)
#### Post date: [October 14, 2025, 8:28pm UTC](https://discourse.julialang.org/t/how-to-create-a-reliable-event-loop-in-julia-few-ms/133153/3 "2025-10-14T20:28:40Z")

</div>

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.
