Answer Posted / chandrashekar kalvacherla
volatile tells the compiler that this variable can get altered by ways that the compiler cannot deduce. As a consequence, the compiler will exclude that variable from optimizations and the code will always fetch the variables content from memory, even if it has done so before (no caching).
Imagine a hardware clock which is mapped into memory. You need some way to tell the compiler: whenever I access that variable (mapped to the hardware clock), I want you to actually fetch the content from there. Otherwise the compiler might just ask the clock once for the current time and use the cached value (in a processor register) throught the rest of the program.
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
How can I find out the size of a file, prior to reading it in?
How can you return multiple values from a function?
Where does the name "C" come from, anyway?
How can I remove the leading spaces from a string?
Explain how do you determine whether to use a stream function or a low-level function?
What are the application of void data type in c?
When can a far pointer be used?
What are the rules for the identifier?
What are header files in c programming?
Explain the difference between malloc() and calloc() function?
What is the general form of #line preprocessor?
What are operators in c?
Write a program with dynamically allocation of variable.
What are the loops in c?
Are pointers integer?