how the compiler treats any volatile variable?Explain with
example.



how the compiler treats any volatile variable?Explain with example...

Answer / daniboy

A volatile variable is one whose VALUE CAN CHANGE
UNEXPECTEDLY. Consequently, the compiler can make NO
ASSUMPTIONS about the value of the variable. In
particular, the optimizer must be careful to RELOAD the
variable every time it is used instead of holding a copy in
a register.
Examples of volatile variables are:

(a) Hardware registers in peripherals (e.g., status
registers)
(b) Non-stack variables referenced within an interrupt
service routine.
(c) Variables shared by multiple tasks in a multi-
threaded application.

Source: 10 Best Questions to would-be Embedded Programmers -
By Nigel Johns

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More C Interview Questions

What is 'bus error'?

0 Answers  


Does c have circular shift operators?

0 Answers  


largest Of three Number using without if condition?

0 Answers  


How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?

1 Answers  


Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times the loop is executed ?

8 Answers   Mascot, TCS,






How to implement call back functions ?

3 Answers   HP,


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

0 Answers   Genpact,


What is the difference between functions getch() and getche()?

0 Answers  


What is the use of ?

0 Answers  


why java is called as a purely oops language.

3 Answers   TVS,


What is sizeof array?

0 Answers  


what is the difference between arrays and linked list

26 Answers   MAHINDRA, Tech Mahindra, Wipro,


Categories