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 you find out how much memory is available?
What is multidimensional arrays
What is pragma in c?
What does void main () mean?
What is file in c language?
How can I send mail from within a c program?
Explain what are the different file extensions involved when programming in c?
What is an array in c?
How do I get a null pointer in my programs?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
What is the general form of #line preprocessor?
What is build process in c?
How can you invoke another program from within a C program?
Why doesnt the call scanf work?
How can I invoke another program or command and trap its output?