volatile

Discussion in 'C Programming' started by lak, Oct 23, 2007.

  1. lak

    lak Guest

    what is "volatile"? what is the use of this?
    lak, Oct 23, 2007
    #1
    1. Advertising

  2. lak

    Porkling Guest

    On Mon, 22 Oct 2007 21:20:06 -0700, lak <> wrote:


    >what is "volatile"? what is the use of this?


    It means "let me be".
    It tells compiler donot optimize me because of I would change in
    runtime.
    Porkling, Oct 23, 2007
    #2
    1. Advertising

  3. lak

    jaysome Guest

    On Mon, 22 Oct 2007 21:20:06 -0700, lak <> wrote:

    >what is "volatile"? what is the use of this?


    Search the following web site for "volatile" and read all of the
    articles in the search results.

    http://www.embedded.com/

    After reading these articles, if you still have questions, then by all
    means ask them here.

    Best regards
    --
    jay
    jaysome, Oct 23, 2007
    #3
  4. On Oct 23, 9:20 am, lak <> wrote:
    > what is "volatile"? what is the use of this?



    "volatile" is a 'qualifier' that is used at the time of
    declaration. It tells the compiler that the value of the
    variable may change at any time-without being manipulated from
    your code. For example , registers(Status Registers) whose
    values may change asynchronously at any point of time from
    external factors . Also, it is very useful in ISRs and
    Multithreaded programming.

    It is very common in Embedded to declare status register as
    volatile. It implies that it can be changed by external
    hardware at any point of time during the lifetime of the
    program and the compiler must not optimise it if it is not
    used in the current program.It is for optimisation .

    There are lot of good articles regarding 'volatile' in
    internet. Try googling. :)
    karthikbalaguru, Oct 23, 2007
    #4
  5. lak

    santosh Guest

    lak wrote:

    > what is "volatile"? what is the use of this?


    It indicates to the compiler that the object so qualified should not be
    subject to optimisation, particularly that it can be modified
    asynchronously from outside the program. Typically this means that
    reading the object, actually accesses it, and not some compiler cached
    copy, even if the compiler believes that the object has not changed. It
    will also prevent the compiler from keeping the object entirely in a
    register, even if the object's lifetime is small.
    santosh, Oct 23, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Knute Johnson

    Re: Volatile?

    Knute Johnson, Jul 1, 2003, in forum: Java
    Replies:
    17
    Views:
    1,437
    Knute Johnson
    Jul 3, 2003
  2. Doug Pardee

    Re: Volatile?

    Doug Pardee, Jul 1, 2003, in forum: Java
    Replies:
    0
    Views:
    886
    Doug Pardee
    Jul 1, 2003
  3. Replies:
    1
    Views:
    903
    Knute Johnson
    Aug 29, 2003
  4. Daniel

    Can volatile be trusted?

    Daniel, Sep 11, 2003, in forum: Java
    Replies:
    7
    Views:
    467
    Chris Uppal
    Sep 12, 2003
  5. ben
    Replies:
    5
    Views:
    583
    Ulrich Eckhardt
    Jan 11, 2005
Loading...

Share This Page