<?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: C/C++: Using Bitfields Effectively</title>
	<atom:link href="http://tdistler.com/2008/07/21/cc-using-bitfields-effectively/feed" rel="self" type="application/rss+xml" />
	<link>http://tdistler.com/2008/07/21/cc-using-bitfields-effectively</link>
	<description>&#34;To err is human, but to really foul things up you need a computer.”</description>
	<lastBuildDate>Wed, 30 Nov 2011 07:44:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: anduril462</title>
		<link>http://tdistler.com/2008/07/21/cc-using-bitfields-effectively/comment-page-1#comment-16148</link>
		<dc:creator>anduril462</dc:creator>
		<pubDate>Thu, 08 Sep 2011 17:35:28 +0000</pubDate>
		<guid isPermaLink="false">http://tdistler.com/?p=120#comment-16148</guid>
		<description>Nice article, especially the race condition section.  There&#039;s one other big problem you missed though.  The order of allocation of bit-fields is implementation defined, so it&#039;s entirely possible, though unlikely, that the implementation puts the fields in some order other than what you specify.  That means, for example, that Base may actually occupy bits 16-31, and your direct read from a hardware register wont work.  To use this reliably, you must have a thorough understanding of your implementation (compiler, etc) and even then, it&#039;s not likely to be portable.  See section 6.7.2.1 of the C99 standard for a list of other implementation-defined and unspecified behaviors to look out for.</description>
		<content:encoded><![CDATA[<p>Nice article, especially the race condition section.  There&#8217;s one other big problem you missed though.  The order of allocation of bit-fields is implementation defined, so it&#8217;s entirely possible, though unlikely, that the implementation puts the fields in some order other than what you specify.  That means, for example, that Base may actually occupy bits 16-31, and your direct read from a hardware register wont work.  To use this reliably, you must have a thorough understanding of your implementation (compiler, etc) and even then, it&#8217;s not likely to be portable.  See section 6.7.2.1 of the C99 standard for a list of other implementation-defined and unspecified behaviors to look out for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: micahc</title>
		<link>http://tdistler.com/2008/07/21/cc-using-bitfields-effectively/comment-page-1#comment-5183</link>
		<dc:creator>micahc</dc:creator>
		<pubDate>Sun, 24 Jan 2010 20:28:31 +0000</pubDate>
		<guid isPermaLink="false">http://tdistler.com/?p=120#comment-5183</guid>
		<description>I would say that you should still lock the entire operation, from the caching to the writing back from the cache. If you don&#039;t, what happens when you read, release the lock, and then get interrupted by a process that manages to acquire the lock, cache, release the lock, perform the same block processing you were going to do, but with an updated register, reaquire the lock again, and then write. When the first thread runs again it will the clobber the register.</description>
		<content:encoded><![CDATA[<p>I would say that you should still lock the entire operation, from the caching to the writing back from the cache. If you don&#8217;t, what happens when you read, release the lock, and then get interrupted by a process that manages to acquire the lock, cache, release the lock, perform the same block processing you were going to do, but with an updated register, reaquire the lock again, and then write. When the first thread runs again it will the clobber the register.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: web development company</title>
		<link>http://tdistler.com/2008/07/21/cc-using-bitfields-effectively/comment-page-1#comment-4516</link>
		<dc:creator>web development company</dc:creator>
		<pubDate>Wed, 07 Oct 2009 13:43:01 +0000</pubDate>
		<guid isPermaLink="false">http://tdistler.com/?p=120#comment-4516</guid>
		<description>Hey, that was interesting,

Great information here on bitfields.

Thanks for writing about it</description>
		<content:encoded><![CDATA[<p>Hey, that was interesting,</p>
<p>Great information here on bitfields.</p>
<p>Thanks for writing about it</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mattepiu</title>
		<link>http://tdistler.com/2008/07/21/cc-using-bitfields-effectively/comment-page-1#comment-4443</link>
		<dc:creator>mattepiu</dc:creator>
		<pubDate>Fri, 18 Sep 2009 07:24:51 +0000</pubDate>
		<guid isPermaLink="false">http://tdistler.com/?p=120#comment-4443</guid>
		<description>In reply to nix: 
hum, yes and no.
You should know when you shouldn&#039;t mask/cache (usually you shouldn&#039;t) and when
you can do freely (for example to read the status of the struct just one time and then read the various flags of that register snapshot).

But I have to agree that usually caching isn&#039;t a good idea for volatile variables.</description>
		<content:encoded><![CDATA[<p>In reply to nix:<br />
hum, yes and no.<br />
You should know when you shouldn&#8217;t mask/cache (usually you shouldn&#8217;t) and when<br />
you can do freely (for example to read the status of the struct just one time and then read the various flags of that register snapshot).</p>
<p>But I have to agree that usually caching isn&#8217;t a good idea for volatile variables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nix</title>
		<link>http://tdistler.com/2008/07/21/cc-using-bitfields-effectively/comment-page-1#comment-3588</link>
		<dc:creator>nix</dc:creator>
		<pubDate>Wed, 17 Jun 2009 15:41:57 +0000</pubDate>
		<guid isPermaLink="false">http://tdistler.com/?p=120#comment-3588</guid>
		<description>The Example to mask &quot;volatile&quot; (in the &quot;Performance Problems&quot; ) should not be practised as volatile is having its own special purpose and masking this property will give unexpected behaviuor from the application.</description>
		<content:encoded><![CDATA[<p>The Example to mask &#8220;volatile&#8221; (in the &#8220;Performance Problems&#8221; ) should not be practised as volatile is having its own special purpose and masking this property will give unexpected behaviuor from the application.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mythic.glyph</title>
		<link>http://tdistler.com/2008/07/21/cc-using-bitfields-effectively/comment-page-1#comment-1601</link>
		<dc:creator>mythic.glyph</dc:creator>
		<pubDate>Wed, 25 Feb 2009 16:47:46 +0000</pubDate>
		<guid isPermaLink="false">http://tdistler.com/?p=120#comment-1601</guid>
		<description>short &amp; sweet.</description>
		<content:encoded><![CDATA[<p>short &amp; sweet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://tdistler.com/2008/07/21/cc-using-bitfields-effectively/comment-page-1#comment-778</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Tue, 29 Jul 2008 15:48:46 +0000</pubDate>
		<guid isPermaLink="false">http://tdistler.com/?p=120#comment-778</guid>
		<description>Fixed. Thanks!</description>
		<content:encoded><![CDATA[<p>Fixed. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: random dude</title>
		<link>http://tdistler.com/2008/07/21/cc-using-bitfields-effectively/comment-page-1#comment-769</link>
		<dc:creator>random dude</dc:creator>
		<pubDate>Tue, 29 Jul 2008 05:32:08 +0000</pubDate>
		<guid isPermaLink="false">http://tdistler.com/?p=120#comment-769</guid>
		<description>There appears to be an error in this blog post -  ‘virtual’ should likely be &#039;volatile&#039;</description>
		<content:encoded><![CDATA[<p>There appears to be an error in this blog post &#8211;  ‘virtual’ should likely be &#8216;volatile&#8217;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic page generated in 5.315 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-10 07:44:58 -->

