<?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: Effective C Tips #2 &#8211; Defining buffer sizes</title>
	<atom:link href="http://embeddedgurus.com/stack-overflow/2009/02/effective-c-tips-2-defining-buffer-sizes/feed/" rel="self" type="application/rss+xml" />
	<link>http://embeddedgurus.com/stack-overflow/2009/02/effective-c-tips-2-defining-buffer-sizes/</link>
	<description>Thoughts on embedded systems by Nigel Jones</description>
	<lastBuildDate>Wed, 28 Jul 2010 00:59:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/02/effective-c-tips-2-defining-buffer-sizes/comment-page-1/#comment-137</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Tue, 12 May 2009 12:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/02/22/effective-c-tips-2-defining-buffer-sizes/#comment-137</guid>
		<description>Yevheniy - you are quite right. Thanks for pointing this out. I&#039;ve modified the post and of course given you credit for the observation. Now I just have to go and modify my code!</description>
		<content:encoded><![CDATA[<p>Yevheniy &#8211; you are quite right. Thanks for pointing this out. I&#8217;ve modified the post and of course given you credit for the observation. Now I just have to go and modify my code!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yevheniy</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/02/effective-c-tips-2-defining-buffer-sizes/comment-page-1/#comment-136</link>
		<dc:creator>Yevheniy</dc:creator>
		<pubDate>Tue, 12 May 2009 10:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/02/22/effective-c-tips-2-defining-buffer-sizes/#comment-136</guid>
		<description>Nigel, when RX_BUF_SIZE is 1 it will also be considered as a valid size by your code. Thus it&#039;s better to check that RX_BUF_SIZE is not 1 as well.</description>
		<content:encoded><![CDATA[<p>Nigel, when RX_BUF_SIZE is 1 it will also be considered as a valid size by your code. Thus it&#8217;s better to check that RX_BUF_SIZE is not 1 as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miro Samek</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/02/effective-c-tips-2-defining-buffer-sizes/comment-page-1/#comment-135</link>
		<dc:creator>Miro Samek</dc:creator>
		<pubDate>Fri, 20 Mar 2009 18:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/02/22/effective-c-tips-2-defining-buffer-sizes/#comment-135</guid>
		<description>Nigel,According to your own teaching (in &quot;writing fast loops&quot; post) the head counter should count down rather than up. Then the comparison for wrap-around would be against zero, which is special and probably as fast as masking the head counter. Additional bonus is that the buffer size does not need to be power of 2 anymore, so you can save some RAM.</description>
		<content:encoded><![CDATA[<p>Nigel,According to your own teaching (in &#8220;writing fast loops&#8221; post) the head counter should count down rather than up. Then the comparison for wrap-around would be against zero, which is special and probably as fast as masking the head counter. Additional bonus is that the buffer size does not need to be power of 2 anymore, so you can save some RAM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nigel Jones</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/02/effective-c-tips-2-defining-buffer-sizes/comment-page-1/#comment-134</link>
		<dc:creator>Nigel Jones</dc:creator>
		<pubDate>Thu, 05 Mar 2009 00:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/02/22/effective-c-tips-2-defining-buffer-sizes/#comment-134</guid>
		<description>Bruno it&#039;s all about speed in this case. If you have a high frequency interrupt, then shaving a couple of op codes off the ISR handler can have a dramatic impact on the CPU utilization. BTW, the code you have suggested also has a potential problem if RX_BUF_SIZE is zero. I say &#039;potential&#039; because most half decent compilers would flag it. The lousy ones would not, and then you&#039;d have a problem.</description>
		<content:encoded><![CDATA[<p>Bruno it&#8217;s all about speed in this case. If you have a high frequency interrupt, then shaving a couple of op codes off the ISR handler can have a dramatic impact on the CPU utilization. BTW, the code you have suggested also has a potential problem if RX_BUF_SIZE is zero. I say &#8216;potential&#8217; because most half decent compilers would flag it. The lousy ones would not, and then you&#8217;d have a problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruno Santiago</title>
		<link>http://embeddedgurus.com/stack-overflow/2009/02/effective-c-tips-2-defining-buffer-sizes/comment-page-1/#comment-133</link>
		<dc:creator>Bruno Santiago</dc:creator>
		<pubDate>Wed, 25 Feb 2009 17:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfcdev.org/test-stack/2009/02/22/effective-c-tips-2-defining-buffer-sizes/#comment-133</guid>
		<description>Probably the code you posted is faster and the latency is determinisc, but why not just use a if?++RxHead;if( RxHead &gt;= RX_BUF_SIZE ){  RxHead = 0;}Maybe it´s lack of insinght, but in this case I really don´t see the point of complicating things.</description>
		<content:encoded><![CDATA[<p>Probably the code you posted is faster and the latency is determinisc, but why not just use a if?++RxHead;if( RxHead &gt;= RX_BUF_SIZE ){  RxHead = 0;}Maybe it´s lack of insinght, but in this case I really don´t see the point of complicating things.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
