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
formula to convert 2500mmh2o into m3/hr
What are the different types of errors?
What functions are used for dynamic memory allocation in c language?
Explain how can I avoid the abort, retry, fail messages?
When should a type cast not be used?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
What is the size of enum in bytes?
how do you execute a c program in unix.
#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }
What is omp_num_threads?
What is main return c?
What is spark map function?
Is c procedural or object oriented?
Why do we use header files in c?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.