how the compiler treats any volatile variable?Explain with
example.
Answer Posted / 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 View All Answers
What are pointers? Why are they used?
What is integer constants?
Where can I get an ansi-compatible lint?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
What are header files and what are its uses in C programming?
What do you mean by invalid pointer arithmetic?
Can we change the value of static variable in c?
how to find anagram without using string functions using only loops in c programming
What is #include stdio h?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
What is an array? What the different types of arrays in c?
Is multithreading possible in c?
What is wrong in this statement?
Can we use visual studio for c?