Results 1 to 5 of 5

Thread: C : Volatile Modifier

  1. #1
    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    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.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    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;
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    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

  5. #5
    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;

Similar Threads

  1. Replies: 5
    Last Post: 29-10-2010, 01:53 AM
  2. Specifications of UNIX User Password Modifier
    By Abigail101 in forum Windows Software
    Replies: 5
    Last Post: 06-02-2010, 02:11 AM
  3. Difference between Access Specifier and Modifier in Java
    By Sarfaraj Khan in forum Software Development
    Replies: 5
    Last Post: 19-01-2010, 02:06 PM
  4. Information about Win32/BaiduSobar the Browser Modifier
    By Juan-Carlos in forum Networking & Security
    Replies: 5
    Last Post: 13-12-2009, 12:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,421,984.59984 seconds with 17 queries