Skip to content
Adaptive AgroTech NetworkUniversity of Southern Denmark · SDU Drone Center
Cover for Why Is Volatile Not Enough for Interrupt-Shared Data?

Video by Adaptive AgroTech. If the embedded player is unavailable, open the original video ↗.

Why Is Volatile Not Enough for Interrupt-Shared Data?

A volatile qualifier makes the compiler perform accesses to a shared variable.

Understand the concept

The key idea

A volatile qualifier makes the compiler perform accesses to a shared variable. An interrupt can still occur partway through a multi-instruction update.

What to remember

  • Distinguish visibility from atomicity
  • Choose synchronization suited to the processor and data width
Pause & think

Check your understanding

Can an interrupt interrupt a volatile counter increment?

Show the explanation

Yes. A read, addition and write can be separate instructions.