When volatile can be used?

Answers were Sorted based on User's Feedback



When volatile can be used?..

Answer / reejusri

One more thing i want to add in above answer that is if
compiler sees keyword volatile it skips that variable from
optimization of code, becasue since it is very dymanic in
nature and to manage such type of variable for
optimaization is costly.

Is This Answer Correct ?    7 Yes 0 No

When volatile can be used?..

Answer / mustafa

Volatile restricts the compiler in two ways
1-> No optimization algorithm should be applied to this
variable.
2-> When ever you need the value of the volatile variable
please take it from the memory.

Is This Answer Correct ?    7 Yes 0 No

When volatile can be used?..

Answer / qqlin

it means this value will be changed unexpectedly. everytime
the program wants to use it, it can only be got from memory
but not from the register directly.

if you want a variable can be accessed by several threads,
you need this key word, like in ISR program, etc.

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More C++ General Interview Questions

There are 100 students in a class. The management keep information in two tables. Those two tables are given like Roll no Name Age 001 ABC 15 002 XYZ 14 and Roll No Subject Marks 001 Math 75 001 Physics 55 002 Math 68 001 Hindi 69 They want the information like this Roll No Name Hindi Physics Math Total 001 ABC 69 55 75 199 002 XYZ 68 74 84 226 And Roll No Suject Highest 001 Math 98 007 Physics 84 021 Hindi 74 All 275 All information is kept in structure in main memory. You have to find last two tables.

0 Answers  


What are the types of pointer?

0 Answers  


How to stop conversions among objects?

5 Answers   Symphony,


Do you need a main function in c++?

0 Answers  


Which algorithm do you like the most? Why?

2 Answers   Google,






When a function is made inline. Write the situation where inline functions may not work.

2 Answers  


Write a note about the virtual member function?

0 Answers  


the first character in the variable name must be an a) special symbol b) number c) alphabet

0 Answers  


is throwing exception from a constructor not a good practice ?

5 Answers   Ericsson,


What is the use of structure in c++?

0 Answers  


Consider a c++ template funtion template<class T> T& Add(T a, T b){return a+b ;} if this function is called as T c = Add("SAM", "SUNG"); what will happen? What is the problem in the template declaration/ How to solve the problem.

7 Answers   LG, Samsung,


What is a stack c++?

0 Answers  


Categories