InterviewSolution
| 1. |
Explain The Use Of Volatile Field Modifier? |
|
Answer» When you COMPILE a program, the COMPILER will examine your code and perform some "tricks" behind the scenes that optimize your program's PERFORMANCE. Under certain circumstances, you MAY want to force the compiler not to optimize a variable. Optimization can make certain assumptions about where and how memory is handled. If, for example, you are building an interface to memory-mapped device, you may need to suppress optimization. To protect a variable from being optimized, you should use the volatile keyword, as SHOWN: volatile double system_bit_flags; When you compile a program, the compiler will examine your code and perform some "tricks" behind the scenes that optimize your program's performance. Under certain circumstances, you may want to force the compiler not to optimize a variable. Optimization can make certain assumptions about where and how memory is handled. If, for example, you are building an interface to memory-mapped device, you may need to suppress optimization. To protect a variable from being optimized, you should use the volatile keyword, as shown: volatile double system_bit_flags; |
|