Gem #14: Interrupt Handling Idioms (Part 2) Author: Pat Rogers, AdaCore Abstract: Ada Gem #14 There are two design idioms commonly used when handling interrupts with Ada. One has more of the characteristics associated with good software engineering, the other somewhat better performance. We explore these two idioms in this gem. Let s get started ¦ Last week we introduced this topic and explored the first of the two designs. The gist of it is that we want to implement a multi-level response to interrupts, in which a protected procedure implements the first-level handler and a task implements the secondary level handling outside of the interrupt context. We use serial communications over a UART (Universal Asynchronous Receiver Transmitter) as the example. In both designs we encapsulate the two levels of the interrupt handling code inside the body of a package named Message_Processor. Second Design Idiom The second idiom is similar to the first, in that a protected object encapsulates the interrupt handling procedure, but this second design uses a Suspension_Object, instead of a protected entry, to signal the task. The type Suspension_Object is declared within package Ada.Synchronous_Task_Control and is essentially a boolean flag with synchronization. A single
/lp/association-for-computing-machinery/gem-14-interrupt-handling-idioms-part-2-EnKaP9kSFy