Results 1 to 4 of 4
Hi,
i like to know the importance of constant volatile in device drivers or some where.
Fews doubt on this Keyword:If the volatile variable is constant, then what is the ...
- 09-29-2007 #1Just Joined!
- Join Date
- Nov 2006
- Location
- Hyderabad
- Posts
- 85
const volatile
Hi,
i like to know the importance of constant volatile in device drivers or some where.
Fews doubt on this Keyword:If the volatile variable is constant, then what is the use.
It has been made volatile, since it can be modified on the fly in some other thread.
If it can be made constant, then volatile will not carry any meaning!
thanx in advance
- 09-29-2007 #2
It is possible for memory-mapped hardware to be designed so that if you read a particular location in "memory", then some hardware action will be performed. The const is a way of documenting that there is no reason to change the value itself. The volatile is a way of ensuring that no matter how much your compiler optimizes the code, a reference in a C program to that location will not be "optimized out"; that is, it will always be compiled as a real reference to that location.
Hope this helps.
- 10-01-2007 #3Just Joined!
- Join Date
- Nov 2006
- Location
- Hyderabad
- Posts
- 85
thank you for reply
i gone for some searching on const volatile variable.
if we declare volatile variable as const, it cann't be changed by current context, but it can be changed by external events such as signal interrupts, hardware registers,memory mapped i/o.
- 10-01-2007 #4
Oops, forgot about that. I got an education today, thanks!


Reply With Quote