130. RAII

Question.1

A developer creates a scoped interrupt lock:

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

void write_flash() {
   IntGuard lock;
   // Critical section: interrupts disabled
   flash_write(addr, data);
   if (verify_failed) return;  // Early exit
   update_checksum();
}

Are interrupts re-enabled on the early return?

Need Help? Refer to the Quick Guide below

Select Answer