I recently had an interview with a software company who asked me the following question:

> 
> Can you describe to me what adding *volatile* in front of variables does? Can you explain to me why it's important?
> 
> 
> 

Most of my programming knowledge comes from C, yet the job position is for C# (I thought I might add this bit of info if necessary for the question specifically)

I answered by saying it just lets the ***compiler*** know that the variable can be used across processes or threads, and that it should not use optimization on that variable; as optimizing it can deteriorate behavior. In a nutshell, it's a warning to the compiler.

According to the interviewer, however, it's the other way around, and the volatile keyword warns the ***OS***, not the compiler. 

I was a bit befuddled by this, so I did some research and actually found conflicting answers! Some sources say it's for the compiler, and others for the OS.

Which is it? Does it differ by language?