Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



C : Volatile Modifier

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 27-01-2010
Member
 
Join Date: Jan 2010
Posts: 29
C : Volatile Modifier
  

Hello, friends. I am the student of the MscCS. I have the knowledge of the C language. But I don't know about the Volatile Modifier of the C language. I have to submit the assignment in the college. So, I want know about the Volatile Modifier of the C language. I would also like to know about how the Volatile Modifier work, what is the use of the Volatile Modifier, how can I use them in the program. So, Can anyone help me to know about the Volatile Modifier.

Reply With Quote
  #2  
Old 27-01-2010
Member
 
Join Date: Apr 2008
Posts: 1,946
C : Volatile Modifier

Hi, The Volatile Modifier means it is a directive to the compiler's optimizer. The operations involving Volatile Modifier should not be optimized in certain ways. It is worth to having use of the Volatile Modifier in two special cases. In the first case, It involves memory-mapped hardware means a device like a graphics adapter as if it is part of the computer's memory that appears to the computer's hardware and In the second case, It involves shared memory means that memory that is being used by more than two programs simultaneously running.
Reply With Quote
  #3  
Old 27-01-2010
Member
 
Join Date: Apr 2008
Posts: 1,999
C Program : Volatile Modifier

I suggest you to carefully go through the following lines of code that help you to know about the Volatile Modifier more easily :
tim_t tim_add(volatile const struct timr *t, int b)
{
int m;
int y;
tim_t then;
y = 0;
then = t->value;
for (m = 0; m < 1000; m++)
{
y = y + b;
}
return t->value - then;
}
Reply With Quote
  #4  
Old 27-01-2010
Member
 
Join Date: May 2008
Posts: 2,289
Volatile Modifier

When the value of the variable can change unexpectedly that time variable can be declared as Volatile. basically, Only three types of variables can change:
1. Global variables accessed by multiple tasks within a multi-threaded application
2. Memory-mapped peripheral registers
3. Global variables modified by an interrupt service routine
Reply With Quote
  #5  
Old 27-01-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
Volatile Modifier : C

Note that you can not be allowed to use volatile modifier on any time. The following are the data types with those you can use Volatile Modifier :
1. An enum type with an enum base type of the following: uint, sbyte, sshort, byte, short, int.
2. byte, sbyte, ushort, short, uint, int, float, char, bool.
3. Any pointer type in a unsafe context.
4. Any reference type.
Example of Volatile Modifier :
public volatile int age;
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "C : Volatile Modifier"
Thread Thread Starter Forum Replies Last Post
How to change the modifier key which is not working on other keyboard Ravana Hardware Peripherals 5 29-10-2010 01:53 AM
Specifications of UNIX User Password Modifier Abigail101 Windows Software 5 06-02-2010 01:11 AM
Difference between Access Specifier and Modifier in Java Sarfaraj Khan Software Development 5 19-01-2010 01:06 PM
Information about Win32/BaiduSobar the Browser Modifier Juan-Carlos Networking & Security 5 12-12-2009 11:06 PM


All times are GMT +5.5. The time now is 10:19 AM.