[Top][All Lists]

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

[gpsd-dev] shm, volatile, etc.

From: Dave Platt
Subject: [gpsd-dev] shm, volatile, etc.
Date: Tue, 05 Nov 2013 11:20:30 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

It may be old news to most, but...

If you're *sure* that reordering is never going to be an issue with
accesses to the variable in question, and that the multithreaded
access to the variable can't cause anomalous behavior no matter
how race-condition-y things could ever get under the worst
possible conditions when the wind is blowing and the moon
is in the seventh house and Murphy is awake, then maybe "volatile"
is adequate.

But, based on the discussions cited above (and on the fact that I
have personally been burned by mis-using "volatile" in just this
fashion) I really don't think I'll ever depend on it again.

The following was also interesting to me:

It looks to me as if many (mis)uses of "volatile" would count
as being "unstable" code, according to the definition in this
article... and might be at risk for being silently eliminated or
altered in unpredictable ways by future compilers.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]