100. Constructors-II

Question.2

A developer uses a constructor to acquire an interrupt lock:

class InterruptGuard {
public:
   InterruptGuard() { __disable_irq(); }
   ~InterruptGuard() { __enable_irq(); }
};

void critical_section() {
   InterruptGuard guard;
   // Interrupts disabled here
   if (error) return;  // Early return
   process();
}

Are interrupts re-enabled on the early return?

Need Help? Refer to the Quick Guide below

Select Answer