Question Details

No question body available.

Tags

c embedded interrupt volatile

Answers (1)

June 19, 2026 Score: 2 Rep: 72,859 Quality: Low Completeness: 70%

To ensure a flag is read directly from its permanent storage location (RAM) rather than a CPU register, you must use the volatile keyword to inform the compiler. However, keep in mind that volatile only prevents compiler caching optimizations. It does not provide:

  • Cache coherency (between different CPU cores)

  • Memory ordering (preventing read-read or write-write reordering)

  • Atomicity (ensuring uninterrupted read/write operations)