<?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: volatile</title>
	<atom:link href="http://www.airs.com/blog/archives/154/feed" rel="self" type="application/rss+xml" />
	<link>http://www.airs.com/blog/archives/154</link>
	<description>Ian Lance Taylor</description>
	<lastBuildDate>Mon, 15 Mar 2010 16:54:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: -= Linkage 2008.03.24 =-</title>
		<link>http://www.airs.com/blog/archives/154/comment-page-1#comment-15830</link>
		<dc:creator>-= Linkage 2008.03.24 =-</dc:creator>
		<pubDate>Mon, 26 Jan 2009 15:37:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/154#comment-15830</guid>
		<description>[...] C volatile [...]</description>
		<content:encoded><![CDATA[<p>[...] C volatile [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ð¢Ð¾Ð½ÐºÐ¾ÑÑ‚Ð¸ Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ Ð¼Ð¾Ð´Ð¸Ñ„Ð¸ÐºÐ°Ñ‚Ð¾Ñ€Ð° volatile Ð½Ð° ÐÐ»ÐµÐºÑÐµÐ¹ Embedded</title>
		<link>http://www.airs.com/blog/archives/154/comment-page-1#comment-15799</link>
		<dc:creator>Ð¢Ð¾Ð½ÐºÐ¾ÑÑ‚Ð¸ Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ Ð¼Ð¾Ð´Ð¸Ñ„Ð¸ÐºÐ°Ñ‚Ð¾Ñ€Ð° volatile Ð½Ð° ÐÐ»ÐµÐºÑÐµÐ¹ Embedded</dc:creator>
		<pubDate>Tue, 20 Jan 2009 17:06:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/154#comment-15799</guid>
		<description>[...] Ð˜Ð½Ñ‚ÐµÑ€ÐµÑÐ½Ð°Ñ Ð·Ð°Ð¼ÐµÑ‚ÐºÐ°Â Ian Lance TaylorÂ Ð¾Ð± Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ð¸ Ð¼Ð¾Ð´Ð¸Ñ„Ð¸ÐºÐ°Ñ‚Ð¾Ñ€Ð°Â volatile Ð² ÑÐ·Ñ‹ÐºÐµ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¸Ñ€Ð¾Ð²Ð°Ð½Ð¸Ñ Ð¡. ÐŸÑ€Ð°Ð²Ð´Ð° Ð² Ð½ÐµÐ¹ Ð¾Ð¿ÑƒÑÐºÐ°ÐµÑ‚ÑÑ Ð¼ÐµÑ‚Ð¾Ð´ Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ volatile Ð´Ð»Ñ Ð¼Ð½Ð¾Ð³Ð¾-Ð¿Ð¾Ñ‚Ð¾ÐºÐ¾Ð²Ñ‹Ñ… Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¼, Ð¿Ð¾ÑÑ‚Ð¾Ð¼Ñƒ Ð² Ð´Ð¾Ð³Ð¾Ð½ÐºÑƒ ÑÑ‚Ð°Ñ‚ÑŒÑÂ Andrei Alexandrescu -Â volatile - Multithreaded Programmer&#8217;s Best Friend. [...]</description>
		<content:encoded><![CDATA[<p>[...] Ð˜Ð½Ñ‚ÐµÑ€ÐµÑÐ½Ð°Ñ Ð·Ð°Ð¼ÐµÑ‚ÐºÐ°Â Ian Lance TaylorÂ Ð¾Ð± Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ð¸ Ð¼Ð¾Ð´Ð¸Ñ„Ð¸ÐºÐ°Ñ‚Ð¾Ñ€Ð°Â volatile Ð² ÑÐ·Ñ‹ÐºÐµ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¸Ñ€Ð¾Ð²Ð°Ð½Ð¸Ñ Ð¡. ÐŸÑ€Ð°Ð²Ð´Ð° Ð² Ð½ÐµÐ¹ Ð¾Ð¿ÑƒÑÐºÐ°ÐµÑ‚ÑÑ Ð¼ÐµÑ‚Ð¾Ð´ Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ volatile Ð´Ð»Ñ Ð¼Ð½Ð¾Ð³Ð¾-Ð¿Ð¾Ñ‚Ð¾ÐºÐ¾Ð²Ñ‹Ñ… Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¼, Ð¿Ð¾ÑÑ‚Ð¾Ð¼Ñƒ Ð² Ð´Ð¾Ð³Ð¾Ð½ÐºÑƒ ÑÑ‚Ð°Ñ‚ÑŒÑÂ Andrei Alexandrescu -Â volatile &#8211; Multithreaded Programmer&#8217;s Best Friend. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: davem</title>
		<link>http://www.airs.com/blog/archives/154/comment-page-1#comment-14735</link>
		<dc:creator>davem</dc:creator>
		<pubDate>Tue, 26 Aug 2008 04:47:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/154#comment-14735</guid>
		<description>But in such a situation you would be doing one of two things to
coordinate execution in the interrupt handler from execution
outside of that interrupt handler.

1) Disable CPU interrupts in non-interrupt handler code accessing
     the buffer or other shared state

2) Using a spinlock or some other kind of mutex to protect the
     buffer

Such primitives, in order to be useful, would have to provide the
same things that volatile give you, yet more directly so.  Therefore
you don&#039;t need to use volatile.</description>
		<content:encoded><![CDATA[<p>But in such a situation you would be doing one of two things to<br />
coordinate execution in the interrupt handler from execution<br />
outside of that interrupt handler.</p>
<p>1) Disable CPU interrupts in non-interrupt handler code accessing<br />
     the buffer or other shared state</p>
<p>2) Using a spinlock or some other kind of mutex to protect the<br />
     buffer</p>
<p>Such primitives, in order to be useful, would have to provide the<br />
same things that volatile give you, yet more directly so.  Therefore<br />
you don&#8217;t need to use volatile.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Lance Taylor</title>
		<link>http://www.airs.com/blog/archives/154/comment-page-1#comment-14734</link>
		<dc:creator>Ian Lance Taylor</dc:creator>
		<pubDate>Tue, 26 Aug 2008 04:12:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/154#comment-14734</guid>
		<description>Yes, that makes sense.  Thanks for the example.</description>
		<content:encoded><![CDATA[<p>Yes, that makes sense.  Thanks for the example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raphael</title>
		<link>http://www.airs.com/blog/archives/154/comment-page-1#comment-14731</link>
		<dc:creator>Raphael</dc:creator>
		<pubDate>Mon, 25 Aug 2008 09:15:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/154#comment-14731</guid>
		<description>One other - sensible - use of &#039;volatile&#039; is for variables that are modified by interrupt handlers. (Usually the OS handles interrupts for you. But on microcontrollers you have to handle them yourself. )
For example, you might have a main loop sending data from a buffer over a serial line. When new data is available from the analog-digital converter (ADC) an interrupt occurs. You handle this interrupt in a routine that copies the data from the ADC register into your buffer, then restarts the ADC. If this buffer were not declared &#039;volatile&#039; the main loop might not recognize newly added data.</description>
		<content:encoded><![CDATA[<p>One other &#8211; sensible &#8211; use of &#8216;volatile&#8217; is for variables that are modified by interrupt handlers. (Usually the OS handles interrupts for you. But on microcontrollers you have to handle them yourself. )<br />
For example, you might have a main loop sending data from a buffer over a serial line. When new data is available from the analog-digital converter (ADC) an interrupt occurs. You handle this interrupt in a routine that copies the data from the ADC register into your buffer, then restarts the ADC. If this buffer were not declared &#8216;volatile&#8217; the main loop might not recognize newly added data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Lance Taylor</title>
		<link>http://www.airs.com/blog/archives/154/comment-page-1#comment-11353</link>
		<dc:creator>Ian Lance Taylor</dc:creator>
		<pubDate>Mon, 10 Mar 2008 19:14:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/154#comment-11353</guid>
		<description>Thanks for the pointer to the article.  I admit that I had not considered that way of using volatile in C++ to prevent inadvertent unlocked accesses.  That seems like a good idea.  I was thinking about applying volatile to primitive types, and indeed the article agrees with me: don&#039;t do it for multithreaded code.</description>
		<content:encoded><![CDATA[<p>Thanks for the pointer to the article.  I admit that I had not considered that way of using volatile in C++ to prevent inadvertent unlocked accesses.  That seems like a good idea.  I was thinking about applying volatile to primitive types, and indeed the article agrees with me: don&#8217;t do it for multithreaded code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gabe</title>
		<link>http://www.airs.com/blog/archives/154/comment-page-1#comment-11352</link>
		<dc:creator>gabe</dc:creator>
		<pubDate>Sat, 08 Mar 2008 13:46:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/154#comment-11352</guid>
		<description>Hi Ian. Thanks for this post. I&#039;ve recently started working on some multi threaded C++ apps. Currently using Trolltech/Qt&#039;s libraries but I&#039;ll probably also probably use Boost. Anyway, this discussion of volatile was very helpful, especially the use of volatile sig_atomic_t as a signal which will not require a semaphore or mutex.

At any rate, I&#039;m curious about your view of this use of volatile, from Andrei Alexandrescu. 
http://www.ddj.com/cpp/184403766

It seems incorrect or at least unintended according to the standard. However, I have used it on a small project and had good results. 

Thanks!</description>
		<content:encoded><![CDATA[<p>Hi Ian. Thanks for this post. I&#8217;ve recently started working on some multi threaded C++ apps. Currently using Trolltech/Qt&#8217;s libraries but I&#8217;ll probably also probably use Boost. Anyway, this discussion of volatile was very helpful, especially the use of volatile sig_atomic_t as a signal which will not require a semaphore or mutex.</p>
<p>At any rate, I&#8217;m curious about your view of this use of volatile, from Andrei Alexandrescu.<br />
<a href="http://www.ddj.com/cpp/184403766" rel="nofollow">http://www.ddj.com/cpp/184403766</a></p>
<p>It seems incorrect or at least unintended according to the standard. However, I have used it on a small project and had good results. </p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
