<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Nine ways to break your systems code using volatile</title>
	<atom:link href="http://blog.regehr.org/archives/28/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.regehr.org/archives/28</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 05:34:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: regehr</title>
		<link>http://blog.regehr.org/archives/28/comment-page-1#comment-1817</link>
		<dc:creator>regehr</dc:creator>
		<pubDate>Mon, 24 Jan 2011 21:34:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=28#comment-1817</guid>
		<description>Hi Melbourne,  

The implementation-definedness is a little bit irrelevant since there is pretty solid agreement among compiler developers and compiler users that a volatile on the RHS of an expression means the volatile location should be loaded from, and a volatile on the LHS of an expression means the volatile location should be stored to.

Basically, in spite of some ugly stuff in the standard, people want and need a usable language for systems work.</description>
		<content:encoded><![CDATA[<p>Hi Melbourne,  </p>
<p>The implementation-definedness is a little bit irrelevant since there is pretty solid agreement among compiler developers and compiler users that a volatile on the RHS of an expression means the volatile location should be loaded from, and a volatile on the LHS of an expression means the volatile location should be stored to.</p>
<p>Basically, in spite of some ugly stuff in the standard, people want and need a usable language for systems work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Melbourne</title>
		<link>http://blog.regehr.org/archives/28/comment-page-1#comment-1814</link>
		<dc:creator>Melbourne</dc:creator>
		<pubDate>Mon, 24 Jan 2011 10:32:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=28#comment-1814</guid>
		<description>volatile is implementation-defined. As the C-standard says, “What constitutes an access to an object that has volatile- qualified type is implementation-defined”, so use of &#039;volatile&#039; boils down to whatever your compiler does on your platform. 
Having said that, the meaning of [code]__asm__ __volatile__ (&quot;dmb&quot; : : : &quot;memory&quot;);[/code] is also implementation-defined, so the suggested solution (and the suggested class of solutions) is not really a solution to anything at all.</description>
		<content:encoded><![CDATA[<p>volatile is implementation-defined. As the C-standard says, “What constitutes an access to an object that has volatile- qualified type is implementation-defined”, so use of &#8216;volatile&#8217; boils down to whatever your compiler does on your platform.<br />
Having said that, the meaning of
<pre class="brush: plain; title: ; notranslate">__asm__ __volatile__ ("dmb" : : : "memory");</pre>
<p> is also implementation-defined, so the suggested solution (and the suggested class of solutions) is not really a solution to anything at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Essex IT Support</title>
		<link>http://blog.regehr.org/archives/28/comment-page-1#comment-856</link>
		<dc:creator>Essex IT Support</dc:creator>
		<pubDate>Wed, 04 Aug 2010 19:13:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=28#comment-856</guid>
		<description>C is a good and much easier way of  programming. This really helps me understand more of C programming.

Thanks for the information.</description>
		<content:encoded><![CDATA[<p>C is a good and much easier way of  programming. This really helps me understand more of C programming.</p>
<p>Thanks for the information.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: regehr</title>
		<link>http://blog.regehr.org/archives/28/comment-page-1#comment-254</link>
		<dc:creator>regehr</dc:creator>
		<pubDate>Tue, 27 Apr 2010 15:31:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=28#comment-254</guid>
		<description>Hi Ralf,

I suspect we largely agree.  It probably sounds like I&#039;m trying to defend the standard and the implementations but my intent is just to come up with a pragmatic explanation of the situation that developers are likely to find themselves in.  It is definitely broken, but the breakage can often be worked around through prudent engineering.  Anyway, a new post is coming soon with even more fun issues ;).

John</description>
		<content:encoded><![CDATA[<p>Hi Ralf,</p>
<p>I suspect we largely agree.  It probably sounds like I&#8217;m trying to defend the standard and the implementations but my intent is just to come up with a pragmatic explanation of the situation that developers are likely to find themselves in.  It is definitely broken, but the breakage can often be worked around through prudent engineering.  Anyway, a new post is coming soon with even more fun issues <img src='http://blog.regehr.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ralf</title>
		<link>http://blog.regehr.org/archives/28/comment-page-1#comment-253</link>
		<dc:creator>Ralf</dc:creator>
		<pubDate>Mon, 26 Apr 2010 18:32:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.regehr.org/?p=28#comment-253</guid>
		<description>Hi John,

I see what you&#039;re saying, but it essentially makes no difference. In this 2 line function, there is clearly a sequence point between the 2 instructions. Interpreting the spec such that the non-volatile access can move past a volatile access clearly invalidates it in all cases except 2 volatile accesses. In any case, if the volatile write is done before the array write, then the volatile instruction *has* moved past the sequence point before it.

An example, in {a;b;c;volatile;d;e;f;}, it&#039;s fine to rearrange {a;b;c;} and {d;e;f;} at will, e.g. to produce {c;b;a;volatile;f;d;e}, but it is not correct to rearrange any of these statements outside of their triplet because doing so necessarily causes the volatile to move across a sequence point. 

I guess it boils down, as you say, to whether a memory access is a side effect. Personally, I&#039;d argue that it is a side-effect (and in fact, this causes the compiler no problems as it can still re-order any non-volatile statements), but if the accepted view is that this is wrong, then I guess it&#039;s something we have to live with.

Certainly, I agree that compiler vendors are unlikely to change their implementations and that it&#039;s best to highlight that this problem exists and work around it as you describe.

Ralf</description>
		<content:encoded><![CDATA[<p>Hi John,</p>
<p>I see what you&#8217;re saying, but it essentially makes no difference. In this 2 line function, there is clearly a sequence point between the 2 instructions. Interpreting the spec such that the non-volatile access can move past a volatile access clearly invalidates it in all cases except 2 volatile accesses. In any case, if the volatile write is done before the array write, then the volatile instruction *has* moved past the sequence point before it.</p>
<p>An example, in {a;b;c;volatile;d;e;f;}, it&#8217;s fine to rearrange {a;b;c;} and {d;e;f;} at will, e.g. to produce {c;b;a;volatile;f;d;e}, but it is not correct to rearrange any of these statements outside of their triplet because doing so necessarily causes the volatile to move across a sequence point. </p>
<p>I guess it boils down, as you say, to whether a memory access is a side effect. Personally, I&#8217;d argue that it is a side-effect (and in fact, this causes the compiler no problems as it can still re-order any non-volatile statements), but if the accepted view is that this is wrong, then I guess it&#8217;s something we have to live with.</p>
<p>Certainly, I agree that compiler vendors are unlikely to change their implementations and that it&#8217;s best to highlight that this problem exists and work around it as you describe.</p>
<p>Ralf</p>
]]></content:encoded>
	</item>
</channel>
</rss>

