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
What is bss in c?
What is struct node in c?
Why does everyone say not to use scanf? What should I use instead?
hi send me sample aptitude papers of cts?
What is the explanation for prototype function in c?
When can you use a pointer with a function?
Is c easier than java?
What is calloc in c?
What is assert and when would I use it?
What is #line in c?
Explain the difference between getch() and getche() in c?
what is the role you expect in software industry?
Is there a built-in function in C that can be used for sorting data?
How can this be legal c?
`write a program to display the recomended action depends on a color of trafic light using nested if statments