What is an volatile variable?

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


Please Help Members By Posting Answers For Below Questions

With the help of using classes, write a program to add two numbers.

609


Is printf a keyword?

749


Why is sprintf unsafe?

608


You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

1770


How many keywords are there in c?

579






What are the different types of C instructions?

663


What is strcpy() function?

646


How important is structure in life?

580


Hai what is the different types of versions and their differences

1479


What language is c written?

568


Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop

1702


What are the ways to a null pointer can use in c programming language?

581


Explain the use of keyword 'register' with respect to variables.

583


What is the advantage of a random access file?

631


Why do we use stdio h and conio h?

624