Should there be an interrupt handler?

I use a static variable inside the interrupt handler, making the interrupt handler non-tolerant.

  • Is it possible to have an interrupt handler without a reentrant?
  • When a hardware interrupt raises, does an event occur in some queue and is waiting for the current interrupt handler to complete or is the interrupt handler called immediately?

thanks

PS. I am using Linux. The programming language I use is C, if that matters.

+4
source share
2 answers

The short answer is that interrupt service routines are not inherently required to be reentrant. Reentrancy is only required for nested interrupts . If the operating system you are using does not support nested interrupts , you do not need to worry about reinstalling at all. If so, you may have control over the interrupt that you are servicing so you never get a nested interrupt.

EDIT: Now that I know that you are using Linux, you may find this link useful: Can the interrupt handler be unloaded with the same interrupt handler?

Essentially, the answer to your question is that Linux masks the interrupt when it is asserted so that it does not preempt itself unless a certain flag was accepted during ISR registration.

Here's the corresponding quote:

Linux interrupt handlers do not have to be reentrant. When this interrupt handler is executed, the corresponding interrupt line is masked on all processors, preventing another interrupt on the same line from the received one. Usually all other interrupts are enabled, so other interrupts are serviced, but the current line is always disabled. Therefore, the same interrupt handler is never called to simultaneously service a nested interrupt. This greatly simplifies writing an interrupt handler.

+7
source

It is impossible to speak for all interrupt handlers, but on dozens of platforms I wrote a hardware interrupt service (ISR), the mechanics were such as to prevent reentry behavior everywhere.

ISRs for software interrupts, on the other hand, out of 2 that I wrote, were specifically designed to detect and handle reentry activity.

As already mentioned, it most likely depends on the OS / platform.

0
source

Source: https://habr.com/ru/post/1496013/


All Articles