[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.0.99.0705090308150.17598@chino.kir.corp.google.com>
Date: Wed, 9 May 2007 03:25:06 -0700 (PDT)
From: David Rientjes <rientjes@...gle.com>
To: Alan Cox <alan@...rguk.ukuu.org.uk>
cc: Randy Dunlap <randy.dunlap@...cle.com>,
Satyam Sharma <satyam.sharma@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Paul Sokolovsky <pmiscml@...il.com>,
linux-kernel@...r.kernel.org, jeremy@...p.org
Subject: Re: [PATCH] doc: volatile considered evil
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 majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists