How to share mutable data with an interrupt handler not running into a deadlock?

Hi there,

I'm on embedded system development and do have a function to register handler functions for an interrupt. But this registered list of handlers need to be mutable accessible within the interrupt handler to be able to remove it once it has been called. But using Mutex inside the IRQ handler could easily lead to deadlocks. What would be a good approach/solution to this requirement?

Thanks in advance for any hints.

Use atomic pointers for the interrupt handler pointers?

But in general adding and removing interrupt handlers dynamically seems like a dubious design, probably better to have a static list and have dispatch logic in the handlers if necessary.

thanks for the hint. The thing is I‘d like to utilize a timer interrupt to enable timed execution of scheduled functions as one of my scenarios. In this case I’d need to be able to add a function to be executed with specific delay to a lis and this list would be reduced by the already called functions at their point in time.
My current thoughts go into the direction that this list is only mutablem outside the interrupt handler and I’m using an AtomicUsize to set the offset into the list where execution has already happened, but thought that their might be better solutions possible?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.