Chevalier Tech interview question

Explain the use of the volatile data type?

Interview Answer

Anonymous

26 May 2026

Volatile is used when a data object might be accessed by more than 1 thread, or by a thread and one or more interrupts. It does this by ensuring any data access is via main memory, so that the cache cannot become inconsistent. In embedded systems it is typically used as a mechanism for an interrupt to signal that a timer, or external event, requires attention - e.g. a receive buffer has new data.