On 5/10/07, Jesper Juhl <jesper.juhl@xxxxxxxxx> wrote:
Just to add, this true only if you are using volatile for your normal C variables. On the contrary when you use volatile while using extended asm directives, the GCC compiler may still optimize your inline voodo.
HTH
~psr
On 09/05/07, anil kumar <anildahiya80@xxxxxxxxx> wrote:
> HI
> Please tell me , what are the main difference between atomic and volatile
> variable ?
atomic refers to something that appears to the rest of the system as a
single event that is either completed entirely or not at all. When
speaking about atomic data types what is meant is data types that,
when read or written, are always consistent.
For instance, if one part of the system is writing to the variable and
another part is reading the variable, then the part that is reading
will either see the value before the write happens or the value after
the write has completer - it'll never read a value from the variable
that is only partially updated.
A volatile object (variable) is an object that the compiler will not
optimize access to.
Just to add, this true only if you are using volatile for your normal C variables. On the contrary when you use volatile while using extended asm directives, the GCC compiler may still optimize your inline voodo.
HTH
~psr
The volatile keyword does not guarantee that
access to a variable will be atomic, so you can't use volatile instead
of proper locking with a mutex, spinlock or similar.
> Thanks in advance.
> --Anil
--
Jesper Juhl <jesper.juhl@xxxxxxxxx>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ
--
play the game