Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - volatile

Node:volatile, Next:, Previous:void, Up:More data types



volatile

The volatile type qualifier was introduced by the ANSI Standard to permit the use of memory-mapped variables, that is, variables whose value changes autonomously based on input from hardware. One might declare a volatile variable volatile float temperature; whose value fluctuated according to readings from a digital thermometer connected to the computer.

There is another use for the volatile qualifier that has to do with multiprocessing operating systems. Independent processes that share common memory might each change the value of a variable independently. The volatile keyword serves as a warning to the compiler that it should not optimize the code containing the variable (that is, compile it so that it will run in the most efficient way possible) by storing the value of the variable and referring to it repeatedly, but should reread the value of the variable every time. (Volatile variables are also flagged by the compiler as not to be stored in read-only memory.)

 
 
  Published under free license. Design by Interspire