Electronic – the danger of using interrupt pre-emption in ARM

arminterrupts

I am working on a system which uses about 4 interrupts. I can clearly define a priority from one to the other. For example, I feed SPI transfers with DMA requests and operate a USB interface which drives the SPI data. To this end I have prioritized my interrupts as follows (ordered from highest to lowest priority)

  1. Systick
  2. EXTI for handshaking signals
  3. DMA streams
  4. USB

Everything works great for a while and then I start seeing some odd behavior that I have not been able to determine the cause of yet, but I am wondering/suspecting if its because I am allowing interrupts to pre-empt other ones at inopportune times.

So my question is, what sorts of issues should be considered when deciding if an interrupt should preempt another, or if it should just be given a high enough priority to tail-chain.

Best Answer

In general, interrupt preemption may cause deadlocking problems: if an interruption waits on a resource that is locked/in use by another lower priority interruption, you program may stall.

Also, a higher priority interruption may well interrupt a task which should not be interrupted if not properly protected (critical sections). When not using interrupt preemption, disabling interrupts on a given level disables all interruptions. When nesting, you may have higher priority interruptions breaking code from lower priority interruptions/code in unexpected ways.

Frankly, unless you really need to prioritize a process over another, it is useless to mess with that. Since you look like your are only chaining interdependent processes, i would only call this asking for trouble.