473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

abt volatile variable

hi,


this is karunakar.My question is "when u declared a variable as volatile ,where the variable will stored(i mean, which memory part (section) is assigned for that ) ".
Aug 27 '07 #1
2 1153
Meetee
931 Expert Mod 512MB
hi,


this is karunakar.My question is "when u declared a variable as volatile ,where the variable will stored(i mean, which memory part (section) is assigned for that ) ".
Hi,

Volatile qualifiers can be used to change the behavior of a type.

volatile int i = 5; declares and initializes an object with type volatile int whose value will be always read from memory. A variable or object declared with the volatile
keyword may be modified externally from the declaring object.

Regards
Aug 27 '07 #2
gsi
51
Hi,
Following the above explanation, Volatile is a type qualifier and not a storage class specifier ( like ' register ' which requests the compiler to allocate the variable qualified with 'register' in a cpu register). So it has nothing to do with the section of memory in to which it will be allocated but rather tells the compiler not to perform any optimization on the variable (Hence they are always read from memory on each reference to it).

thanks,
gsi.
Aug 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Radde | last post by:
HI, Can volatile variables be accessed by many processess..or only one process can access it.. Cheers..
11
by: srinivas reddy | last post by:
Hi, Is there any chance that a program doesn' work properly even after a variable is declared as volatile? I remember somebody mentioning a scenario involving L1, L2 caches. Could anybody throw...
14
by: google-newsgroups | last post by:
Hello, even (or because?) reading the standard (ISO/IEC 9899/1999) I do not understand some issues with volatile. The background is embedded programming where data is exchanged between main...
17
by: dingoatemydonut | last post by:
The C99 standard states: "In the abstract machine, all expressions are evaluated as specified by the semantics. An actual implementation need not evaluate part of an expression if it can deduce...
22
by: Assaf | last post by:
hi all i know that i should not cross-post, but i am not sure to which group to post this question. 2 quesions about volatile: 1. i use volatile when 2 threads access the same variable...
14
by: Pierre | last post by:
Using the "volatile" keyword, creates a problem if I intend to use any of the interlocked APIs. The compiler generates an error if I use the following line, for example: ...
4
by: vijay.rajamanickam | last post by:
I am a newbie w.r.t. compiler optimizations and I believe these optimizations are generally done in function level. Can I safely assume that if I use getter & setter functions, I can effectively...
6
by: bwaichu | last post by:
Can someone help me out here? This is one of those areas of C that I am fuzzy on. I'm not quite sure when I should use volatile. If you could provide an example, that would help out a lot. I...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
10
by: S James S Stapleton | last post by:
Is volatile necessary anymore? I have a two-thread piece of code I've been testing to figure out what volatile does (fairly simple code, uses pthreads). I have an update thread (variables passed as...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.