Volatile

Volatile

am 06.02.2007 12:04:19 von ankitjain1580

Hi ppl

Can any body here make this "volatile" more clear in
terms of C language with some practical example i.e
why we need it? or for what it can be used for ?

thanks

ankit




Send instant messages to your online friends http://uk.messenger.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Volatile

am 06.02.2007 13:04:00 von Rajat Jain

On 2/6/07, Ankit Jain wrote:
> Hi ppl
>
> Can any body here make this "volatile" more clear in
> terms of C language with some practical example i.e
> why we need it? or for what it can be used for ?
>

Volatile provides a hint to the compiler not to act oversmart by
performing optimizations on the variable ;-). This is because the the
value of the variable may be modified from elsewhere (for e.g.
interrupts etc) which the compiler is not aware of. Hence it should
not cache it anywhere, and should always generate load instructions to
read the "fresh" copy.

Regards,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs