Re: [PATCH] doc: volatile considered evil

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

 



On Wed, 9 May 2007, Alan Cox wrote:

> When Might You Need volatile ?
> ------------------------------
> 
> When you are implementing the locking primitives on a new platform. When
> you are implementing the I/O and atomic prmitives on a new platform. Also
> in inline gcc assembler where "volatile" is used for subtly different
> purposes.
> 

What is determined to be an "access" (read or modify) to an object such 
as a locking primitive that is type-qualified with the keyword 'volatile' 
is implementation defined.

You cannot guarantee that the value in such an object would agree 
with the evaluation thus far as specified by the semantics of the code
even at sequence points because such an object can be modified without 
knowledge to the implementation.  The only thing you _can_ guarantee at 
these sequence points is that their previous accesses are complete and 
later accesses, as specified by the semantics of the code, have not yet 
occurred.  This does not exclude the possibility that they were modified 
without knowledge to the implementation.  In this case, the actual and 
abstract semantics of the text may not agree.

Thus, any reliance on type-qualifying an object that represents an atomic 
or locking primitive on the keyword 'volatile' is misplaced.

		David
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux