Re: difference between atomic and volatile variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux