<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Send Receive Reply</title>
	<atom:link href="http://sendreceivereply.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sendreceivereply.wordpress.com</link>
	<description>QNX blog for development tricks, tips and insights</description>
	<lastBuildDate>Sat, 03 Sep 2011 14:53:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='sendreceivereply.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Send Receive Reply</title>
		<link>http://sendreceivereply.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sendreceivereply.wordpress.com/osd.xml" title="Send Receive Reply" />
	<atom:link rel='hub' href='http://sendreceivereply.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Application Builder for AGTDK: Storyboard Designer</title>
		<link>http://sendreceivereply.wordpress.com/2009/11/10/app-builder-for-agtdk-storyboard-designer/</link>
		<comments>http://sendreceivereply.wordpress.com/2009/11/10/app-builder-for-agtdk-storyboard-designer/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 03:48:05 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=105</guid>
		<description><![CDATA[So it is time for a shameless plug &#8230; but one with a distinct QNX angle =;-) After many months of hard work the developers at Crank Software (which includes myself) are ready to release Storyboard Suite 1.0, a multi-operating system, multi-platform designer driven graphical application builder. At this point you may be either bored or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=105&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So it is time for a shameless plug &#8230; but one with a distinct QNX angle =;-)</p>
<p>After many months of hard work the developers at <a href="http://www.cranksoftware.com">Crank Software</a> (which includes myself) are ready to release <a href="http://www.cranksoftware.com/products/crank_storyboard_suite.php">Storyboard Suite 1.0</a>, a multi-operating system, multi-platform designer driven graphical application builder.</p>
<p>At this point you may be either bored or intrigued &#8230; in either case you should <a href="http://www.cranksoftware.com/products/eval.php">go and start downloading your free version of Storyboard Suite now</a>!  If you are curious and don&#8217;t want to read &#8230; <a href="http://www.cranksoftware.com/video">go watch a Storyboard video</a>.</p>
<p>Still reading?  Great &#8230; now let&#8217;s talk about why this is great for QNX developers.  Up to this point if you wanted to build single mode graphical applications on top of <a href="http://www.qnx.com/products/middleware/graphics/adv_graphics.html">Advanced Graphics TDK (aka GF aka Core Graphics)</a> you had a few different options:</p>
<ol>
<li>Use <a href="http://www.adobe.com/flashplatform/">Flash</a>.  Flash is an awesome platform/tool and you can build incredibly creative and eye popping applications using all of the power and features that <a href="http://www.adobe.com">Adobe </a>has provided, with a ready pool of skilled Flash developers at the ready &#8230; but sometimes Flash is just too big a solution when all you want are a couple of screens and some data displays.</li>
<li>Use the rich C API&#8217;s and a (ported) widget library.  This isn&#8217;t impossible, but it also means that your software developers are the ones doing the user interface development (and porting) and re-interpreting the graphical design that some artist has created for the product.  This is time consuming and in my experience the software developer rarely <em>gets</em> the vision the graphical designer had in mind when he build the application screens.</li>
</ol>
<p><a href="http://www.cranksoftware.com/products/crank_storyboard_suite.php">Crank Storyboard Suite</a> is composed of two pieces that give you an <strong><em>awesome </em></strong>third alternative:</p>
<p><a href="http://www.cranksoftware.com/products/crank_storyboard_designer.php">Storyboard Designer</a> is an Eclipse based graphical application development environment.  It is based on a application hierarchy composed of screens, layers and controls and is driven by a simple, but extensible, event model.  Visual content comes directly from designers as either direct image imports including a <em>sweet </em>PSD file importer that can transform Photoshop layer elements directly into an application&#8217;s screen, layers and controls.</p>
<p>The tool exports a data bundle which is used as input for the  <a href="http://www.cranksoftware.com/products/crank_storyboard_embedded_engine.php">Storyboard Embedded Engine</a>, the runtime component that lives on your embedded system.  The engine is easily configurable and plugin based so that it is extensible to any new technologies or trends that appear in the market.</p>
<p>&#8230; did I mention that there are <a href="http://www.cranksoftware.com/video">videos that you can watch</a>?</p>
<p>By now your download should be finished, so go and give it a whirl.  A few simple examples are included along with a simulator that allows you to run applications you build on your native system if you don&#8217;t have an embedded target handy, and if you&#8217;ve got questions &#8230; well <a href="http://www.cranksoftware.com/forums/">we&#8217;ve got forums to ask them in</a>.</p>
<p>With 1.0 now out the door 1.1 (or 1.0.1?) is coming along quick with a focus on user driven feedback and enhancements!  Things like providing additional  <a href="http://www.webkit.org">WebKit</a> integration for various customers and making simple graphical transforms even easier .. oh and I thought I saw an OpenGLES renderer running in the office too!</p>
<p>Thomas</p>
<p><strong>Note:</strong> I didn&#8217;t include <a href="http://www.qnx.com/products/middleware/graphics/photon.html">Photon </a>in the above list, since really if you are using Photon you&#8217;ve got a ready solution for building applications, widgets and an application builder at the ready.  It isn&#8217;t likely that you graphics designers will find it an environment they want to work in, but they could learn it if they wanted to.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=105&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2009/11/10/app-builder-for-agtdk-storyboard-designer/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Combining System Profiler search results</title>
		<link>http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/</link>
		<comments>http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 14:24:17 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=86</guid>
		<description><![CDATA[In the last few posts [1][2][3] I&#8217;ve been talking about how the developers at Crank have been finding and addressing some of the performance issues with WebKit.    One of the ways in which we highlighted this performance issue was to take advantage of the System Profiler&#8217;s Trace Search and the new Path Manager trace events that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=86&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-95" href="http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/searchconnect/"></a>In the last few posts [<a href="http://sendreceivereply.wordpress.com/2009/02/28/less-webkit-is-more-webkit/">1</a>][<a href="http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/">2]</a>[<a href="http://sendreceivereply.wordpress.com/2009/02/07/making-tracing-even-easier/">3</a>] I&#8217;ve been talking about how the <a href="http://www.cranksoftware.com">developers at Crank</a> have been finding and addressing some of the performance issues with <a href="http://www.webkit.org">WebKit</a>.   </p>
<p>One of the ways in which we highlighted this performance issue was to take advantage of the System Profiler&#8217;s <a href="http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/">Trace Search</a> and the new Path Manager trace events that are available in the 6.4.0 Neutrino kernel.   This search gives us a quick view into what files are being opened up</p>
<p><a rel="attachment wp-att-79" href="http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/fileopensearch/"><img class="aligncenter size-full wp-image-79" title="fileopensearch" src="http://sendreceivereply.files.wordpress.com/2009/02/fileopensearch.png?w=479&#038;h=240" alt="fileopensearch" width="479" height="240" /></a> </p>
<p>These search results give us very usefull information, but they are kind of isolated.  One of the neat things that the Trace Search dialog allows you to do is to combine search conditions together using the &amp;&amp; and || operators to AND and OR conditions which can give your search results a bit more of an impact.  </p>
<p><a rel="attachment wp-att-94" href="http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/searchandor/"><img class="aligncenter size-full wp-image-94" title="searchandor" src="http://sendreceivereply.files.wordpress.com/2009/03/searchandor.png?w=480&#038;h=101" alt="searchandor" width="480" height="101" /></a> </p>
<p>For example, if we wanted to get a rough estimate of the kind of effect that each of these file opens was having on our system, then we might do a compound search joining both the FileOpen information with the number of times that we perform a ConnectAttach to actually establish a connection to a server:</p>
<p><a rel="attachment wp-att-96" href="http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/searchconnect1/"><img class="aligncenter size-full wp-image-96" title="searchconnect1" src="http://sendreceivereply.files.wordpress.com/2009/03/searchconnect1.png?w=440&#038;h=262" alt="searchconnect1" width="440" height="262" /></a></p>
<p>Then enter a compound condition:</p>
<p><a rel="attachment wp-att-97" href="http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/searchcombined/"><img class="aligncenter size-full wp-image-97" title="searchcombined" src="http://sendreceivereply.files.wordpress.com/2009/03/searchcombined.png?w=480&#038;h=201" alt="searchcombined" width="480" height="201" /></a></p>
<p>Now when we do our search, we get a much more interesting set of results that gives us an indication of just how many different servers might be involved when we are doing all of this additional file access:</p>
<p><a rel="attachment wp-att-99" href="http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/searchresults1/"></a><a rel="attachment wp-att-100" href="http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/searchresults2/"><img class="aligncenter size-full wp-image-100" title="searchresults2" src="http://sendreceivereply.files.wordpress.com/2009/03/searchresults2.png?w=480&#038;h=115" alt="searchresults2" width="480" height="115" /></a><a rel="attachment wp-att-99" href="http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/searchresults1/"></a></p>
<p>I&#8217;ve cut out some of the columns here to try and fit the content in, but we can now see the FileOpen results with the ConnectAttach() calls inter-mingled.  The handy thing with this information is that you can now quickly establish a few cost metrics based on the observed results.  This can be handy when you are trying to determine what areas may be worth persuing for further optimization gains.</p>
<p>Happy Optimizing.</p>
<p>Thomas</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=86&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2009/03/20/combining-system-profiler-search-results/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2009/02/fileopensearch.png" medium="image">
			<media:title type="html">fileopensearch</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2009/03/searchandor.png" medium="image">
			<media:title type="html">searchandor</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2009/03/searchconnect1.png" medium="image">
			<media:title type="html">searchconnect1</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2009/03/searchcombined.png" medium="image">
			<media:title type="html">searchcombined</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2009/03/searchresults2.png" medium="image">
			<media:title type="html">searchresults2</media:title>
		</media:content>
	</item>
		<item>
		<title>Less WebKit is More WebKit</title>
		<link>http://sendreceivereply.wordpress.com/2009/02/28/less-webkit-is-more-webkit/</link>
		<comments>http://sendreceivereply.wordpress.com/2009/02/28/less-webkit-is-more-webkit/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 17:51:34 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=91</guid>
		<description><![CDATA[&#8230; at least that is true in the embedded space where your CPU footprint is just as important as your memory footprint and your storage (&#8220;on-disk&#8221;) footprint. As a follow up to the Crank WebKit performance &#8220;shark week&#8221; we decided that since runtime performance was starting to look pretty good we should turn our sights to the memory [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=91&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8230; at least that is true in the embedded space where your CPU footprint is just as important as your memory footprint and your storage (&#8220;on-disk&#8221;) footprint.</p>
<p>As a follow up to the <a href="http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/">Crank WebKit performance &#8220;shark week&#8221;</a> we decided that since runtime performance was starting to look pretty good we should turn our sights to the memory footprint that the WebKit port was taking on our systems.  </p>
<p>Due to the fact that this was a brand new browser engine (WebKit), with a minimal custom front end (Crank Launcher), ported to a brand new graphics framework from QNX (AG/GF), there was really no &#8220;apples to apples&#8221; comparable to use (though <a href="http://www.cranksoftware.com">Crank</a> does have many internal versions of <a href="http://www.mozilla.com/firefox">Firefox</a>).  This isn&#8217;t as bad as it seems &#8230; in the world of software, attempting to &#8220;match&#8221; what previous software generations did rarely helps to advance the state of the technology.  Our goal was to take a fixed block of time and make the biggest impact that we could.</p>
<p>We took base measurements off many different sites, but here I&#8217;ll use the plain old <a href="http://www.google.com">www.google.com</a> as the reference.  When we loaded that site up, after all of the shared objects were loaded and we finished rendering the page, we found that we would often hit close to 30M of memory being used!  That was a pretty outrageous number.</p>
<p>There are lots of different tools for memory analysis, most of which don&#8217;t scale appropriately or provide accurate enough results when used on an application as disjoint as WebKit:  It uses both C and C++ object smart pointers, it mixes custom allocators and the system allocator (malloc) and the usage and behaviour of memory allocation is completely different for each of the shared libraries used (ie libc, libxml, freetype, icu, libjpeg, &#8230;).</p>
<p>Since we were coming off the <a href="http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/">week of CPU performance analysis</a> we had lots of different trace files hanging around so we decided to take a crank at them with the System Profiler.   In addition to the new Path Manager event in 6.4.0, there are two system events for tracking mmap events &#8230; one for named events and one for un-named events. </p>
<p>We set up some traces, using the same technique as with the <a href="http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/">Path Manager events</a>, and leveraged that information to give us some insight to what major allocations (those that routed to mmap()) were occuring and correspondingly to see what shared libraries, files and other objects were being mmap&#8217;ed by WebKit. </p>
<p>This tuning once again pointed us to the <a href="http://www.freetype.org">font handing </a> and some less than optimal code in the way that WebKit uses the <a href="http://www.freetype.org">FreeType</a> and <a href="http://www.fontconfig.org">FontConfig</a> API&#8217;s.  After last week&#8217;s CPU tuning experience with the font configuration, I&#8217;m rapidly coming to the conclusion that fonts and internationalization is nothing but a work generator!</p>
<p>Just for confirmation, we dropped the entire application into the debugger, put a breakpoint on the mmap() function and stepped through the major WebKit operations all while double verifying using <em>pidin mem</em>  to see the memory effect on the system.</p>
<p>To make a short story long, we concluded that there is no reason to map in Asian fonts, especially at 6M a pop, if you have no characters on screen that require such functionality!  Not a revelation that most people would be knocked over by, but the effect on this software was.  With a little bit of tuning around the fonts and a few other memory areas, our memory footprint rocketted down to a very respectable (and stable) 4M when we target <a href="http://www.google.com">www.google.com</a>. </p>
<p>&#8230; and of course to speak to the title, when you drop from 32M to 4M (the less) we pick up a few extra CPU cycles (the more) in the general operation.  We&#8217;ve got a few more <a href="http://www.cranksoftware.com/blog">tricks up our sleeve</a> but we&#8217;re getting very close to our GF release point!</p>
<p>Thomas</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=91&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2009/02/28/less-webkit-is-more-webkit/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Find font, open font, close font &#8230; Go WebKit! Go!</title>
		<link>http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/</link>
		<comments>http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 15:00:56 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=76</guid>
		<description><![CDATA[File system access is pretty fast &#8230; if you are running on a desktop system with lots of caching resources and no real requirement to synch/flush content to the backing media until it you have idle cycles.  You can do a lot of churning and never even have it poke to the top of any [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=76&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>File system access is pretty fast &#8230; if you are running on a desktop system with lots of caching resources and no real requirement to synch/flush content to the backing media until it you have idle cycles.  You can do a lot of churning and never even have it poke to the top of any desktop performance metering tools.</p>
<p>If you are running an embedded system though, filesystem access is your nemesis.  Not only does the media that you are interfacing with have generally slower access times, but the environment much more demanding.  You get the double whammy of fewer CPU cycles to spare and little or no additional cache memory to compensate for slow device access.  All that, and you&#8217;ve got some pesky power monitor that  keeps trying to get the system to idle so it can sleep and save a few milliwatts of power.</p>
<p>The customers that have approached Crank software about <a href="http://www.webkit.org">WebKit</a> integration all have embedded systems that they are running, so as part of my <a href="http://sendreceivereply.wordpress.com/2009/02/07/making-tracing-even-easier/">WebKit optimization week</a> I started out with the easy targets: Excessive filesystem access. </p>
<p>Using the <a href="http://community.qnx.com/sf/wiki/do/viewPage/projects.ide/wiki/SystemProfiler">System Profiler</a> (<a href="http://www.abraham-maslow.com/m_motivation/Maslow_Quotes.asp">a handy hammer for all my problems</a>) and QNX 6.4.0 it is dead easy to highlight those expensive pathname based filesystem operations  (open,opendir,stat etc):</p>
<ol>
<li>Open a trace log file and open the search dialog; <strong>Search &gt; Search</strong> or just  <strong>Ctrl+H</strong> in the editor. </li>
<li>Select the <strong>Trace Search</strong> tab icon and select <strong>Add</strong> to create a new condition</li>
<li>Create the condition using the <strong>System</strong> class and the <strong>Path Manager</strong> code</li>
</ol>
<p style="text-align:center;"><a rel="attachment wp-att-80" href="http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/conditiondef1/"><img class="size-full wp-image-80  aligncenter" title="conditiondef1" src="http://sendreceivereply.files.wordpress.com/2009/02/conditiondef1.png?w=480&#038;h=402" alt="conditiondef1" width="480" height="402" /></a></p>
<p>Now if you use this condition you will see all of the path based file operations.  You can use the data fields in the event such as process or pid to filter the events down to what you are interested in.  Running this query, focusing in on the the WebKit based application as it launched against a test website yeilded:</p>
<p> </p>
<p style="text-align:center;"><a rel="attachment wp-att-79" href="http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/fileopensearch/"><img class="size-full wp-image-79 aligncenter" title="fileopensearch" src="http://sendreceivereply.files.wordpress.com/2009/02/fileopensearch.png?w=479&#038;h=240" alt="fileopensearch" width="479" height="240" /></a></p>
<p>Unbelievable!  Considering that this was a trace that lasted only 30 seconds, <em>2100</em>file accesses seems to be a little bit unreasonable and either a bug or an area ripe for optimization.  The pathname provided us with lots of insight into what was happening (lots and lots of font access).  <a href="http://www.cranksoftware.com">Our</a> current port uses <a href="http://www.fontconfig.org">FontConfig</a> to manage the font mappings and <a href="http://www.freetype.org/">FreeType</a> to perform the rendering. </p>
<p>Our first change was to create a more &#8216;embedded friendly&#8217; font configuration file.  By default the font configuration is scanned every few seconds to support dynamic font addition and removal.  Usefull for desktops, but not needed by most embedded systems.  Doing that, we picked up a few seconds of improvement, but were still churning. </p>
<p>Time to dive into the code and correlate it with our trace results:</p>
<p>The traces showed repetitive file access for the same font, so we added a simple filesystem name cache and used <a href="http://freetype.sourceforge.net/freetype2/docs/reference/ft2-cache_subsystem.html">FreeType&#8217;s internal cache</a> to avoid this churn.  This dropped the file accesses by about an eighth and picked up another few seconds of improvement.  Not bad for a bit of effort, but not the big gain we were looking for.</p>
<p>The traces still showed that we were hitting the font configuration directories several times over, definitely not the intention of the source as far as we could tell.  After a day of code inspection, the culprit turned out to be an innocent looking routine that was responsible for cleaning up temporary font resources &#8230; unfortunately the cleanup also destroyed a static font configuration, causing it to be re-created each time a new font request was made!  Fixing that bug and re-running our test load:</p>
<p style="text-align:center;"><a rel="attachment wp-att-82" href="http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/fileopensearchnew1/"><img class="size-full wp-image-82 aligncenter" title="fileopensearchnew1" src="http://sendreceivereply.files.wordpress.com/2009/02/fileopensearchnew1.png?w=478&#038;h=240" alt="fileopensearchnew1" width="478" height="240" /></a></p>
<p>Now <em>that&#8217;s </em>looking better!  While the number of file accesses is still high <em>(318)</em> it isn&#8217;t completely ridiculous <em>(2100) </em>and even better, most of those initial accesses are the shared library loading and don&#8217;t occur during the steady state operations of the browser.  The even better news is the time savings that came with this reduction &#8230; it dropped a full ten (10) seconds off the general load time!  We&#8217;ve totally moving from <a href="http://www.tetesaclaques.tv/video.php?vid=231">Super Sloppy to Super Shiny!</a> <em> (thanks Mario and Paul!).</em></p>
<p>If you want to get more details on the <a href="http://www.cranksoftware.com/downloads/">WebKit port</a>, we&#8217;ve just opened up the <a href="http://www.cranksoftware.com/blog">Crank Software blog</a> where we&#8217;re planning on posting updates directly there as we make progress and make it available.</p>
<p>Thomas</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=76&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2009/02/16/find-font-open-font-close-font-go-webkit-go/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2009/02/conditiondef1.png" medium="image">
			<media:title type="html">conditiondef1</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2009/02/fileopensearch.png" medium="image">
			<media:title type="html">fileopensearch</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2009/02/fileopensearchnew1.png" medium="image">
			<media:title type="html">fileopensearchnew1</media:title>
		</media:content>
	</item>
		<item>
		<title>Tracing WebKit made easy</title>
		<link>http://sendreceivereply.wordpress.com/2009/02/07/making-tracing-even-easier/</link>
		<comments>http://sendreceivereply.wordpress.com/2009/02/07/making-tracing-even-easier/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 16:27:22 +0000</pubDate>
		<dc:creator>thomasfletcher</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=72</guid>
		<description><![CDATA[I spent most of the past week doing some performance tuning on the port of WebKit to QNX Neutrino that Crank Software is doing.  There are lots of different tools I could use but nothing beats the System Profiler when you want to get a quick overview of what is going on with your application and its [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=72&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I spent most of the past week doing some performance tuning on the <a href="http://sendreceivereply.wordpress.com/2008/11/10/ive-been-workin-on-the-webkit-all-the-live-long-day/">port of WebKit to QNX Neutrino</a> that <a href="http://www.cranksoftware.com">Crank Software</a> is doing.  There are lots of different tools I could use but nothing beats the <a href="http://www.qnx.com/products/tools/optimization.html">System Profiler</a> when you want to get a quick overview of what is going on with your application <em>and</em> its effect on the rest of the system.</p>
<p>Since we&#8217;re building <a href="http://webkit.org/">WebKit </a>ourselves, I was able to add in a number of user trace events that had specific meaning for the <a href="http://webkit.org/">WebKit </a>performance metrics we were looking at.  With a few events, it made repetitive measurements of things like application load time, page load time and network latency a snap to calculate.</p>
<p>Prior to the 6.4.0 release, if you wanted to add in your own custom trace events you had to use the <a href="http://www.qnx.com/developers/docs/6.4.0/neutrino/lib_ref/t/traceevent.html">TraceEvent() API</a>.  This API does <em>way </em>more than just insert trace events, it is the swiss army knife of calls to configure and control the entire kernel instrumentation system.  At the end of the day, I was always having to go back to the documentation just to double check the arguments required to push out an event with a string in it:</p>
<p>TraceEvent(<span class="const">_NTO_TRACE_INSERTUSRSTREVENT, &lt;id&gt;, &lt;string&gt;)</span></p>
<p><span class="const">Of course if you wanted anything more than a simple string, you had to fiddle with sprintf&#8217;s, allocate buffers etc.  A number of times I simply would insert five or six trace events in a row rather than doing all that extra work &#8230; which of course meant havin log files cluttered with extra events I eventually needed to filter out to see what I wanted.</span></p>
<p><span class="const">With 6.4.0 a whole slew of trace_* functions were added into the <a href="http://community.qnx.com/integration/viewcvs/viewcvs.cgi/trunk/services/system/public/sys/trace.h?root=coreos_pub&amp;rev=206799&amp;system=exsy1001&amp;view=log">&lt;sys/trace.h&gt; </a>header.  Now instead of having to remember the specific define for the TraceEvent() call, I can just do:</span></p>
<p><span class="const"> trace_logf(&lt;id&gt;, &lt;printf style format string&gt;);</span></p>
<p><span class="const">That is <em>way</em> easier and <em>far</em> more convenient &#8230; makes tracing almost as much fun as using my <a href="https://www.shamwow.com/">ShamWow</a>!  </span></p>
<p><span class="const">Unfortunately the functions aren&#8217;t documented yet, but they were modelled using the same style as the slog_* functions, and you have to be carefull about their use within interrupt handlers but things like the trace_here() function can offer interesting insight using the other optimization tools.</span></p>
<p><span class="const">&#8230; and in case you were wondering about the <a href="http://webkit.org/">WebKit </a>optimization results, they are looking good.  We&#8217;ve eliminated most of the superfluous work that hit embedded systems (especially non-x86 targets) harder than desktops and hope to be making a very usable GF based version available soon!</span></p>
<p><span class="const">Happy Tracing!</span></p>
<p><span class="const">Thomas</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=72&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2009/02/07/making-tracing-even-easier/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/64c14d25965f308a816fdb1170b11d32?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thomasfletcher</media:title>
		</media:content>
	</item>
		<item>
		<title>I&#8217;ve been workin&#8217; on the WebKit all the live long day &#8230;</title>
		<link>http://sendreceivereply.wordpress.com/2008/11/10/ive-been-workin-on-the-webkit-all-the-live-long-day/</link>
		<comments>http://sendreceivereply.wordpress.com/2008/11/10/ive-been-workin-on-the-webkit-all-the-live-long-day/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 14:24:17 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>
		<category><![CDATA[AGTDK]]></category>
		<category><![CDATA[Crank]]></category>
		<category><![CDATA[Neutrino]]></category>
		<category><![CDATA[Photon]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=68</guid>
		<description><![CDATA[&#8230; WebKit for Neutrino 6.4.0 that is Lots has gone on since my last post on SRR.  After finishing up my parental leave last year  I decided that after working at QNX for nearly 10 years it was time for a change and took on a role at Crank Software. We&#8217;re doing a lot of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=68&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8230; <a href="http://www.cranksoftware.com/pre-release/" target="_self">WebKit for Neutrino 6.4.0</a> that is</p>
<p>Lots has gone on since my last post on SRR.  After finishing up my <a href="http://sendreceivereply.wordpress.com/2007/12/28/happy-holidays-colins-in-charge/" target="_self">parental leave last year</a>  I decided that after working at QNX for nearly 10 years it was time for a change and took on a role at <a href="http://www.cranksoftware.com/">Crank Software</a>.</p>
<p>We&#8217;re doing a lot of interesting things at <a href="http://www.cranksoftware.com/">Crank</a>, mostly to do with graphics and improving the way people integrate graphical content into their embedded products. </p>
<p>Crank is doing a lot of work with customers who base their user interface designs on what Apple&#8217;s <a href="http://www.apple.com/iphone/">iPhone</a> and <a href="http://www.apple.com/ipodtouch/">iTouch</a>can do, but want to do it on systems with less powerful CPU&#8217;s, smaller memory capacity and less capable graphics engines.</p>
<p>Oh yeah &#8230; and for those devices that are network connected they also want to run <a href="http://webkit.org/">WebKit</a>, the engine under <a href="http://www.apple.com/safari/">Apple&#8217;s Safari web browser</a>. </p>
<p>As part of addressing these needs (better, faster, smaller) Crank has ported <a href="http://www.cranksoftware.com/pre-release/">WebKit to QNX Neutrino</a>, and since web browsers and graphical applications go hand in hand these days, we plan to provide assistance and support on this technology. </p>
<p style="text-align:left;">If you are keen, you can try out an advance pre-release version of the WebKit engine by downloading it from  <a href="http://www.cranksoftware.com/pre-release/">http://www.cranksoftware.com/pre-release/</a>.</p>
<p>This is a snapshot of our development from a month ago after we got the initial port running and passing the basic browser tests, lots of improvements have been made since then and we&#8217;ll update it when we hit a good stability point.</p>
<p>Our initial ports run on both <a href="http://www.qnx.com/products/neutrino_rtos/">Neutrino 6.3.2 and 6.4.0</a>.  We currently have <a href="http://www.qnx.com/products/middleware/graphics/photon.html">Photon microGUI</a> versions and expect to have an <a href="http://www.qnx.com/products/middleware/graphics/adv_graphics.html">AGTDK</a> based version out in the coming weeks.</p>
<p>The development on <a href="http://webkit.org/blog/">WebKit is very active</a>, with lots of work going on in all areas from user interface to scalability to scripting performance.  Getting the initial port up and running wasn&#8217;t a trivial amount of work, and we hope to work with the WebKit developers to back port our changes. </p>
<p>In the mean time, if you run Neutrino and wanted to be like all the other <a href="http://geeks.pirillo.com/group/webkitusers">cool kids out there running WebKit</a> go check out the pre-release and let us know how it works for you! </p>
<p>Thomas</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=68&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2008/11/10/ive-been-workin-on-the-webkit-all-the-live-long-day/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>QNX 6.4.0 loves ARM v6</title>
		<link>http://sendreceivereply.wordpress.com/2008/10/31/qnx-640-loves-arm-v6/</link>
		<comments>http://sendreceivereply.wordpress.com/2008/10/31/qnx-640-loves-arm-v6/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 19:49:03 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>
		<category><![CDATA[QNX ARM]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=62</guid>
		<description><![CDATA[One of the really cool things about 6.4.0 is the support for ARM v6 chips. You may recall that ARM v5 chips have a somewhat icky cache implementation, resulting in an unfortunate limititation in the virtual address range per process, and also a limitation in the number of processes in the system.  It&#8217;s all described [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=62&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the really cool things about 6.4.0 is the support for ARM v6 chips.</p>
<p>You may recall that ARM v5 chips have a somewhat icky cache implementation, resulting in an unfortunate limititation in the virtual address range per process, and also a limitation in the number of processes in the system.  It&#8217;s all described <a title="arm memory" href="http://www.qnx.com/developers/docs/6.4.0/neutrino/prog/arm_memory.html" target="_blank">here</a>, if you are interested.</p>
<p>The really cool news is that the v6 architecture doesn&#8217;t have this problem (it has a physically tagged cache), and thus the limitation has been removed (read all about it <a title="migrating to ARMv6" href="http://www.qnx.com/developers/docs/6.4.0/neutrino/technotes/migrating_to_ARMv6.html" target="_blank">here</a>!).</p>
<p>Not only that, but the gcc 4.2.4 compiler is much better for ARM, resulting in much better code generation.</p>
<p>QNX 6.4.0 now also supports the Vector Floating Point unit &#8211; which can make a big difference &#8211; read about it <a title="vector floating point" href="http://www.qnx.com/developers/docs/6.4.0/neutrino/technotes/vector_floating_point.html" target="_blank">here.</a></p>
<p>Last but not least, the ARM kernel and Image Filesystem are now mapped with large 1Mb pages.  This really boosts the performance of kernel calls &#8211; since we are using way fewer TLBs.</p>
<p>The fact that 6.4.0 supports large pages is also important for userland programs, especially on ARM &#8211; I&#8217;ll get into that in another post.</p>
<p>Colin</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=62&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2008/10/31/qnx-640-loves-arm-v6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>QNX 6.4.0 &#8211; go get it!</title>
		<link>http://sendreceivereply.wordpress.com/2008/10/31/qnx-640-go-get-it/</link>
		<comments>http://sendreceivereply.wordpress.com/2008/10/31/qnx-640-go-get-it/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 14:23:44 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>
		<category><![CDATA[QNX Release]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=58</guid>
		<description><![CDATA[This is why we&#8217;ve been so quiet of late &#8211; a LOT of work has gone into QNX 6.4.0 &#8211; the first full release of the OS in &#8230; well, it&#8217;s been a while! I&#8217;ll be posting about some of the new features in 6.4.0 &#8211; but how about first you go and download it! [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=58&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is why we&#8217;ve been so quiet of late &#8211; a LOT of work has gone into QNX 6.4.0 &#8211; the first full release of the OS in &#8230; well, it&#8217;s been a while!</p>
<p>I&#8217;ll be posting about some of the new features in 6.4.0 &#8211; but how about first you go and download it!</p>
<p><a title="http://www.qnx.com/products/index_sdp_640.html" href="http://www.qnx.com/products/index_sdp_640.html" target="_blank">http://www.qnx.com/products/index_sdp_640.html</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=58&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2008/10/31/qnx-640-go-get-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>Daddy, the network is down&#8230;</title>
		<link>http://sendreceivereply.wordpress.com/2008/05/12/daddy-the-network-is-down/</link>
		<comments>http://sendreceivereply.wordpress.com/2008/05/12/daddy-the-network-is-down/#comments</comments>
		<pubDate>Mon, 12 May 2008 22:18:56 +0000</pubDate>
		<dc:creator>xtang</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=46</guid>
		<description><![CDATA[The gateway of my home network, is not one of those &#8220;broadband router&#8221;. Instead, it&#8217;s an old Pentium 200Hz machine in my basement, running, of cause, QNX. Why am I doing this? I think it&#8217;s one of those &#8220;because I can&#8221; thing. Since I compiled my own TCPIP stack, I can really know every detail [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=46&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The gateway of my home network, is not one of those &#8220;broadband router&#8221;. Instead, it&#8217;s an old Pentium 200Hz machine in my basement, running, of cause, QNX. Why am I doing this? I think it&#8217;s one of those &#8220;because I can&#8221; thing. Since I compiled my own TCPIP stack, I can really know every detail of the packets in and out of my gateway. Another reason is, of cause, I like to &#8220;live on the edge&#8221;.</p>
<p>Yes, it&#8217;s really &#8220;bleeding edge&#8221;, though a lot of benifit and fun of running the HEAD branch stack, one of the disadvantage is, while in it&#8217;s early stage, the stack &#8220;crashes&#8221;. The good thing is I have the core dump I could look at, but the bad thing is, that&#8217;s also when my kids started shutting at me.</p>
<p>Those of you who had been managed a home network, would really understand how stressful this is. :) Fortunatly, soon my kids find out the &#8220;engineering way&#8221; to fix the problem. They went down to the basement, press the little reset button on the old Pentinum, give it a couple of minutes, and wola, everything comes back. </p>
<p>This works well for a while, but one day while I was at home along, the stack on gateway gone again. I have to get out of my comfort couch, went down to the basement and reset it myself. I said to myself, &#8220;why can&#8217;t I just write a program to resetart the network if it&#8217;s crashed&#8221;, after all, QNX is all about Micro Kernel and Modular System, isn&#8217;t it? </p>
<p>That&#8217;s where my &#8220;sockmon&#8221; program cames from. Once started, it will keeps on monitoring if TCPIP stack is still running, if it disappered, &#8220;sockmon&#8221; will try to execute a shell script you gave it on command line, to re-start the network. If the restart somehow failed after some try, then it will just reboot the system.</p>
<p>You may wonder &#8220;how do you know if TCPIP stack is there or not&#8221;? Well, QNX resource manager have builtin notification to all connected clients if their server disappeared. So all you need is to establish a connection to the tcpip stack (by call socket()), and setup to waitfor the notification events.</p>
<p>I have include the source here, the &#8220;notification&#8221; thing above is true for ALL resource manager (unless the manager is written in such way that turned off this feature), so you can easilly extended my program to any resource manager. Just give it a config file to read about which resource manager (what namespace you care) to watch out, and what to do (which script to execute) if the manager went away.</p>
<p>I will leave this for reader exercise, but if you did that, you would realiz you just got yourself a simple, basic, HA program.</p>
<p> -xtang</p>
<blockquote><p>#include &lt;stdio.h&gt;<br />
#include &lt;errno.h&gt;<br />
#include &lt;unistd.h&gt;<br />
#include &lt;process.h&gt;<br />
#include &lt;signal.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;syslog.h&gt;<br />
#include &lt;sys/procmgr.h&gt;<br />
#include &lt;sys/sysmgr.h&gt;<br />
#include &lt;sys/neutrino.h&gt;<br />
#include &lt;sys/socket.h&gt;</p>
<p>int main(int argc, char **argv)<br />
{<br />
        char *script;<br />
        int sd, chid, fcount;<br />
        struct _pulse pulse;</p>
<p>        if (argc &lt; 2) {<br />
                fprintf(stderr, &#8220;sockmon &lt;re-start script&gt;\n&#8221;);<br />
                return -1;<br />
        }</p>
<p>        script = argv[1];<br />
        if (access(script, X_OK) != 0) {<br />
                fprintf(stderr, &#8220;access(&#8216;%s&#8217;): %s\n&#8221;, script, strerror(errno));<br />
                return -1;<br />
        }</p>
<p>        /* creat a channel for accept COIDDEATH pulse */<br />
        if ((chid = ChannelCreate(_NTO_CHF_COID_DISCONNECT)) == -1) {<br />
                perror(&#8220;ChannelCreate&#8221;);<br />
                return -1;<br />
        }</p>
<p>        /* don&#8217;t care about the child */<br />
        signal(SIGCHLD, SIG_IGN);</p>
<p>#ifdef NDEBUG<br />
        if (procmgr_daemon(0, PROCMGR_DAEMON_NOCLOSE) == -1) {<br />
                perror(&#8220;procmgr_daemon&#8221;);<br />
                return -1;<br />
        }<br />
#endif</p>
<p>        openlog(&#8220;sockmon&#8221;, LOG_PID, LOG_DAEMON);<br />
        setlogmask(LOG_UPTO(LOG_INFO));</p>
<p>        for (;;)<br />
        {<br />
                fcount = 0;</p>
<p>                /* connect to tcpip to monitoring, give it 30 seconds, if still can&#8217;t<br />
                 * connect, reboot the system<br />
                 */<br />
                while ((sd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {<br />
                        if (++fcount &gt;= 6) {<br />
                                syslog(LOG_ERR, &#8220;Can&#8217;t connect to socket after 3 minutes, reboot&#8230;&#8221;<br />
);<br />
                                spawnl(P_NOWAIT, &#8220;/bin/slay&#8221;, &#8220;slay&#8221;, &#8220;-f&#8221;, &#8220;syslogd&#8221;, NULL);<br />
                                sleep(1);<br />
                                sysmgr_reboot();<br />
                                return 0;<br />
                        }<br />
                        sleep(5);<br />
                        syslog(LOG_INFO, &#8220;Connect to Socket failed: %m&#8221;);<br />
                }</p>
<p>                syslog(LOG_INFO, &#8220;Connected to Network, start monitoring&#8230;&#8221;);<br />
                if (MsgReceivePulse(chid, &amp;pulse, sizeof(pulse), NULL) == -1) {<br />
                        syslog(LOG_ERR, &#8220;MsgReceivePulse(): %m&#8221;);<br />
                        return -1;<br />
                }</p>
<p>                if (pulse.code != _PULSE_CODE_COIDDEATH) {<br />
                        syslog(LOG_ERR, &#8220;MsgReceivePulse(): %m&#8221;);<br />
                        return -1;<br />
                }</p>
<p>                if (pulse.value.sival_int != sd) {<br />
                        syslog(LOG_ERR, &#8220;COIDDEATH pulse for %d\n&#8221;, pulse.value);<br />
                        continue;<br />
                }</p>
<p>                syslog(LOG_INFO, &#8220;Network gone, restarting&#8230;&#8221;);<br />
                spawnl(P_WAIT, &#8220;/bin/ksh&#8221;, &#8220;/bin/ksh&#8221;, script, NULL);<br />
        }</p>
<p>        return 0;<br />
}</p></blockquote>
<blockquote><p> </p></blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/46/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/46/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=46&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2008/05/12/daddy-the-network-is-down/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ca7b2d2f6abde1c636237bc7d9c8a24?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xtang</media:title>
		</media:content>
	</item>
		<item>
		<title>It&#8217;s time to OD</title>
		<link>http://sendreceivereply.wordpress.com/2008/04/23/its-time-to-od/</link>
		<comments>http://sendreceivereply.wordpress.com/2008/04/23/its-time-to-od/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 19:41:25 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[dtrace]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[QNX]]></category>
		<category><![CDATA[Tracing]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=56</guid>
		<description><![CDATA[At long last, the dtrace project at Foundry27 is public. It&#8217;s really still in the formative stages, but if you want to download the source and hack around a bit, or even just laugh at the dirty hacks, feel free! I&#8217;m slowing working on a more thorough port, but the prototype is a nice forum [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=56&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At long last, the <a title="dtrace project" href="http://community.qnx.com/sf/projects/dtrace">dtrace project</a> at <a href="http://community.qnx.com">Foundry27</a> is public.  It&#8217;s really still in the formative stages, but if you want to download the source and hack around a bit, or even just laugh at the dirty hacks, feel free!</p>
<p>I&#8217;m slowing working on a more thorough port, but the prototype is a nice forum to play around in.</p>
<p>Have fun&#8230;</p>
<p>Colin</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/56/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/56/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=56&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2008/04/23/its-time-to-od/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>No fault of your own&#8230;</title>
		<link>http://sendreceivereply.wordpress.com/2008/04/18/no-fault-of-your-own/</link>
		<comments>http://sendreceivereply.wordpress.com/2008/04/18/no-fault-of-your-own/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 19:42:28 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[kernel]]></category>
		<category><![CDATA[QNX]]></category>
		<category><![CDATA[demand paging]]></category>
		<category><![CDATA[virtual memory]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=55</guid>
		<description><![CDATA[If you&#8217;ve ever taken a kernel trace of an application starting up on a kernel that is 6.3.2 or later, you might have noticed a thread state in your application called STATE_WAITPAGE. To understand what is going on here, we have to first look at mmap() and how it allocates and initializes memory. When you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=55&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever taken a kernel trace of an application starting up on a kernel that is 6.3.2 or later, you might have noticed a thread state in your application called <strong>STATE_WAITPAGE</strong>.</p>
<p>To understand what is going on here, we have to first look at <em><strong>mmap()</strong></em> and how it allocates and initializes memory.</p>
<p>When you allocate memory with <em><strong>mmap()</strong></em>, it first allocates a virtual address range, and then (unless you&#8217;ve passed <strong>MAP_LAZY</strong>), it will allocate the physical memory needed to back that object.</p>
<p>What it doesn&#8217;t do, though is setup all the page table mappings for the mapping (although in actual fact it will setup a certain amount, depending on heuristics based on the type of mapping).</p>
<p>In actual fact it will wait until the program first accesses a page before setting up a page table entry for it.</p>
<p>This is a change from pre-6.3.2 kernels, where all mappings were setup immediately.   You can re-enable the old behaviour by using the procnto option -mL in your buildfile.</p>
<p>The benefits of this scheme, known as demand paging, are a speedup when the application doesn&#8217;t actually access all of the pages in a mapping.  This is quite useful when mapping executable objects, since often there are quite a few pages in the text section which may never be referenced.</p>
<p>In some patterns of usage, though, this can induce a performance penalty, especially when there are many threads running at the same priority.</p>
<p>This brings us back to <strong>STATE_WAITPAGE</strong>.  When a process is executing and it access a page that has not been mapped, or tries to write to a page that is marked read-only, it will induce a page fault.  This is caught by the kernel.</p>
<p>The fast path in the kernel will peek at the processes pagetables, and if found it will bang it into the TLB (this is done in hardware on some architectures, such as the x86).  If it can&#8217;t find it then it needs to defer the work of handling the fault to the process manager, since it may need to do some complex work such as communicating with device drivers, and also the also the necessary structures may not be accessible/consistent.</p>
<p>This, then, is where the thread gets blocked in <strong>STATE_WAITPAGE</strong>, and a pulse is sent to procnto, to wake up a thread to handle the request.</p>
<p>The procnto worker does the dirty work of initializing the memory (it may need to read a page from a disk driver for example) and setting up the pagetables.</p>
<p>The first time a page is read it is setup with a read-only mapping, even if the mapping is writeable, unless the underlying page has already been marked as modified.  For <strong>MAP_LAZY</strong> mappings, this is the point at which physical memory is actually allocated for the page.  If the allocation fails, then the application will have a <strong>SIGBUS</strong> signal delivered to it (this was the same in pre 6.3.2 kernels).</p>
<p>This delayed initialisation supports two handy schemes.</p>
<p>This first is Copy On Write semantics (COW).  This is where we don&#8217;t bother making a private copy of a page that was originally shared with another mapping until the page is modified.</p>
<p>The second is support for writeable mappings to files.  Prior to 6.3.2 you could only map a file readonly, or with the extra flag, <strong>MAP_NOSYNCFILE</strong>.  This was because there was no tracking of modified pages.</p>
<p>When you call <strong>msync()</strong> on a shared mapping to a file, all the modified pages are written to the backing store.  Now the pages can be marked read-only again, and the modified indicator can be turned off.</p>
<p>Now all this is great, but what about that performance penalty?  Well all that context switch can make the page fault processing take quite a while if there are lots of threads in <strong>STATE_READY</strong> at the same priority.  The procnto thread will be placed at the back of the queue, wait for the others to run, the it will run, potentially talk to a device driver, and then make the original thread ready again, which will be placed at the end of the queue.</p>
<p>Another thing to think of in some circumstances you want to take the hit of talking to the backing store all at once for determinism reasons.</p>
<p>A way to control this behaviour is via the <em><strong>mlock()</strong></em> and <em><strong>mlockall()</strong></em> functions.  These tell procnto that you want the some (or all) pages made memory resident right now.</p>
<p>This means that the mapping will have been fully read in from disk by the time the <em><strong>mmap()</strong></em> call returns to your program.</p>
<p>You still get page faults on the first write to a page, though.  In that case we setup a read-only mapping (or if the underlying pages have already been modified, a read-write mapping).</p>
<p>If you TRULY don&#8217;t want page faults for mappings, then there are two options open to you.  Since device drivers may have their code run in an interrupt handler, and they may also be running code with interrupt disabled, they can&#8217;t take page faults at all.  So when you request IO privity with the <em><strong>ThreadCtl()</strong></em> call, you get marked as being <strong><em>super locked</em></strong>.  This means that all mappings are setup and ready to go.</p>
<p>Of course, only processes running with superuser privilege can request this special status.  To have all processes be marked as super locked, you can pass the -mL option to procnto.  To have all processes simply be locked (the equivalent of calling <em><strong>mlockall(MCL_FUTURE|MCL_CURRENT)</strong></em>, you can pass the -ml option.</p>
<p>Well, this post has gone all over the map &lt;groan&gt;, so I&#8217;m going to sign off.</p>
<p>Later,</p>
<p>Colin</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/55/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/55/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=55&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2008/04/18/no-fault-of-your-own/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>It&#8217;s alive!</title>
		<link>http://sendreceivereply.wordpress.com/2008/04/16/its-alive/</link>
		<comments>http://sendreceivereply.wordpress.com/2008/04/16/its-alive/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 15:12:12 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/?p=54</guid>
		<description><![CDATA[Well sorry for not having written for so long. We&#8217;ve all been very busy working on the 6.4 kernel. BTW &#8211; if you&#8217;ve been wondering about the being CoreOS source repository out of date, the sync process between the internal and external repositories broke down. :-( The good news though is that it&#8217;s fixed now, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=54&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well sorry for not having written for so long.  We&#8217;ve all been very busy working on the 6.4 kernel.</p>
<p>BTW &#8211; if you&#8217;ve been wondering about the  being <a title="CoreOS source repository" href="http://community.qnx.com/sf/scm/do/listRepositories/projects.core_os/scm" target="_blank">CoreOS source repository</a> out of date, the sync process between the internal and external repositories broke down. :-(</p>
<p>The good news though is that it&#8217;s fixed now, so you can get all the goodness straight from the source. :-)</p>
<p>Colin</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/54/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/54/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=54&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2008/04/16/its-alive/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>Move along, nothing to see here.</title>
		<link>http://sendreceivereply.wordpress.com/2008/01/20/move-along-nothing-to-see-here/</link>
		<comments>http://sendreceivereply.wordpress.com/2008/01/20/move-along-nothing-to-see-here/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 21:25:08 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[dtrace]]></category>
		<category><![CDATA[Tracing]]></category>
		<category><![CDATA[dtrace mac osx broken]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2008/01/20/move-along-nothing-to-see-here/</guid>
		<description><![CDATA[As some of you may know, Thomas and I have been working on a port of dtrace, mostly in our spare time. I was intrigued and enthused to see that it had also been ported to FreeBSD and Mac OS X Leopard. I was dismayed, however, to read this blog entry by one of dtrace&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=52&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As some of you may <a href="http://sendreceivereply.wordpress.com/2007/11/08/i-trace-you-trace-what-about-dtrace/" title="I trace, you trace, what about dtrace?">know</a>, Thomas and I have been working on a port of <a href="http://www.sun.com/bigadmin/content/dtrace" title="Dtrace" target="_blank">dtrace</a>, mostly in our spare time.  I was intrigued and enthused to see that it had also been ported to FreeBSD and Mac OS X Leopard.</p>
<p>I was dismayed, however, to read <a href="http://blogs.sun.com/ahl/entry/mac_os_x_and_the" title="Max OS X and the missing probes">this blog entry</a> by one of dtrace&#8217;s inventors, <a href="http://blogs.sun.com/ahl" title="Adam Levelthat's Blog">Adam Leventhal</a>, on a discovery he had made about the Leopard port.</p>
<p>I won&#8217;t repeat the details of it here, but the gist of it is that Apple allows for certain processes to be hidden from any debug/tracing systems.  While you may or may not agree on whether that is Truly Evil Behaviour or not, it doesn&#8217;t really matter &#8211; what it means for sure is that the Leopard dtrace port is severely broken.</p>
<blockquote><p><i>When a system wide tracer cannot trace the whole system, it pretty much ceases to be of any use! </i></p></blockquote>
<p>You might as well pack up, and go home, folks!</p>
<p>The really sad thing is the way they broke it!  They basically disable <i>any</i> probes from running at the same time as a protected process, the prime example being iTunes.</p>
<p>This means, for example, that anything based on the timer tick is useless, since you lose the regular heartbeat, and that any kernel activity that may have been deferred (say disk io) is lost, unnoticed by your dtrace probes!</p>
<p>It really means that you cannot trust any of the data that dtrace is supplying, as it may be at best incomplete, at worst incorrect.</p>
<p>I shake my head, I really do.</p>
<p>Colin</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/52/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/52/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=52&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2008/01/20/move-along-nothing-to-see-here/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>Work your Pocketgeek!</title>
		<link>http://sendreceivereply.wordpress.com/2008/01/16/work-your-pocketgeek/</link>
		<comments>http://sendreceivereply.wordpress.com/2008/01/16/work-your-pocketgeek/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 16:53:24 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2008/01/16/work-your-pocketgeek/</guid>
		<description><![CDATA[In the spirit of open development, QNX has created a new product &#8211; the Pocket Geek! He works in transparent cube (get it, transparent development!!) Head over to http://thepocketgeek.com for some recreational fun, trying to drive your little pocketgeek to complete his tasks without exploding. There&#8217;s also a contest at the end of it all. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=51&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the spirit of open development, QNX has created a new product &#8211; the Pocket Geek! He works in transparent cube (get it, transparent development!!)</p>
<p>Head over to <a href="http://thepocketgeek.com" target="_blank">http://thepocketgeek.com</a> for some recreational fun, trying to drive your little pocketgeek to complete his tasks without exploding. There&#8217;s also a contest at the end of it all.</p>
<p>Have fun!</p>
<p>Colin</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=51&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2008/01/16/work-your-pocketgeek/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>Happy Holidays! Colin&#8217;s in Charge!</title>
		<link>http://sendreceivereply.wordpress.com/2007/12/28/happy-holidays-colins-in-charge/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/12/28/happy-holidays-colins-in-charge/#comments</comments>
		<pubDate>Fri, 28 Dec 2007 18:09:18 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/12/28/happy-holidays-colins-in-charge/</guid>
		<description><![CDATA[Most of QNX is off this week on a yearly holiday break that lasts from Christmas to New Years.   Most of the developers end up being busy playing with new toys (thanks Santa) or tinkering with pet projects (CDT integration with Mylar) that they&#8217;ve had brewing on the side, so January ends up being a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=49&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Most of QNX is off this week on a yearly holiday break that lasts from Christmas to New Years.  </p>
<p>Most of the developers end up being busy playing with new toys (<a href="http://www.openmoko.com/">thanks Santa</a>) or tinkering with pet projects (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=162558">CDT integration with Mylar</a>) that they&#8217;ve had brewing on the side, so January ends up being a pretty exciting time to be back in the office finding out what everyone&#8217;s been up to.</p>
<p>However, this year I&#8217;m going to miss out on that.  Starting in January I&#8217;m turning main responsability of SRR over to my partner in crime Colin as I&#8217;m starting three months of parental leave to hang out with my 9 month old son and teach him the essentials of life:</p>
<ul>
<li>
<div>Recursion, can&#8217;t program effectively without thinking it!</div>
</li>
<li>
<div>Snow fort construction, can&#8217;t live in Ottawa without it!</div>
</li>
<li>
<div>Appreciation for solid foods &#8230; just makes sense!</div>
</li>
</ul>
<p>So as this is my last post for a while (likely, but not certainly) I want to wish you all a happy holiday and a wonderful new year!</p>
<p>Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/49/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/49/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=49&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/12/28/happy-holidays-colins-in-charge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Why wait for the next release &#8230;</title>
		<link>http://sendreceivereply.wordpress.com/2007/12/08/why-wait-for-the-next-release/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/12/08/why-wait-for-the-next-release/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 18:12:19 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/12/08/why-wait-for-the-next-release/</guid>
		<description><![CDATA[OK &#8230; so I promise that this will be my last post about foundry27for a while and I&#8217;ll get back to talking about QNX technology.  But I couldn&#8217;t help myself, I needed to put out one more plug for some of the QNX Neutrino software that is being made more accessible to developers. This time [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=48&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OK &#8230; so I promise that this will be my last post about <a href="http://www.foundry27.com">foundry27</a>for a while and I&#8217;ll get back to talking about QNX technology.  But I couldn&#8217;t help myself, I needed to put out one more plug for some of the QNX Neutrino software that is being made more accessible to developers.</p>
<p>This time it is the availability of the IDE, also commonly known as QNX Momentics, although that statement will get me in trouble since QNX Momentics is more than just the IDE, but it is the complete assembly of a development environment for QNX Neutrino &#8230; but I digress.</p>
<p>The IDE is not part of the current roadmap for source publishing, but the QNX tools development team is shifting to performing its development work more transparently.  To that end there are two community projects, the <a href="http://community.qnx.com/sf/projects/toolchain">Core Development Tools project</a> and the the <a href="http://community.qnx.com/sf/projects/ide">Integrated Development Environment (IDE) project</a>.  From the Core Development Tools project you can get the bleeding edge versions of the GNU toolchain as they are developed &#8230; which is interesting, but most commercial projects currently under development aren&#8217;t likely to switch to a non-released (by QNX) compiler for their production work.   The IDE also offers <a href="http://community.qnx.com/sf/wiki/do/viewPage/projects.ide/wiki/Builds_Tau_Integration">bleeding edge integration build downloads</a> and since the IDE pretty much sits on top of any core tool or runtime components, it can be updated with far less risk to a production development environment.   While I hate to compare the IDE to an editor, updating your IDE is like updating your editor:  In theory new features and functionality should only make you more productive!</p>
<p>The IDE team is tracking what <a href="http://community.qnx.com/sf/wiki/do/viewPage/projects.ide/wiki/Whats_New_IDE_Tau">significant new and noteworthy features</a> are being added to each of the integration builds so you can get an immediate idea of what areas you might want to explore.  A more visual page is also<a href="http://community.qnx.com/sf/wiki/do/viewPage/projects.ide/wiki/WhatIsNewInIDE4.5">tracking the general IDE 4.5 features </a>that you might also want to take a look at.  There is a lot of goodness in these downloads, ranging from the source navigation and usability improvements in the C/C++ development environment to the brand new Application Profiler functionality and a range of smaller, but equally rewarding, fixes and enhancements.</p>
<p>The other benefit to trying it out early is that the IDE team is actively looking for feedback and there is still time in the schedule before the<em> </em>next major release &#8230; <em>codenamed Athens</em> &#8230; to respond to feedback and feature requests.</p>
<p>Of course I&#8217;m a bit biased since I&#8217;ve had a hand in putting some of the new IDE features in, but I&#8217;ve switched for my C/C++ development and I&#8217;m not going back!</p>
<p>Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/48/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/48/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=48&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/12/08/why-wait-for-the-next-release/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Software ports galore!</title>
		<link>http://sendreceivereply.wordpress.com/2007/11/26/software-ports-galore/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/11/26/software-ports-galore/#comments</comments>
		<pubDate>Mon, 26 Nov 2007 14:12:59 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/11/26/software-ports-galore/</guid>
		<description><![CDATA[A couple of weeks ago I wrote about the port of dtrace that Colin and I have got up and running under Neutrino.   For the most part, porting software to Neutrino is a pretty straightforward matter.  Since Neutrino runs self-hosted (ie you work and build in the same environment that you deploy) it means that all [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=47&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I wrote about the <a href="http://sendreceivereply.wordpress.com/2007/11/08/i-trace-you-trace-what-about-dtrace/">port of dtrace</a> that Colin and I have got up and running under Neutrino.   For the most part, porting software to Neutrino is a pretty straightforward matter.  Since Neutrino runs self-hosted (ie you work and build in the same environment that you deploy) it means that all of the &#8216;configure/make&#8217; style projects work without too much hassle.  In fact most of the time if the source is coming from Linux, *BSD, Solaris or some other unix flavour you can get it up and running in a couple of hours.  The main challenge is almost always figuring out the build system and making sure that our compiler front end (qcc) is used to pick up all of the required environment bits and that hacks for other systems are really required for Neutrino (which is pretty well behaved).</p>
<p>Having ported software on a self-hosted system is pretty much essential for a software developer to work effectively.  There are so many essential software bits and pieces that QNX would never include with the Neutrino SDK because while they are useful, the SDK is targeted specifically at what is needed to build Neutrino applications and needs to be portable (and consistent) for use under Windows, Linux, Solaris as well as Neutrino self-hosted x86.   That doesn&#8217;t mean that the extra software bits aren&#8217;t useful, and historically a 3rd party CD was provided for Neutrino self-hosted developers that came with loads of useful extras, from scripting languages (perl, python, tk) to web servers (apache) and editors (vim).</p>
<p>A couple of developers here at QNX, Sean B. and Xiaodan T., with the help of some QNX community members have been working on a <a href="http://community.qnx.com/sf/projects/pkgsrc">wicked awesome project </a>that pretty much replaces the 3rd party CD with something even better!  They have been working to port the <a href="http://en.wikipedia.org/wiki/Pkgsrc">BSD pkgsrc tool/project</a> to support the QNX Neutrino self-hosted environment.   Just the other day I got a message in my mailbox indicating that the project had hit a critical milestone and that QNX Neutrino was now considered a full fledged supported platform:</p>
<p><font size="2"></p>
<blockquote><p>&#8220;we are proud to welcome QNX, thanks to Sean Boudreaux.&#8221;  <a href="http://mail-index.netbsd.org/pkgsrc-users/2007/10/15/0005.html"><u><font size="2" color="#0000ff">http://mail-index.netbsd.org/pkgsrc-users/2007/10/15/0005.html</font></u></a></p></blockquote>
<p></font></p>
<p align="left">It is even listed on the <a href="http://www.netbsd.org/docs/software/packages.html#available-packages">projects main documentation page</a> &#8230; now that is super cool news!  There are 7000+ different software packages part of this collection, and to have all of them available pre-ported and on-demand is a pretty awesome feat.</p>
<p align="left">So if you are running Neutrino self-hosted, (<em>and why wouldn&#8217;t you be!</em>) and you want more than just the stock installed software, then you should definitely take a look at the <a href="http://community.qnx.com/sf/projects/pkgsrc">pkgsrc community project</a>. </p>
<p align="left">Congratulations and thanks to Sean, Xiaodan and all the others who&#8217;ve been working on getting this up and running!</p>
<p align="left">Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/47/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/47/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=47&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/11/26/software-ports-galore/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Mutex madness?</title>
		<link>http://sendreceivereply.wordpress.com/2007/11/15/mutex-madness/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/11/15/mutex-madness/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 19:23:44 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>
		<category><![CDATA[Tracing]]></category>
		<category><![CDATA[kernel trace]]></category>
		<category><![CDATA[mutex]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/11/15/mutex-madness/</guid>
		<description><![CDATA[I recently received an interesting kernel trace from a customer. It showed several threads going from STATE_RUNNING to STATE_MUTEX without an intervening SyncMutexLock kernel call. He wondered if perhaps the trace was corrupted. After looking at the trace it seemed to be sane, but the behaviour shown was somewhat puzzling. However it is explainable, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=45&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently received an interesting kernel trace from a customer.  It showed several threads going from STATE_RUNNING to STATE_MUTEX without an intervening SyncMutexLock kernel call.  He wondered if perhaps the trace was corrupted.</p>
<p>After looking at the trace it seemed to be sane, but the behaviour shown was somewhat puzzling.  However it is explainable, and it has to do with our implementation of mutexes.</p>
<h3><span id="more-45"></span> No kernel calls?</h3>
<p>One of the first things you must realize, when looking at a QNX kernel trace, is that a pthread_mutex_lock() doesn&#8217;t always result in a SyncMutexLock() kernel call.  This is because we implement an optimisation where an <em>uncontested mutex</em> can be aquired without entry to the kernel.  Likewise, unlocking a mutex on which no-one is waiting will not result in a SyncMutexUnlock() kernel call.  This is implemented using atomic compare-and-exchange operations.  How they are implemented depends on which cpu you are using.  Take a look at $QNX_TARGET/usr/include/&lt;cpu&gt;/smpcmp.h if you are interested in the various ways of doing this.</p>
<h3> Not our man though&#8230;</h3>
<p>State changes without seeing kernel calls might point us in that direction then, but the fact is that we are seeing a change to STATE_MUTEX, which would indicate a contested mutex.</p>
<p>The next clue though is that we ARE, in fact, seeing these state changes while in the kernel.  The kernel call was a MsgReceivev().  This led me to the answer.</p>
<p>When we unlock a mutex that other threads are being waited on, we call SyncMutexUnlock(), which checks a priority ordered list of waiting threads.  It then will remove  the first thread from the list and mark it runnable (ie it will transition to STATE_READY).  It also sets a thread flag, <strong>_NTO_TF_ACQUIRE_MUTEX</strong>, which indicates that the thread should aquire the mutex it was waiting on upon exit from the kernel.  The address of the mutex was saved in the thread kernel calls arguments when it called SyncMutexLock(), some time in the past.</p>
<p>The point is, though, that the thread has not yet aquired the mutex.  This can lead to some interesting behaviour.</p>
<p>In the log that was sent to me, the holding thread unlocked the mutex, and then immediately tried to relock it.  The first unlock makes a waiting thread ready.  SyncMutexUnlock() is not a blocking call though, so the thread remains running.</p>
<p>At this point, no-one holds the lock, although the lock indicates that people are waiting on it.</p>
<p>The following call to SyncMutexLock detects that there are threads waiting, and readies another thread (it has no knowledge that there was already a thread readied) to attempt to acquire the mutex.  It then blocks the calling thread, and at this point the first thread that wanted to aquire the mutex will be made running.</p>
<p>Time passes, at at some point the second thread that was marked ready may actually be made running.  As it exits the kernel, the kernel exit code processing notices the aquire flag is set on the thread, and attempts to aquire the mutex.  Of course it is still held by the earlier thread, and thus we need to block this thread and choose another.</p>
<h3>Capice?</h3>
<p>And there you have it.  I&#8217;m sure it&#8217;s all a little odd without better knowledge of how kernel is implemented.  The good news is that you can checkout the <a href="http://community.qnx.com/sf/scm/do/listRepositories/projects.core_os/scm" title="source" target="_blank">source</a> and see for yourself.  Also don&#8217;t forget to checkout the evolving docs on the <a href="http://community.qnx.com/sf/wiki/do/viewPage/projects.core_os/wiki/HomePage" title="project wiki page">project wiki page</a>.</p>
<p>The moral of this story is to not get too upset by multiple thread state changes when we are within the kernel.  The kernel can change it&#8217;s mind several times on which thread will ultimately make it out of the kernel and become running.  The last state change before you see a kernel exit is the one to believe.</p>
<p>Colin</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/45/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/45/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=45&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/11/15/mutex-madness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>I trace, you trace &#8230; what about dtrace?</title>
		<link>http://sendreceivereply.wordpress.com/2007/11/08/i-trace-you-trace-what-about-dtrace/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/11/08/i-trace-you-trace-what-about-dtrace/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 15:48:27 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/11/08/i-trace-you-trace-what-about-dtrace/</guid>
		<description><![CDATA[Anyone who has been plugged into the OS scene is surely aware of the latest Mac OS X Leopardrelease.  It is hard to miss since the news is pretty much splashing up all over the place in news articles and product reviews and in my case filling my mailbox with Google Alerts.  I don&#8217;t have an alert [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=39&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p align="left">Anyone who has been plugged into the OS scene is surely aware of the latest <a href="http://www.apple.com/macosx/">Mac OS X Leopard</a>release.  It is hard to miss since the news is pretty much splashing up all over the place in news articles and product reviews and in my case filling my mailbox with Google Alerts.  I don&#8217;t have an alert set for Max OS X, but I do have one set for <a href="http://www.sun.com/bigadmin/content/dtrace/">DTrace</a> and this tracing functionality has now been included in the latest Mac OS X release and people seem to be pretty jazzed about it.</p>
<p>I&#8217;m jazzed about it too &#8230; but for a different reason all together. </p>
<p>Colin and I have been following the work of <a href="http://blogs.sun.com/bmc/">Bryan</a>, <a href="http://blogs.sun.com/mws/">Mike</a> and <a href="http://blogs.sun.com/ahl/">Adam</a>on dtrace since it was released as part of the <a href="http://www.opensolaris.org/os/">Open Solaris</a>.  We head up most of the <a href="http://www.qnx.com/download/feature.html?programid=9374">kernel instrumentation</a> and <a href="http://www.qnx.com/download/feature.html?programid=9328">system profiling</a>development on Neutrino and have always felt that dtrace, with its focus on runtime safety and use in a production environment, would be a perfect match for embedded developers and compliment our existing instrumentation and tracing strategy for Neutrino very nicely.  </p>
<p>So why were we jazzed by the Max OS X release? The more platforms that dtrace is ported to, the more generic the code base will become.  It is exciting to us because now dtrace is running on Solaris, NetBSD, Max OS X and oh yeah &#8230; <em>Neutrino!</em></p>
<p><a href="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap1.jpg" title="dtrace on Neutrino"></a></p>
<p style="text-align:center;"><em><img src="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap1.jpg?w=480" alt="dtrace on Neutrino" /></em></p>
<p>You can see here that this is a system that is running the 6.3.0 release of Neutrino and this is the basic dtrace command help.  The initial port to Neutrino that Colin and I have done is slightly different from the other OS ports.  Since Neutrino is an micro-kernel, we wanted to see how far we could go keeping the dtrace module out  of the kernel &#8230; and if possible even outside of the process manager.  The current implementation has all of the dtrace system code, normally found in the kernel or a kernel module, encapsulated in a resource manager, io-dtrace, and the utility is a straight port of the Solaris utility.</p>
<p style="text-align:center;"><img src="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap2.jpg?w=480" alt="dtrace provider listing" /></p>
<p>We&#8217;ve only implemented three sets of providers currently. </p>
<ul>
<li><strong>dtrace</strong>:  This is the standard dtrace provider with the BEGIN, END and ERROR probes</li>
<li><strong>instr</strong>: This is a provider based on the existing kernel instrumentation hook and can provide kernel calls, thread state, interrupt information</li>
<li><strong>profile:</strong> This provider is pretty much the same as the Solaris provider and provides statistical sampling at a user controlled rate</li>
</ul>
<p>Even with this minimal set of providers, you can extract some pretty interesting information.  For example, we can re-write the <em>hogs</em> utility, that tracks the runtime of the top few processes, with a simple dtrace script:</p>
<p align="center"><a href="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap3.jpg" title="HOGS dtrace script"><img src="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap3.jpg?w=480" alt="HOGS dtrace script" /></a></p>
<p align="left">We are missing a lot of the standard dtrace built-ins that allow you to get much deeper into the application space, such as providing the user stack information, but even by recording the instruction pointer we can get some usefull information about where an application is spending its time &#8230; expanding on the idea of an application specific statistical profiler, we can gather information about the whole system or target just one process or thread:</p>
<p align="center"><a href="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap4.jpg" title="Mapping the IP address"><img src="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap4.jpg?w=480" alt="Mapping the IP address" /></a></p>
<p align="left">Since dtrace can work directly with C constructs, we can pull in code directly from the Neutrino system headers.  If you wanted to take a look at the kind of messaging operations that were going on in a process, you could write a script to catch all of the MsgSend&#8217;s via the instrumentation hook and decode the first few bytes of data based on the message header to determine what an application is doing:</p>
<p align="center"><a href="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap5.jpg" title="Decoding the message"><img src="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap5.jpg?w=480" alt="Decoding the message" /></a></p>
<p align="left">Pretty cool huh! It is a nice extension to the capabilities of the System Profiler that provides the graphical analysis capabilities, but in a development environment back on the host.</p>
<p align="left">There is still have a lot to do and the port is far from complete.  Before we can go much further, we are likely going to have to do the kernel and/or process manager integration to be able to efficiently provide things like the equivalent of the pid provider and the function boundary tracing.  The good news is that as a proof of concept this is already usefull &#8230; and so far architecturally independent (running on MIPS, SH, ARM, PPC and of course x86), although the hard bits are still ahead of us. </p>
<p align="left">Hats off to Bryan, Mike and Adam for a wicked awesome technology and to Sun to making it available to the software development community.  Since the port isn&#8217;t quite complete, certainly not production ready, Colin and I are hoping that we can get our prototype posted up to the <a href="http://www.foundry27.com">Foundry27 QNX community</a> site so that we aren&#8217;t the only ones who get a chance to play around with this. </p>
<p align="left">Stay tuned &#8230;</p>
<p align="left">Thomas (&amp; Colin who is onsite with a customer &#8230; likely using the dtrace prototype right now)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/39/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/39/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=39&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/11/08/i-trace-you-trace-what-about-dtrace/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap1.jpg" medium="image">
			<media:title type="html">dtrace on Neutrino</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap2.jpg" medium="image">
			<media:title type="html">dtrace provider listing</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap3.jpg" medium="image">
			<media:title type="html">HOGS dtrace script</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap4.jpg" medium="image">
			<media:title type="html">Mapping the IP address</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2007/11/dtrace-snap5.jpg" medium="image">
			<media:title type="html">Decoding the message</media:title>
		</media:content>
	</item>
		<item>
		<title>Published source &#8230; the greatest thing ever!</title>
		<link>http://sendreceivereply.wordpress.com/2007/10/18/published-source-the-greatest-thing-ever/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/10/18/published-source-the-greatest-thing-ever/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 15:48:29 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/10/18/published-source-the-greatest-thing-ever/</guid>
		<description><![CDATA[One of the hardest things about working through problems with some of our customers is the fact that since I work here at the QNX mothership office I have full and complete visibility into all source from our products &#8230; and they do not.  This of course means that I can almost always come out looking like [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=38&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the hardest things about working through problems with some of our customers is the fact that since I work here at the <a target="_blank" href="http://maps.google.com/maps/mm?ie=UTF8&amp;hl=en&amp;ll=45.286022,-75.872312&amp;spn=0.003042,0.007135&amp;t=k&amp;z=18&amp;om=1">QNX mothership</a> office I have full and complete visibility into all source from our products &#8230; and they do not.  This of course means that I can almost always come out looking like a hero since for any hard question a customer has about how something works (or appear not to as the case may be) I can generally root through the source repository, figure out what is going on and explain it back to them.</p>
<p>It is nice to be a hero &#8230; but sometimes things just get lost in translation.</p>
<p>Since it used to be that I couldn&#8217;t just share the code with the customer&#8217;s engineers, we spend a lot of time going back and forth discussing topics in the &#8220;abstract&#8221; until I can paint enough of a mental picture for them about a particular implementation of technology.  By the time that they understand what to do about the problem they are facing, I&#8217;ve pretty much given them a tour through our code.  Kind of a  waste of time considering that most of the software developers I end up working with can read through a blob of C, C++ or Java code just as easily as a paperback novel.</p>
<p>This is why I think that <a href="http://www.foundry27.com">Foundry27</a> is an awesome idea.  We are working to get to the point where for nearly all of the Neutrino technology that has been developed, I&#8217;ll be able to talk customers through a problem and bring them right into the guts of the code during the explanation.   It is going to take some time to get all of that source out, but we have already pushed out the <a target="_blank" href="http://community.qnx.com/integration/viewcvs/viewcvs.cgi/trunk/lib/c/?root=coreos_pub&amp;system=exsy1001">C library source code</a> and the <a target="_blank" href="http://community.qnx.com/integration/viewcvs/viewcvs.cgi/trunk/services/system/?root=coreos_pub&amp;system=exsy1001">kernel/process manager code </a>and that represents quite a bit of important glue bits that help you understand how to get the most out of your applications.</p>
<p>Even better than the fact that the source is being published, is the fact that the different development teams within QNX are starting to take on much more active public roles themselves and helping others to interpret and navigate through the source code.  If you missed it, you should really check out the  <a href="http://www.qnx.com/news/web_seminars/microkernel.html">webinar</a> that Colin and Sebastien presented as a bit of a guided tour through some of the source code included in the <a href="http://community.qnx.com/sf/projects/core_os">QNX Operating System</a> project.  Also we&#8217;ve got most of the kernel developers (and a large number of other QNX developers) online now and monitoring the forums so there is lots of good information flowing around.</p>
<p>Next up on the source release roadmap is the networking stack and driver source and I&#8217;m also going to see if I can get a set of missing OS utilities out the door as well before Christmas!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=38&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/10/18/published-source-the-greatest-thing-ever/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Finding an unblock victim</title>
		<link>http://sendreceivereply.wordpress.com/2007/10/05/finding-an-unblock-victim/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/10/05/finding-an-unblock-victim/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 01:58:44 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[Tracing]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/10/05/finding-an-unblock-victim/</guid>
		<description><![CDATA[Dan posted recently on his blog about implementing an unblock handler in one of our media servers.  Unblock handling is tricky and it can take a bit of fiddling to get an implementation that makes the appropriate trade off between unblock response time and the complexity of implementation.  In this case a significant customer needed the work done in short order [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=34&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://mediatype.ca/">Dan</a> posted recently on his blog about <a href="http://mediatype.ca/2007/09/21/unblock-handler/">implementing an unblock handler</a> in one of our media servers.  Unblock handling is tricky and it can take a bit of fiddling to get an implementation that makes the appropriate trade off between unblock response time and the complexity of implementation.  In this case a significant customer needed the work done in short order so it was done.</p>
<p align="left">The funny thing is that a few days later the customer was then starting to get all sort of spurious errors in their system.  Normally this isn&#8217;t a challenge to track down, but in this case the system was tightly coupled and composed of hundreds of threads with tens of processes and close to a dozen active interrupts.  There was enough other system activity going on that a small failure in one path took a long time to ripple through to a point where the error was noticeable.  The gut feeling was that some part of the client software was being unblocked as a result of the recent server unblock changes and the client wasn&#8217;t ready to deal with the consequences.</p>
<p>&#8230; but we needed to prove it &#8230;</p>
<p>The good news is that the system was running the instrumented kernel and we could take some traces and take a look at the entire system, so traces we took and then we loaded them into the System Profiler.</p>
<p align="center"><a rel="attachment wp-att-35" href="http://sendreceivereply.wordpress.com/2007/10/05/finding-an-unblock-victim/initial-load/" title="System Profiler"><img src="http://sendreceivereply.files.wordpress.com/2007/10/initial.thumbnail.jpg?w=480" alt="System Profiler" /></a> </p>
<p align="left">The question was, how can we quickly check and see if the unblock behaviour is at fault?  Well the first thing to do is to see if there is any unblock activity in the log.  This is easily accomplished with using the Trace Search capability,  <strong>Search</strong> &gt; <strong>Search&#8230; </strong>(or CTRL+H for the keyboard addicts).  Click <strong>Add</strong> to create a new search condition.  The condition we want to look for is the <em>Communication</em> class events with the code of <em>Unblock Pulse</em>.  This will pull up all of the unblock pulses generated in the trace.  In this case we didn&#8217;t have very many to consider:</p>
<p align="center"><a href="http://sendreceivereply.files.wordpress.com/2007/10/search-all.jpg" title="Unblock Search Results"><img src="http://sendreceivereply.files.wordpress.com/2007/10/search-all.thumbnail.jpg?w=480" alt="Unblock Search Results" /></a></p>
<p align="left">We could have gone through and taken a look at each instance, but in this case we knew that we had just put the unblock handling code into the mme server.  The unblock pulse event contains the name of the target process, so we could take a look specifically to see if we had targeted our server.  We can do this by going back into the Trace Search and either editing the existing condition or creating a new condition.  We will still specify the <em>Communication </em>class and the<em> Unblock Pulse</em> event, but this time we will also add in a specific search for instances where the <em>process</em>data is equal to the mme server.</p>
<p align="center"><a rel="attachment wp-att-37" href="http://sendreceivereply.wordpress.com/2007/10/05/finding-an-unblock-victim/mme-unblock-search/" title="MME Unblock Search"><img src="http://sendreceivereply.files.wordpress.com/2007/10/mme-unblock.thumbnail.jpg?w=480" alt="MME Unblock Search" /></a></p>
<p align="left">Now when we run the search <strong>BINGO!</strong>we get just one single hit.  From this point it is easy now to look at the Timeline editor pane and track the behaviour of the client process and thread that the mme unblocks and what happens after the unblock (bad things it turns out).</p>
<p align="left">Also, with the system trace we can take a look at the specific cause of the signal.  It turns out in this case that there was a timer firing a signal that got dropped on the thread which caused it to unblock.  This in turn exposed a general flaw in the customer&#8217;s design since they were running a multi-threaded application where any thread could have potentially been blasted by this signal instead of the process having a dedicated signal handling thread.</p>
<p align="left">Hopefully this quick example gives you some more ideas how you can effectively navigate through the instrumentation trace files, Trace Search is a powerful tool.</p>
<p align="left">Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/34/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/34/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=34&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/10/05/finding-an-unblock-victim/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2007/10/initial.thumbnail.jpg" medium="image">
			<media:title type="html">System Profiler</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2007/10/search-all.thumbnail.jpg" medium="image">
			<media:title type="html">Unblock Search Results</media:title>
		</media:content>

		<media:content url="http://sendreceivereply.files.wordpress.com/2007/10/mme-unblock.thumbnail.jpg" medium="image">
			<media:title type="html">MME Unblock Search</media:title>
		</media:content>
	</item>
		<item>
		<title>More time than you want</title>
		<link>http://sendreceivereply.wordpress.com/2007/09/25/more-time-than-you-want/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/09/25/more-time-than-you-want/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 02:08:09 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/09/25/more-time-than-you-want/</guid>
		<description><![CDATA[I was discussing with one of the other developers here some source code that comes from a very popular open source database that has been ported to QNX and that is going to be shipping with the next release of the OS. It is funny the way that developers get into this mindset that the code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=28&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was discussing with one of the other developers here some source code that comes from a very popular open source database that has been ported to QNX and that is going to be shipping with the next release of the OS. It is funny the way that developers get into this mindset that the code they are writing will be the only code in the entire universe running.</p>
<p>The snippet of code we were looking at looked something like the following (code changes made to protect those who should know better):</p>
<p>/*<br />
** Sleep for a little while.  Return the amount of time slept.<br />
** The argument is the number of milliseconds we want to sleep.<br />
*/<br />
<font color="#228b22"><strong>int</strong></font> <strong><font color="#0000ff">OSSleep</font></strong>(<font color="#228b22"><strong>int</strong></font> ms){<br />
  usleep(ms*1000);<br />
  <strong><font color="#a020f0">return</font></strong> ms;<br />
}</p>
<p>Can you see what the flaw in the logic is here? Perhaps if we put the code into a context the problem will become clearer. The OSSleep function is being called in order to walk our way through a series of progressively longer timeouts .. based on the return value of how long this function has slept.</p>
<p>If the application containing this source code was the only thing running on the system, then there would be no problem. However, in most modern operating systems, QNX Neutrino counted among them, there are multiple tasks that are all running concurrently and being managed by the OS.  This means that while surely the code above will delay for N milliseconds, it could in fact be much longer than that if some other thread pre-empts this thread before or after it makes it into (or out of) the system call.</p>
<p>So .. what could we do to make it better?  Well we could snapshot the time on input and snapshotting it on exit and returning the difference.   This makes things incrementally better by narrowing down the window of error, but the window is still there. </p>
<p>The reality is that this kind of API, and this application&#8217;s use of it, is fundamentally flawed.  What the application is trying to emulate is allowing multiple threads of execution the ability to acquire a resource.  If the resource can&#8217;t be acquired, then the thread backs off or may choose to cancel the operation all together. </p>
<p>This is a perfect scenario for a condition variable &#8230; something available under Neutrino, but not necessarily under the other Unix flavours that this source was ported to.  By switching to a condition variable, we can be much more precise with respect to when we signal client applications to &#8220;try again&#8221; &#8230; which can result in a surprisingly large reduction in overall CPU consumption and system churn (due to all the extra context switches and cycles through the scheduling READY queue).</p>
<p>So in these days of thinking about multiple threads of execution running on separate CPU cores, we should also remind ourselves that using &#8220;time&#8221; as a basis for control needs to be carefully planned on systems where there is more than a single thread of execution.</p>
<p>Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/28/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/28/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=28&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/09/25/more-time-than-you-want/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>More on BEEP</title>
		<link>http://sendreceivereply.wordpress.com/2007/09/18/more-on-beep/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/09/18/more-on-beep/#comments</comments>
		<pubDate>Tue, 18 Sep 2007 02:09:50 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/09/18/more-on-beep/</guid>
		<description><![CDATA[A few months ago, back in the dark agains, BF (Before Foundry27), I hurriedly blogged about trying to turn off the annoying Beep &#8211; the bane of laptop owners anywhere. Well, today I had a few minutes, and so I went of in search of a more complete solution. Switching Modes As you may remember, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=33&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few months ago, back in the dark agains, BF (Before <a href="http://community.qnx.com" title="Foundry27" target="_blank">Foundry27</a>), I hurriedly blogged about trying to turn off the annoying <a href="http://sendreceivereply.wordpress.com/2007/07/27/beepn-beeps/" title="Beep">Beep</a> &#8211; the bane of laptop owners anywhere.</p>
<p>Well, today I had a few minutes, and so I went of in search of a more complete solution.</p>
<h3><span id="more-33"></span>Switching Modes</h3>
<p>As you may remember, one of the issues was that the beep control sequence, was only understood by <a href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/utilities/d/devc-con.html" title="devc-con">devc-con</a> when it was running QNX4 Terminal emulation mode, which is not the default.</p>
<p>I was telling this to my colleague, <a href="http://community.qnx.com/sf/docman/do/downloadDocument/projects.core_os/docman.root.os_docs/doc1073" title="PeterV">Peterv</a>, and he said &#8211; well just emit the code to switch to QNX emulation and back.</p>
<p>Well, it was one of those &#8216;Duh&#8217; moments. :-)</p>
<p>Of course, the fun part was figuring out the codes to emit.  I couldn&#8217;t find a decent doc of the QNX4 Terminal Emulator codes, and the ANSI code to switch to QNX4 was a private vendor extension.</p>
<p>After a bit of mucking around though, I figured it out&#8230;</p>
<h3>The Dark Majik</h3>
<p>And yeah shall chant&#8230;</p>
<pre class="brush: cpp;">#!/bin/sh

# switch to QNX4 emulation
printf "%c[?+q" 0x1b

# set beep tick count = 1, frequency divider to 1

printf "%cs%c%c%c" 0x1b 33 33 32

# switch back to ANSI emulation
printf "%c?1+q" 0x1b</pre>
<p>Now, make sure you put this output to /dev/con1, because that is the device that actually talks to the PC beep port.  Photon pterm terminals do understand these codes, but they just send a bell character to /dev/con1!</p>
<p>Enjoy a beepless world, my friends.</p>
<p>BTW &#8211; you can muck around with the parameters.  You might find you like a beep but just a bit shorter &#8211; each tick is 50ms.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/33/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/33/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=33&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/09/18/more-on-beep/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>Devc-ditto, the principle, the usage</title>
		<link>http://sendreceivereply.wordpress.com/2007/09/14/devc-ditto-the-principle-the-usage/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/09/14/devc-ditto-the-principle-the-usage/#comments</comments>
		<pubDate>Fri, 14 Sep 2007 02:40:31 +0000</pubDate>
		<dc:creator>xtang</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/09/14/devc-ditto-the-principle-the-usage/</guid>
		<description><![CDATA[Ever since I get my hands on QNET, the question &#8220;where is ditto&#8221; seems following me. At some point, I decided to give it a try, to see what&#8217;s the problem. Turns out the ditto functionality on QNX4, is mostly built into the console device. The character devices on QNX6 has a different architecture, to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=32&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ever since I get my hands on QNET, the question &#8220;where is ditto&#8221; seems following me. At some point, I decided to give it a try, to see what&#8217;s the problem. Turns out the ditto functionality on QNX4, is mostly built into the console device. The character devices on QNX6 has a different architecture, to do the samething, I would have to &#8220;port&#8221; those functionality into, right, libio-char; Not only libio-char is owned by Dan Dodge at the time (I am not kidding :D), at the time it already built into a whole lot character devices, including those non-x86s. So basically I am stuck.</p>
<p>One day I realized all &#8220;ditto&#8221; doing (or need to do), is to &#8221;sniff&#8221; characters between applications and the character device. Just like a network packet sniffer. Applications are going to write() into, for example, /dev/con1; All Ineed to do, is to find out what has benn written in, buffer them, for someone else to read out.</p>
<p>So how do I do this? QNX6 resource manager allow you register already exist path name, to, un, hijack it. So all I need to do, is write my own resrouce manager (called devc-ditto :D), it also attach to /dev/con1; The default behavior of resource manager pathname attach, is the &#8221;latest attched got message first&#8221;, which works very well. So once devc-ditto attached to /dev/con1, any one open(&#8220;/dev/con1&#8243;, ..) it will end up with a connection from application to devc-ditto. All the applications write() would comes to me, I buffer those data it is written, then relay it to the resource manager who is really managing /dev/con1 (devc-con); Done!</p>
<p>Well almost done, this only allow me to sniff out the datas, how do I pass it to another application? This is easy, if I take over /dev/con1 for example, I would then create a /dev/con1.ditto, read from this device, you got all it buffered.</p>
<p>So here is how you use it:</p>
<p>On a console 2, try </p>
<p><em><strong>  # devc-ditto /dev/con1<br />
  # cat /dev/con1.ditto</strong></em></p>
<p>Then go back to console 1, do &#8220;<strong><em>ls &gt;/dev/con1</em></strong>&#8220;, and come back, you should see all the &#8220;ls&#8221; output (from cat).</p>
<p>Wait, this is not what ditto doing right? Why is the 2 character &#8220;ls&#8221; not showing up in &#8220;cat&#8221; ? Think what happened, you hit &#8220;l&#8221; key, devc-con got it, give it to your shell, youe shell will echo it, by sending it to /dev/con1&#8230; but hey devc-ditto doesn&#8217;t see this &#8220;l&#8221;, why?</p>
<p>Because, the shell made a connection directly to devc-con, not to me. OK, so if I exit the shell, and re-login, that would do it, right? Sorry, no, because &#8220;login&#8221; spawned &#8220;sh&#8221;, the shell inherite stdin, stdout, stderr from &#8220;login&#8221;, in other words, the shell never open() the /dev/con1 device. Hm, so I have to run devc-ditto before &#8220;login&#8221; running? Yes, you can do that, by put devc-ditto in /etc/rc.d/rc.local, it actually works&#8230;.</p>
<p>But, but I don&#8217;t like that. I want to be able to start/stop/restart devc-ditto freely. After talk to some expert, I have put this in my .kshrc.</p>
<p>  alias reopen &#8216;exec 0&lt;$TTY 1&gt;$TTY 2&gt;$TTY&#8217;</p>
<p>Now, exit and login again on console 1, and type</p>
<p>   <strong><em># reopen</em></strong></p>
<p>Wohoo, after that, anything you type in concole 1, you should be able to see it in &#8220;cat&#8221;.</p>
<p>&#8220;But that&#8217;s now all &#8216;ditto&#8217; doing, I also want to type in from &#8216;the other window&#8217;&#8221;, yes, I hear you. To allow inject key, I made it so any character write() into /dev/con1.ditto device, would be read() out from the /dev/con1. So what do you need to inject key? Yes, use &#8220;qtalk&#8221;.  Now there are a few gocha of &#8220;qtalk&#8221;, first of all, you need a qtalk support &#8220;-O&#8221; option, which ignores file open count; Also qtalk tend to open a character device in &#8220;edit&#8221; mode, we want &#8220;raw&#8221; mode.  So here is what you do, (assume you are on /dev/con2)</p>
<p>    <em><strong># qtalk -O -m /dev/con1.ditto<br />
    </strong></em>&lt;in qtalk&gt;<br />
    <strong><em># stty raw &lt;/dev/con2</em></strong></p>
<p>After this, whatever you type in qtalk, would show up in /dev/con1, and processed by the shell running there. This ultimatlly gives you the same &#8220;ditto&#8221; experence. And of cause, all these are standard utilities (cat, qtalk), so they work over QNET just fine.</p>
<p>But this is not all of it. Since the principle is just hijack a device name, devc-ditto not limited to only console, you can use it against any character device, /dev/ser1, or maybe /dev/ttypX. Wait, &#8220;/dev/ttypX&#8221;, isn&#8217;t that means I can &#8221;ditto&#8221; into a telnet session? Exactly. I will leave the practice for you, to figure out how to &#8221;ditto&#8221; into a telnet session.</p>
<p>That&#8217;s all I have to say.  come to <a target="_blank" href="http://community.qnx.com/sf/discussion/do/listTopics/projects.core_os/discussion.newcode">ostech forum</a> if you want to discuss more, enhance it if you have more idea. Oh, one more thing, I made the devc-ditto also handle mount/umount, so you don&#8217;t need to start a lot of them if you want to monitor multiple interfaces.</p>
<p>   <strong><em># mount -Tditto /dev/ttyp5</em></strong></p>
<p>Now you can tap into /dev/ttyp5.ditto, after you done:</p>
<p>   <em><strong># umount /dev/ttyp5.ditto</strong></em></p>
<p>xtang</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/32/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/32/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=32&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/09/14/devc-ditto-the-principle-the-usage/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ca7b2d2f6abde1c636237bc7d9c8a24?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">xtang</media:title>
		</media:content>
	</item>
		<item>
		<title>Ditto Delivered!</title>
		<link>http://sendreceivereply.wordpress.com/2007/09/12/ditto-delivered/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/09/12/ditto-delivered/#comments</comments>
		<pubDate>Wed, 12 Sep 2007 11:01:31 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/09/12/ditto-delivered/</guid>
		<description><![CDATA[A couple of months ago we wrote about the missing QNX4 ditto for Neutrino and while script is an interesting alternative, the comments coming from some of you indicated that you just weren&#8217;t going to be happy until you got your ditto back! The good news is that a QNX developer, Xiaodan Tang, took it upon [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=29&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A couple of months ago we wrote about the <a href="http://sendreceivereply.wordpress.com/2007/06/21/ditto-everyones-favourite-missing-tool/">missing QNX4 ditto for Neutrino</a> and while script is an interesting alternative, the <a href="http://sendreceivereply.wordpress.com/2007/06/21/ditto-everyones-favourite-missing-tool/#comments">comments</a> coming from some of you indicated that you just weren&#8217;t going to be happy until you got your ditto back!</p>
<p>The good news is that a QNX developer, Xiaodan Tang, took it upon himself to help out and solve this ditto dilemma.  Xiaodan has written a new Neutrino service, aptly called devc-ditto, that will allow character buffer replication and general terminal emulation.</p>
<p>While solving a lingering problem is always good news, the next question people will inevitably ask is &#8220;<em>When can I get devc-ditto?</em>&#8220;. </p>
<p>The new devc-ditto is a <a href="http://en.wikipedia.org/wiki/Bad_Thing">good thing</a>.  As a general rule, we like to include good things in our product distribution.  Here is where the bad news<strong> <em>used to</em></strong> have to be delivered.  Our software releases are &#8220;<em>steady and stable</em>&#8221; which at times can be an euphamism for &#8220;<em>glacially paced</em>&#8220;.  This means that to get devc-ditto you would either have to wait for the commercial release (potentially a long time) or give your QNX sales rep a call and figure out a way to get this excellent piece of accellerated technology into your hands.</p>
<p><em>&#8230; but the times they are a changin&#8217;</em></p>
<p>QNX is shifting its entire R&amp;D team to a new <a href="http://community.qnx.com/sf/projects/community">Transparent Development model</a>.  In this model the source code for our products is being published live and the work on those products is taking place publicly.    Still commercial software development but with a flavour that should make open source developers, who like probing the product source and interacting with the authors/maintainers the source, much more at home.</p>
<p>I can hear you thinking &#8220;<em>Yeah yeah &#8230; neat.  Now how does this help me get devc-ditto?!</em>&#8220;</p>
<p>Well QNX has a lot of source to release, and it will take some time to clean it up into publically presentable form, but working with Xiaodan and the <a href="http://community.qnx.com/sf/projects/core_os">Core OS team</a> we have been able to get <a href="http://community.qnx.com/integration/viewcvs/viewcvs.cgi/trunk/services/devc-ditto/?root=coreos_pub&amp;system=exsy1001">devc-ditto included in the first OS source release</a>, which means you can <strong>get it</strong>, <strong>build it</strong>, <strong>use it</strong>, <strong>change it</strong> all to your hearts content!</p>
<ol>
<li><a href="https://www.qnx.com/account/login.html">Get a community username (aka your MyQNX username)</a></li>
<li><a href="http://www.qnx.com/products/getmomentics/">Get the latest development tools and distribution </a>(if you just want devc-ditto, and you have a dev seat, you can skip this)</li>
<li>Get the source: svn co &#8211;username=&lt;community_username&gt; <a href="http://community.qnx.com/svn/repos/coreos_pub/trunk/services/devc-ditto">http://community.qnx.com/svn/repos/coreos_pub/trunk/services/devc-ditto</a></li>
<li>Build it: make</li>
</ol>
<p>I&#8217;ll leave the <em>use-it</em> up to you to figure out now &#8230; if in doubt, post to the <a href="http://community.qnx.com/sf/wiki/do/viewPage/projects.core_os/wiki/OS_Forums_guide">OS forums</a> with your questions!  If you want to <a href="http://community.qnx.com/sf/wiki/do/viewPage/projects.core_os/wiki/GetTheOSSource">get more </a>and <a href="http://community.qnx.com/sf/wiki/do/viewPage/projects.core_os/wiki/BuildTheOSSource">build more</a> then you should really check out the whole <a href="http://">Core OS project</a> as well as the other community projects.</p>
<p>Thomas </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/29/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/29/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=29&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/09/12/ditto-delivered/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Anticip&#8230;&#8230;&#8230;..ation!</title>
		<link>http://sendreceivereply.wordpress.com/2007/09/11/anticipation/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/09/11/anticipation/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 00:40:33 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>
		<category><![CDATA[Tease]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/09/11/anticipation/</guid>
		<description><![CDATA[Back in the day, some 10 years ago, when I was a young Kiwi programmer on the far end of a very long copper wire into 175 Terence Matthews Crescent, being a QNX customer was a lot of fun. QUICS was cool (and I heard they were going to move their BBS system to a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=30&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Back in the day, some 10 years ago, when I was a young Kiwi programmer on the <a href="http://maps.google.com/maps?f=q&amp;hl=en&amp;q=19+Newton+Rd,+Newton,+Auckland+1010,+New+Zealand&amp;sll=45.286256,-75.872923&amp;sspn=0.002691,0.007167&amp;ie=UTF8&amp;cd=1&amp;geocode=0,-36.860897,174.753577&amp;ll=-36.860961,174.753106&amp;spn=0.00306,0.007167&amp;t=h&amp;z=18&amp;iwloc=addr&amp;om=1" target="_blank" title="far end">far end</a> of a very long copper wire into <a href="http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q=175+Terence+Matthews+Crescent,+Kanata,+ON,+Canada&amp;sll=37.0625,-95.677068&amp;sspn=24.912343,58.710937&amp;ie=UTF8&amp;ll=45.286256,-75.872923&amp;spn=0.002691,0.007167&amp;t=h&amp;z=18&amp;iwloc=addr&amp;om=1" title="175 Terence Matthews Crescent" target="_blank">175 Terence Matthews Crescent</a>, being a QNX customer was a lot of fun.  QUICS was cool (and I heard they were going to move their BBS system to a Usenet based NNTP reader!  WOW!), and you really got a sense of working WITH the team of talented individuals in far off, exotic Ottawa.</p>
<p>More often that not bug reports would be greeted with a friendly post saying &#8211; &#8220;Thanks!  Try this and let me know if it fixes your problem!&#8221;, and you&#8217;d be downloading a binary straight from the desk of Real Live Kernel Engineer.</p>
<p>Ah, the thrill of finding hidden paths and filenames embedded in that debug binary.</p>
<p>What it must be like to be a PART of that select club, to be involved directly in the creation of the most successful micro-kernel RTOS out there&#8230;</p>
<p>Wouldn&#8217;t you want to be part of that?</p>
<p>Well, I&#8217;ve been there over 10 years now, and all I can say is&#8230; <a href="http://www.qnx.com" title="Wednesday">I can&#8217;t wait until Wednesday!!!!!</a></p>
<p>:-D</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/30/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/30/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=30&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/09/11/anticipation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>Help! I can&#8217;t debug!</title>
		<link>http://sendreceivereply.wordpress.com/2007/08/22/help-i-cant-debug/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/08/22/help-i-cant-debug/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 01:08:32 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/08/22/help-i-cant-debug/</guid>
		<description><![CDATA[I was just coming off of my holidays and thought that I should run a quick check of my mailbox to see what new and exciting things had transpired while I was away and blissfully ignorant of the comings and goings at the office. What I found in my mailbox I found rather amusing.  I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=27&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was just coming off of my <a target="_blank" href="http://www.poetscove.com/">holidays </a>and thought that I should run a quick check of my mailbox to see what new and exciting things had transpired while I was away and blissfully ignorant of the comings and goings at the office.</p>
<p>What I found in my mailbox I found rather amusing.  I had four separate requests for help in getting the <a target="_blank" href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/utilities/g/gdb.html">QNX debugger </a>up and running using the <a target="_blank" href="http://www.qnx.com/developers/docs/6.3.0SP3/ide_en/user_guide/about.html">IDE</a>. </p>
<p>I&#8217;m not doing (<em>much</em>) IDE development these days but these types of requests still manage to find their way to me because of my dogged insistance that I use our Momentics tools for all of my development and also because I think that <a target="_blank" href="http://heather.cs.ucdavis.edu/~matloff/UnixAndC/CLanguage/Debug.html"><em>printf</em>  debugging is for dinosaurs</a>.  If the IDE can&#8217;t get the job done for you, then we need to fix it so that it can &#8230; feel free to tell us so!</p>
<p>Anyway &#8230; back those e-mails.  They all were stating that they just couldn&#8217;t get the IDE debugger to work.  The platforms were all different (arm, sh, x86) and the environments were all different (Windows, Linux and Neutrino) but the problem was the same.  The application would launch, but the IDE debug session would fail with a cryptic connection error.</p>
<p>Why is this happening?  For most IDE services, the<a target="_blank" href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/utilities/q/qconn.html"> qconn target agent</a> is all that needs to be up and running.  However, the debugger <em>also </em>makes use of the <a target="_blank" href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/utilities/p/pdebug.html">pdebug debugger target </a>agent.  This is launched automatically for you when you start debugging. </p>
<p>&#8230; unless it isn&#8217;t. </p>
<p>The problem is that since the IDE is telling qconn to launch the pdebug program, pdebug needs to be in one of two places:</p>
<ul>
<li>Accessible via qconn&#8217;s PATH environment variable</li>
<li>Located in /usr/bin/pdebug</li>
</ul>
<p>If the pdebug debugger target agent can&#8217;t be launched, then the debug session will fail &#8230; and the resulting error message provides absolutely no indication of what is going on and why the debug session failed.</p>
<p>While this bit of information is <a target="_blank" href="http://www.qnx.com/developers/docs/6.3.0SP3/ide_en/user_guide/debug.html">recorded in the documentation</a> for the IDE, it isn&#8217;t the first thing you would find when things go wrong.</p>
<p>So &#8230; if debugging wasn&#8217;t working for you and you never understood why and flipped back to printf&#8217;s take a close look at your configuration (and/or make sure that pdebug is in /usr/bin) and try it again &#8230; I think you&#8217;ll like it!</p>
<p>Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=27&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/08/22/help-i-cant-debug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Bleepin&#8217; Beeps!</title>
		<link>http://sendreceivereply.wordpress.com/2007/07/27/beepn-beeps/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/07/27/beepn-beeps/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 18:09:37 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/07/27/beepn-beeps/</guid>
		<description><![CDATA[Ok, here you go. I looked into the mystery that is devc-con, and I found a way to modify the beep. The unfortunate side is that it only works if you are running devc-con in QNX mode, so you will either have to do that (by passing the -Q option) or suffer with the loud [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=26&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ok, here you go.   I looked into the mystery that is devc-con, and I found a way to modify the beep.</p>
<p>The unfortunate side is that it only works if you are running devc-con in QNX mode, so you will either have to do that (by passing the -Q option) or suffer with the loud beeps (for now)</p>
<p>Ok, so go change your build file, and make sure your TERM env var is qnx</p>
<p>So we need to emit an escape sequence, which can be done thusly&#8230;</p>
<p># printf &#8220;%cs%c%c%c&#8221; 0x1b, &lt;c1&gt;, &lt;c2&gt;, &lt;c3&gt;</p>
<p>Where c1 c2 and c3 are the parameters&#8230;</p>
<p>Here&#8217;s a snippet of the state machine&#8230;</p>
<pre class="brush: cpp;">
case STATE_QNX4_11:&Acirc;&nbsp;&Acirc;&nbsp;&Acirc;&nbsp;&Acirc;&nbsp; /* esc_beep_set */
s-&gt;beep_ticks = (c &lt;= ' ') ? 6 : c - ' ';
s-&gt;esc_flag = STATE_QNX4_12;
break;
case STATE_QNX4_12:
s-&gt;xpos = c - ' ';
s-&gt;esc_flag = STATE_QNX4_13;
break;
case STATE_QNX4_13:
n = (s-&gt;xpos % 192) + ((c - ' ') % 192) * 192;
if(!n)
s-&gt;beep_counter = 0x0606;
else
s-&gt;beep_counter = (n &amp;lt; 19) ? 0xffff :
(unsigned)(1193180L / (long)n);
break;
</pre>
<p>The default values for beep_ticks and beep_counter are 6 and 0&#215;0606, respectively.</p>
<p>I haven&#8217;t quite worked out the optimimum, but basically if you screw it up, the beep is gone anyways, so I&#8217;m alright with that.  You guys can have fun playing.</p>
<p>I&#8217;ll try and work a nobeep facility into the next version of devc-con.</p>
<p>Sorry this is brief, I&#8217;m running out of time today.  I&#8217;ll try and elaborate more on exactly WHAT these things mean later (or maybe Thomas will&#8230;)</p>
<p>Enjoy!</p>
<p>Colin</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=26&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/07/27/beepn-beeps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>Dog days of summer &#8230;</title>
		<link>http://sendreceivereply.wordpress.com/2007/07/13/dog-days-of-summer/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/07/13/dog-days-of-summer/#comments</comments>
		<pubDate>Fri, 13 Jul 2007 12:40:11 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/07/13/dog-days-of-summer/</guid>
		<description><![CDATA[So weeks go by and you&#8217;re probably thinking What is up with those send receive reply guys? They haven&#8217;t posted anything in weeks! True &#8230; it has been a few weeks, but we haven&#8217;t been idle.  There are exciting things a brew at QNX during the summer heat &#8230; air conditioning being one of them [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=25&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So weeks go by and you&#8217;re probably thinking</p>
<p><em>What is up with those send receive reply guys? They haven&#8217;t posted anything in weeks!</em></p>
<p>True &#8230; it has been a few weeks, but we haven&#8217;t been idle.  There are exciting things a brew at QNX during the summer heat &#8230; air conditioning being one of them that tends to only make sporadic appearances unfortunately.</p>
<p>One of the more interesting features that is has worked its way into the Neutrino kernel for the next release (slated for the not too distant future) is going to be the ability to report out the mapping of physical memory of a system to virtual addresses used by individual processes. </p>
<p><em>&#8220;But we live in a <a href="http://en.wikipedia.org/wiki/Virtual_address">virtual address world</a>&#8220;,  </em>you say &#8220;w<em>hy would we want a physical map of a systems memory</em>?&#8221;</p>
<p>That was certainly my first impression.  Particularly with the fact that you can get a complete virtual address mapping for a process using the <a href="http://en.wikipedia.org/wiki/Procfs">/proc filesystem </a>and the appropriate devctl() and the entries for &lt;sys/procfs.h&gt; and &lt;sys/debug.h&gt;, you should be able to paint a fairly complete memory story all using virtual address information.</p>
<p>Turns out that that isn&#8217;t quite the case.  You can get close, but there are still some missing details when it comes to how particular shared libraries and executables are mapped within other mapped areas (for example using <a target="_blank" href="http://www.qnx.com/developers/docs/momentics621_docs/neutrino/utilities/m/mkifs.html#XIPvsCopy">execute in place</a> within secondary <a href="http://www.qnx.com/developers/docs/momentics621_docs/neutrino/technotes/multiple.html">image file systems</a>).  Getting access to the physical address allows you to resolve that ambiguity quite nicely.</p>
<p>Also, while I mentioned in the <a target="_blank" href="http://sendreceivereply.wordpress.com/2007/06/04/fragmentation-meeting-rooms-and-memory-allocators/">article on fragmentation</a> (yes &#8230; we will get back to that issue =;-) that the OS nominally hands out memory uniformly in ~4K chunks, it does have the ability to fragment over time.  In general this isn&#8217;t a problem since the MMU for the processor provides the mapping giving you virtual continuity over fragmented physical memory.</p>
<p>Unless you need (or want) physically contiguous memory.  This can lead to improved performance in some device drivers that can leverage DMA and direct IO data transfers.  It is also a requirement by some tooling like the instrumented kernel, that arranges its data buffers as one contiguous ring.</p>
<p>The interface for extracting this additional memory information will be through the <a target="_blank" href="http://en.wikipedia.org/wiki/Procfs">/proc interface</a> and is a multi-stage procedure, but the fact that the information is now available is great news.  </p>
<p>Now all we need is a tool to showcase this new information &#8230; nothing like writing a handy utility to help beat the heat!</p>
<p> Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=25&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/07/13/dog-days-of-summer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Ditto &#8230; everyone&#8217;s favourite missing tool</title>
		<link>http://sendreceivereply.wordpress.com/2007/06/21/ditto-everyones-favourite-missing-tool/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/06/21/ditto-everyones-favourite-missing-tool/#comments</comments>
		<pubDate>Thu, 21 Jun 2007 11:14:14 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/06/21/ditto-everyones-favourite-missing-tool/</guid>
		<description><![CDATA[This week I&#8217;m celebrating my nine year anniversary working with QNX.  When I started at QNX the company was in the throes of a major product development effort to bring QNX 6/Neutrino to market as its next generation operating system with full support for processor families other than x86.  When I started MIPS, PPC ports were [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=24&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This week I&#8217;m celebrating my nine year anniversary working with QNX.  When I started at QNX the company was in the throes of a major product development effort to bring QNX 6/Neutrino to market as its next generation operating system with full support for processor families other than x86. </p>
<p align="left">When I started MIPS, PPC ports were well underway with ARM and SH support starting up.   I&#8217;m not an expert in any particular processor architecture, so I ended up working through a lot of the general system bugs and polishing some of the rough edges of this new OS.  By necessity this meant spending a lot of time interacting with the very active set of QNX developers, who at that time were steeped in QNX 4 knowledge and trying to migrate their systems and software to this new OS.   There are a lot of basic similarities between QNX 4 and QNX 6 but there are enough differences that migration wasn&#8217;t a zero effort affair, despite a fairly comprehensive software migration kit.</p>
<p>About once a month I&#8217;d receive a request from QNX4 developers:</p>
<blockquote><p><em>&#8220;When will ditto be ported to Neutrino?&#8221; </em></p></blockquote>
<p>Of course, the first time I heard this comment I was intrigued since <em><a target="_blank" href="http://www.qnx.com/developers/docs/qnx_4.25_docs/qnx4/utils/d/ditto.html">ditto</a></em> is not a standard *nix utility, so I thought I&#8217;d look into it.  It turned out that porting this particular utility (which provides terminal replication and remote terminal access) to Neutrino was going to take some signficiant work and more or less be an entire re-write since the utility took specific advantage of how QNX 4 character device drivers were written.  Under Neutrino the serial driver code was completely different,  so at the time I turned my focus to other areas where fixes could be made more short term with a plan to come back to do the ditto re-write.</p>
<p>Here we are, nine years later and there <a target="_blank" href="http://sendreceivereply.wordpress.com/about/">are still people asking for <em>ditto </em>for Neutrino</a><em>.</em> </p>
<p>Boy do I feel bad about never getting back to that work =;-(</p>
<p>Well since <em>I </em>still<em> </em>haven&#8217;t ported ditto yet, the first thing I&#8217;m going to do is suggest an alternative that may be a more mainstream solution in these days of Linux fervor.  The <a target="_blank" href="http://www.gnu.org/software/screen/screen.html">GNU Screen</a> utility provides much of the same terminal multiplexing and remote or shared control that ditto did.  The source compiles, with a few minor changes, out of the box for Neutrino. While I haven&#8217;t taken it for a full test drive yet, this looks like it might be the best immediate solution and maybe even long term since there are <a target="_blank" href="http://www.kuro5hin.org/story/2004/3/9/16838/14935">several screen resources</a> available in the community.</p>
<p>However, ditto ain&#8217;t totally dead yet.  The other day walking through our source tree on a related project I noticed that one of our aspiring developers has done some work to make some of the ditto remote monitoring (no interaction) capabilities available for Neutrino.  This is still internal goods, and not in the next OS release, but perhaps this article might nudge it along if there is some competition.</p>
<p>Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=24&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/06/21/ditto-everyones-favourite-missing-tool/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Fragmentation; meeting rooms and memory allocators</title>
		<link>http://sendreceivereply.wordpress.com/2007/06/04/fragmentation-meeting-rooms-and-memory-allocators/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/06/04/fragmentation-meeting-rooms-and-memory-allocators/#comments</comments>
		<pubDate>Mon, 04 Jun 2007 15:28:52 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/06/04/fragmentation-meeting-rooms-and-memory-allocators/</guid>
		<description><![CDATA[At QNX we have a problem. We have many meeting rooms but we have many more developers that want to have meetings and discussions in those meeting rooms. While a certain amount of hallway development is always going to happen, the really big whiteboards are all in the meeting rooms &#8230; so that is where [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=22&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At QNX we have a problem.  We have <em>many</em> meeting rooms but we have <strong><em>many more</em></strong> developers that want to have meetings and discussions in those meeting rooms.  While a certain amount of <a href="http://www.joelonsoftware.com/articles/fog0000000043.html">hallway development</a> is always going to happen, the really big whiteboards are all in the meeting rooms &#8230; so that is where we have to gather.  Our admin folks use <a href="http://www.microsoft.com/technet/archive/exchangeserver55/maintain/cfbook.mspx?mfr=true">Microsoft Exchange</a>, so if you want to book the rooms then you need to play along (or call in a lot of favours!) and book through the Exchange server.  An interesting trend I&#8217;ve noticed is that every few months we tend to end up with a mysterious meeting room stall.  A time where it is not possible to use the system to book any meeting room in the building, but if you wander around you find that most of the rooms are not being used.</p>
<p>Mysterious &#8230; and incredibly annoying!</p>
<p>I&#8217;ve come to the conclusion that what is happening is that the Exchange meeting rooms are suffering from fragmentation.  When the system is cleared, then large groups book re-occuring meetings.  Time goes on, and the re-occuring meeting needs to be shifted and bumped, rooms get borrowe<em></em>d (or stolen) and when the meeting organizer changes the room, the room doesn&#8217;t officially get free&#8217;ed up until all participants clear <em>their</em> bookings of the rooms.  Over time things get so fragmented that until everyone clears their calendars you can&#8217;t book anything.</p>
<p>Fragmentation is a pain.  There are lots of schemes to avoid it in <a href="http://www.enterprisestorageforum.com/management/features/article.php/3356811">filesystems</a> and in <a href="http://citeseer.ist.psu.edu/johnstone97memory.html">memory allocators</a>, but eventually it comes down to the fact that you need to make arbitrary decisions about how to carve up a resource into pieces to satisfy a particular usage pattern.  In the case of operating system memory, this granularity is of page sizes which are <em>generally*</em> 4K chunks.  </p>
<p>For most embedded applications 4K of memory is an awfull lot so there is a secondary, application level, allocator that sits behind the malloc/free/realloc calls that applications use to get at the memory.  This memory allocator takes the pages provided by the operating system and then further carves them into bands of memory of smaller fixed block sizes as well as a list of &#8220;bigger blocks&#8221; that are non-uniform in size to satisfy the abnormal requests.  A great, more detailed, description of what the QNX memory allocator is doing is in the <a href="http://www.qnx.com/developers/docs/6.3.0SP3/ide_en/user_guide/about.html">QNX IDE User&#8217;s Guide </a>in the <a href="http://www.qnx.com/developers/docs/6.3.0SP3/ide_en/user_guide/memory.html">Memory Analysis</a> section.</p>
<p>If you snoop the  header file then you can see the <code>struct malloc_stats</code> structure that can provide you with information about how your system is using application allocated memory.  You will need to include the _malloc_stats external global variable to get at the numbers.  </p>
<p>While not a direct measure of fragmentation, these statistics give you some insight into the overhead that the memory allocator is taking and how much memory is being handed out to your application (and thus shows up in a pidin mem listing as application heap) but may not be used directly.  Note however that these statistics don&#8217;t tell the whole story and in the allocator it is possible for &#8220;big blocks&#8221; to be borrowed for &#8220;small block&#8221; use but for now we&#8217;ll pretend that those values tell you most of what you need to know to get started.</p>
<p>So now that you can see a bit of detail of how the application allocator is carving up and managing memory &#8230; what can you do when you find out that the allocator&#8217;s decision about small blocks or big blocks isn&#8217;t the right one for you but you don&#8217;t want to write your own memory allocator?  We&#8217;ll talk about that kind of customization (and how you know you need to do it) in my next post!</p>
<p>In the meantime, I need to go and find out which meeting room is suffering from fragmentation and grab it for a meeting!</p>
<p>Thomas</p>
<hr />
* I say generally here because with the introduction of large page support in new versions of Neutrino, a 4K page may be the general page size, but it isn&#8217;t the only page size =;-)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=22&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/06/04/fragmentation-meeting-rooms-and-memory-allocators/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>You&#8217;ve been waiting long enough!</title>
		<link>http://sendreceivereply.wordpress.com/2007/05/27/youve-been-waiting-long-enough/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/05/27/youve-been-waiting-long-enough/#comments</comments>
		<pubDate>Sun, 27 May 2007 20:54:23 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/05/27/youve-been-waiting-long-enough/</guid>
		<description><![CDATA[In my previous post on the problems with a polling waitfor, I mentioned that there was a timing window in which we could miss the notification event. If the path we were looking for was attached in between the stat() and the procmgr_event_notify() call (admittedly a small window) then we would end up waiting the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=21&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">In my <a href="http://sendreceivereply.wordpress.com/2007/04/24/what-are-you-waiting-for/">previous post</a> on the problems with a polling <span class="SpellE">waitfor</span>, I mentioned that there was a timing window in which we could miss the notification event.</p>
<p class="MsoNormal">If the path we were looking for was attached in between the <span class="GramE"><em>stat(</em></span><em>)</em> and the <span class="SpellE"><em>procmgr_event_notify</em></span><em>()</em> call (admittedly a small window) then we would end up waiting the entire timeout duration before noticing that the path had appeared.</p>
<p class="MsoNormal">Here’s a new version that uses a pulse that closes that hole, by using a pulse as the notification event.</p>
<pre>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;time.h&gt;
#include &lt;sys/netmgr.h&gt;
#include &lt;sys/neutrino.h&gt;

#include &lt;sys/procmgr.h&gt;
#include &lt;sys/siginfo.h&gt;

#define PULSE_CODE_TIMEOUT      _PULSE_CODE_MINAVAIL
#define PULSE_CODE_PATHSPACE    PULSE_CODE_TIMEOUT+1

int main( int argc, char *argv[] )
{
    struct itimerspec   timeout;
    int                 timer_id;
    struct sigevent     event;
    struct stat         sbuf;
    int                 chid, coid;
    char                *path;
    struct _pulse       pulse;

    path = argv[1];
    memset( &amp;timeout, 0, sizeof(timeout) );
    timeout.it_value.tv_sec = atoi(argv[2]);

    chid = ChannelCreate(0);
    coid = ConnectAttach( ND_LOCAL_NODE, 0, chid, _NTO_SIDE_CHANNEL, 0 );

    SIGEV_PULSE_INIT( &amp;event, coid, getprio(0), PULSE_CODE_TIMEOUT, 0 );
    timer_create( CLOCK_REALTIME, &amp;event, &amp;timer_id );

    /* make sure PATHSPACE event has higher priority */
    SIGEV_PULSE_INIT( &amp;event, coid, getprio(0)+1, PULSE_CODE_PATHSPACE, 0 );
    procmgr_event_notify( PROCMGR_EVENT_PATHSPACE, &amp;event );

    /* Check to make sure we don't wait for something already there... */
    if ( stat( argv[1], &amp;sbuf ) == 0 ) {
        printf("Found %s\\n", path );
        return EXIT_SUCCESS;
    }

    timer_settime( timer_id, 0, &amp;timeout, NULL );

    while( MsgReceivePulse( chid, &amp;pulse, sizeof(pulse), NULL ) == 0 ) {
        switch(pulse.code) {
        case PULSE_CODE_PATHSPACE:
            if ( stat( argv[1], &amp;sbuf ) == 0 ) {
                printf("Found %s\\n", path );
                return EXIT_SUCCESS;
            }
            break;
        case PULSE_CODE_TIMEOUT:
            printf("Timed out waiting for %s\\n", path);
            return EXIT_FAILURE;
        default:
            printf("Unknown pulse code %d waiting for %s\\n", pulse.code, path);
            return EXIT_FAILURE;
        }
    }
    return EXIT_FAILURE;
}</pre>
<p class="MsoNormal">Note that I use a timeout pulse too, and make the timeout pulse have a lower priority than the notification pulse.<span>  </span>This is because pulses queue in priority order, and I want to make sure that I receive the path event pulse first.</p>
<p class="MsoNormal">Cheers,</p>
<p class="MsoNormal">Colin</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=21&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/05/27/youve-been-waiting-long-enough/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>Resource manager dispatching &#8230; using your own channels</title>
		<link>http://sendreceivereply.wordpress.com/2007/05/12/resource-manager-dispatching-using-your-own-channels/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/05/12/resource-manager-dispatching-using-your-own-channels/#comments</comments>
		<pubDate>Sat, 12 May 2007 08:45:03 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/05/12/resource-manager-dispatching-using-your-own-channels/</guid>
		<description><![CDATA[Ever write a resource manager?  Ever wonder why you were doing that and not just the raw operating system primitives? If you have used Neutrino for any length of time, then you have probably done the former and if it was a trivial system, then the latter thought has probably crossed your mind. QNX&#8217;s message [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=17&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ever write a resource manager?  Ever wonder why you were doing that and not just the raw operating system primitives?</p>
<p>If you have used Neutrino for any length of time, then you have probably done the former and if it was a trivial system, then the latter thought has probably crossed your mind.</p>
<p>QNX&#8217;s message passing strategy is all about following the Send/Receive/Reply mantra where clients talk to servers and block until they are replied to with a message.  Under QNX4 there were <em>officially</em> no threads so when you were sending a message, you only needed to supply the node (transparent network message passing!) and the process identifier as routing information.  When Neutrino (QNX6) was introduced, threads were made first class citizensand to make the targeting of message operations completely unambiguous, message channels were added.  This meant that instead of just a node and process id, you also had to specify the channel identifier.</p>
<p> How does a client get these three pieces of information about the server it wants to talk to?  There are lots of different schemes to accomplish this depending on the structure of the system you are building; ranging from sticking the information into a piece of shared memory to passing it from parent to child processes via a fork/exec/spawn type of operation.   In a simple system, you can have simple sharing policies to get at this data, however as a system gets more complicated with more clients and servers, then things get out of hand quickly.</p>
<p>The preferred mechanism however, would be to let the OS do the heavy lifting and to replace the node, process id, channel id with a symbolic entry that is easy for clients to use and discover and let the resolution of that be handled by the operating system.</p>
<p>Enter the raison d&#8217;etre for the resource manager.  It was introduced to help facilitate that binding on both the client (name resolution) and on the server (node, process id, channel id binding) as well as providing dispatching capabilities to help with the demultiplexing of common messages to specific handlers.  The Neutrino Programmer&#8217;s Guide tells you all about this, and Rob Krten&#8217;s Neutrino books do a great job of providing further enlightenment.</p>
<p>About every six months or so I run into someone who is stuck in a very specific situation.  They have created their own channel via ChannelCreate(), perhaps to turn off priority inheritance or because they need to avoid using certain flags, and would like to use it with the resource manager framework.   The resource manager framework does such a  good job of abstracting and hiding the channel that it seems that it isn&#8217;t possible.</p>
<p> Alas &#8230; do not lose hope!  There is an undocumented function that allows this to occur:</p>
<pre>
dispatch_t *_dispatch_create(int chid, unsigned flags)
</pre>
<p>The function above allows you to pass in a channel identifier that you have created yourself and serves as a replacement for the general dispatch initialization function, dispatch_create(), that is the preferred initialization.  As always, when you are using something that is undocumented (but publicly exposed) there are some caveats to consider:</p>
<ul>
<li>The flags field should be passed as 0 at this time</li>
<li>In order for proper operation of the resource manager, you must specify _NTO_CHF_UNBLOCK | _NTO_CHF_DISCONNECT as flags for the channel.  Without these flags, your resource manager may fail to properly close off connections from clients that abnormally disconnect.</li>
</ul>
<p>One of the situations where this function is required, is if you are trying to have a resource manager as part of an application that also uses Photon.  While this joining of server and interface functionality is generally frowned upon (a clean separation is always preferred) there are some situations where it simply isn&#8217;t practical.  In this case, Photon generally grabs the _NTO_CHF_COID_DISCONNECT flag for itself, which the current resource manager framework assumes it will be able to use.  Since this flag can be set on only one channel per process, your resource manager will end up failing during initialization with a mysterious error &#8230; a future release will clean this up and allow everyone to play nice, but for the current 6.3.x releases of Neutrino, you will need to use this function to work around that situation.</p>
<p> Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=17&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/05/12/resource-manager-dispatching-using-your-own-channels/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Can you wait a little bit faster?</title>
		<link>http://sendreceivereply.wordpress.com/2007/05/02/can-you-wait-a-little-bit-faster/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/05/02/can-you-wait-a-little-bit-faster/#comments</comments>
		<pubDate>Wed, 02 May 2007 11:24:11 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/05/02/can-you-wait-a-little-bit-faster/</guid>
		<description><![CDATA[I was having a conversation with a customer the other day who was very concerned about a pidin listing where he was seeing something like the following: # pidin      pid tid name               prio STATE       Blocked ...        20   1 server_app          255o RECEIVE 1 20 1 server_app 10o RUNNING 20 1 server_app 255o RECEIVE 1 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=16&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was having a conversation with a customer the other day who was very concerned about a pidin listing where he was seeing something like the following:</p>
<pre>
# pidin
     pid tid name               prio STATE       Blocked
...
       20   1 server_app             255o RECEIVE    1
       20   1 server_app             10o  RUNNING
       20   1 server_app             255o RECEIVE    1
...
       32   1 client_app              10o REPLY         20
       32   2 client_app              10f NANOSLEEP
...</pre>
<p>He was concerned because most of his system generally operated at priority 10 and if there were tasks that were at priority 255, then wouldn&#8217;t those other tasks be starved out and never get a chance to run!?</p>
<p>Of course if you take a few minutes to reflect on what is really being displayed then peace and calm return quite quickly to the world. </p>
<p>The threads that are all marked as being high priority are all in blocking states.  That is to say that they are not RUNNING, nor are they wanting to run and in the READY state.  In fact they are all blocked waiting for some other sort of event to occur or non-CPU resource to become available.  While their reported priorities are high they are not going to interfere with the operation of the system &#8230; at least not until they transition to a RUNNING or READY state.   In the case of threads which are RECEIVE blocked such as is the case here, unless the communication channels were created specifically to avoid priority inheritance, the receive thread will end up READY/RUNNING at the priority of the sending client.</p>
<p>If that is the case you may wonder, why have pidin report the priority information on blocking states at all if it is just going to cause people this sense of panic and trigger these types of false alarms?</p>
<p>Well the information can be insightfull since in most blocking scenarios, the thread <em>was </em>READY or RUNNING prior to being blocked and as such the priority gives a hint to what they might have been doing.  Also in the case of priority inheritance states (MUTEX, SEND) then you can better see who is causing priorities to be automatically shifted in the system.</p>
<p>In this case, 255 was a curious number to be seeing and we eventually traced it back to their code where they were generating asynchronous pulse events to a server, but the pulses were not being properly initialized and were picking up junk off the stack and setting bad priorities &#8230; hence the 255 value. </p>
<p>QNX Coding Tip of the Day:  Don&#8217;t initialize <a href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/s/sigevent.html">sigevent</a>&#8216;s using the member values, use the <a href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/s/sigevent.html">SIGEV_*</a> macros!</p>
<p> Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=16&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/05/02/can-you-wait-a-little-bit-faster/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>What are you waiting for?</title>
		<link>http://sendreceivereply.wordpress.com/2007/04/24/what-are-you-waiting-for/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/04/24/what-are-you-waiting-for/#comments</comments>
		<pubDate>Tue, 24 Apr 2007 21:04:49 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/04/24/what-are-you-waiting-for/</guid>
		<description><![CDATA[One of the common problems I&#8217;ve helped customers with is optimising their device startup time. There are many things you can do to squeeze a few precious seconds out of your startup sequence, but one of the simplest may not be immediately obvious. The sequence devb-eide waitfor /dev/hd0 30 &#8230; is an all too common [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=14&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the common problems I&#8217;ve helped customers with is optimising their device startup time.</p>
<p>There are many things you can do to squeeze a few precious seconds out of your startup sequence, but one of the simplest may not be immediately obvious.</p>
<p>The sequence</p>
<p>devb-eide<br />
waitfor /dev/hd0 30<br />
&#8230;</p>
<p>is an all too common one, but it&#8217;s surprisingly damaging if you are trying to not waste cycles.</p>
<p>For one thing, it means that you can&#8217;t really start anything after the waitfor until devb-eide has gone through its sometimes lengthy initialization sequence (sorry devb, don&#8217;t mean to pick on you&#8230;).</p>
<p>Really all the system can do is to finish off the initialization of any servers you already started and poll for the device to appear.</p>
<p>Wait a second &#8211; POLL??!!!</p>
<p>Hmmm, in RTOS speak, Poll=BAD, WaitForAnEvent=GOOD!</p>
<p>Yes, my friends, it&#8217;s sad to say that /bin/waitfor (actually the amazingly versatile /bin/on) does actually poll, with a period of 100ms to boot, as does the builtin version that procnto provides when running your image&#8217;s startup script.</p>
<p>There are a number of nasties associated with this, one of the most annoying being that if your device appears 1ms after that 100ms poll (which is just a stat()) then you&#8217;re going to wait around for ANOTHER 99ms before waitfor notices!</p>
<p>And unless you have plenty else going on in the meantime then that means the dreaded idle thread will happily be using up your precious cpu.  Another good reason to have plenty of servers started BEFORE you do the waitfor.</p>
<p>So how about a remedy?</p>
<p>Well, the basic version of waitfor looks something like this&#8230;</p>
<p>while we haven&#8217;t reached the max limit<br />
do<br />
stat the device<br />
if it&#8217;s there, break out<br />
delay 100ms<br />
done</p>
<p>Wouldn&#8217;t it be nice if we could do something more like</p>
<p>while we haven&#8217;t reached the max limit<br />
do<br />
sleep for the remaining timeout, but wakeup if the device appears?<br />
done</p>
<p>Well, as it happens, if you are running QNX6.3.0 SP2 or later, then there is actually a facility you can use.  It&#8217;s a new flag to procmgr_event_notify, PROCMGR_EVENT_NAMESPACE,which will see a sigevent winging it&#8217;s way to you whenever the pathspace changes, which is basically whenever someone attaches or detaches a pathname.</p>
<p>So here&#8217;s a revised version of waitfor that waits until something changes, then hopefully stats the device.</p>
<blockquote><p>#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;sys/stat.h&gt;<br />
#include &lt;sys/time.h&gt;<br />
#include &lt;sys/procmgr.h&gt;<br />
#include &lt;sys/siginfo.h&gt;</p>
<p>int main( int argc, char *argv[] )<br />
{<br />
struct sigevent event;<br />
struct stat     sbuf;<br />
int             timeout;<br />
int             total;<br />
char            *path;<br />
time_t          start, now;</p>
<p>path = argv[1];<br />
timeout = atoi(argv[2]);</p>
<p>if ( stat( argv[1], &amp;sbuf ) == 0 ) {<br />
printf(&#8220;Found %s!\n&#8221;, path );<br />
return EXIT_SUCCESS;<br />
}</p>
<p>SIGEV_UNBLOCK_INIT( &amp;event );<br />
procmgr_event_notify( PROCMGR_EVENT_PATHSPACE, &amp;event );</p>
<p>start = time(NULL);<br />
do {<br />
sleep( timeout );<br />
if ( stat( argv[1], &amp;sbuf ) == 0 ) {<br />
printf(&#8220;Found %s!\n&#8221;, path );<br />
return EXIT_SUCCESS;<br />
}<br />
now = time(NULL);<br />
timeout -= (now &#8211; start);<br />
start = now;<br />
} while( timeout &gt; 0 );<br />
return EXIT_FAILURE;<br />
}</p></blockquote>
<p>If 99ms of idle time upsets you, this might help you sleep better.</p>
<p>Colin</p>
<p>PS &#8211; yes, this will be fixed in the next release of the kernel/utils, if I have anything to do with it.</p>
<p>PPS &#8211; I should mention that there is yet another location that waitfor is defined, that is the ewaitfor builtin in /bin/fesh.  This version at least lets you set the poll period, as a third argument to ewaitfor.  Again, that should be in 6.3.0 SP2 or later.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=14&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/04/24/what-are-you-waiting-for/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>From file to device &#8230;</title>
		<link>http://sendreceivereply.wordpress.com/2007/04/15/from-file-to-device/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/04/15/from-file-to-device/#comments</comments>
		<pubDate>Sun, 15 Apr 2007 18:18:22 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/04/15/from-file-to-device/</guid>
		<description><![CDATA[Interesting question arose last week from one of the media developers at QNX working with a third party library.  The API that the third party was providing to him involved him providing a file path to the library, that was then stored and passed back to him as a plugin that he was supposed to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=13&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Interesting question arose last week from one of the media developers at QNX working with a third party library.  The API that the third party was providing to him involved him providing a file path to the library, that was then stored and passed back to him as a plugin that he was supposed to use for some specialized device access (in this case a custom CD drive handling).</p>
<p>The problem, other than the not so elegant API required by this third party library, was that while the library needed a filename to work with, his plugin needed to send drive level control commands in the form of custom <a href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/d/devctl.html">devctl()</a>&#8216;s.</p>
<p> This reminded me of some control commands that had been put in to the block/filesystem level in the early days of Neutrino.  Hunting around I found the devctl() commands I was looking for in <strong>&lt;sys/dcmd_blk.h&gt;</strong>:</p>
<pre>
#define DCMD_FSYS_MOUNTED_ON  __DIOF(_DCMD_FSYS,  16, char[256])
#define DCMD_FSYS_MOUNTED_AT  __DIOF(_DCMD_FSYS,  17, char[256])
#define DCMD_FSYS_MOUNTED_BY  __DIOF(_DCMD_FSYS,  18, char[256])</pre>
<p>When you have a file descriptor that points to something handled by of of the block oriented filesystems or block driver (ie devb-*), then you can use these handy commands to dig down or up or to determine where an entry is mounted in the filesystem.</p>
<p><strong>DCMD_FSYS_MOUNTED_ON</strong><br />
This command will return the pathname of the underlying device, partition or file the current entry was <em>mounted on</em>. For example a file descriptor to a filesystem file will generally point back to a partition (or the raw block device), a partition file descriptor will point back to the raw device. In this way you can burrow your way down to the controlling device.</p>
<p><strong>DCMD_FSYS_MOUNTED_BY</strong><br />
This command tries to root out and determine where the file descriptor you are referencing has been mounted if it is a singular mount point such as a partition. This is an upward version of MOUNTED_ON, but since multiple users can exist for a single device, it isn&#8217;t as generally useful as the MOUNTED_ON command.</p>
<p><strong>DCMD_FSYS_MOUNTED_AT</strong><br />
This command tells you where the object that you are referencing was mounted at. This is similar to the type of information that you get back from the mount utility, but in this case the MOUNTED_AT command is a specific command for the block filesystem.</p>
<p>Due to the overlay nature of the Neutrino pathname space, these commands are really only applicable for file entries since directory entry resolution isn&#8217;t as explicit as for files*, but can come in handy if you are in a pinch like we were with this silly third party library API.</p>
<p>Thomas</p>
<hr />
* We&#8217;ll leave the magic of mountpoints, overlays and the contents of the /proc/mount directory for a rain(ier) day I think.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=13&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/04/15/from-file-to-device/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello World (SIGSEGV remix)</title>
		<link>http://sendreceivereply.wordpress.com/2007/04/11/hello-world-sigsegv-remix/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/04/11/hello-world-sigsegv-remix/#comments</comments>
		<pubDate>Wed, 11 Apr 2007 03:08:52 +0000</pubDate>
		<dc:creator>colinburgess</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/04/11/hello-world-sigsegv-remix/</guid>
		<description><![CDATA[Hi there, I&#8217;m Colin. Look Ma, I can write programs&#8230; #./hello Process 5861407 (hello) terminated SIGSEGV code=1 fltno=11 ip=b0348cec mapaddr=00048cec. ref=00000000 Oops, that’s not the start to this blog that I was hoping to make. Two lines in and already my efforts are riddled with bugs. Oh my. In actual fact though, I wanted to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=12&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="snap_preview">Hi there, I&#8217;m Colin.  Look Ma, I can write programs&#8230;</p>
<p><strong>#./hello<br />
Process 5861407 (hello) terminated SIGSEGV code=1 fltno=11 ip=b0348cec mapaddr=00048cec. ref=00000000</strong></p>
<p>Oops, that’s not the start to this blog that I was hoping to make. Two lines in and already my efforts are riddled with bugs. Oh my.</p>
<p>In actual fact though, I wanted to start of by sharing some a tidbit I found the other day, while staring at the termination code in procnto.</p>
<p>The message you see above is generated by the termer thread, which runs some procnto code on behalf of your dearly departed process to cleanup leftover resources, such as file descriptors, memory mappings etc.  And one of the things it does, if you have added a -v to procnto in your build file, is to print out information about the exit status of processes.</p>
<p>What it tells us is that your process died of a <strong>SIGSEGV</strong>, and the code=1 (<strong>SEGV_MAPERR</strong> from sys/siginfo.h) and fault=11 (<strong>FLTPAGE </strong>from sys/fault.h) tell me that it was trying to access a page that wasn’t mapped.</p>
<p>It died at the address <strong>0x</strong><strong>b0348cec</strong>, which is all very well, but if I load my hello binary into gdb then this address is clearly not in my application.</p>
<p>The clue is <strong>mapaddr=000</strong><strong>48cec</strong>. This tells me that the object that contains the offending code was relocated when it was mapped into memory, and thus we are crashing in a shared object.  But where/what is 0x48cec?  The long winded approach is to figure out which shared object contains <strong>0xb0348cec</strong> (using pidin mem) and then load that shared object into either gdb or objdump.  But that&#8217;s all rather grungy.</p>
<p>Which brings me to the paydirt &#8211; there is code in the termer thread to actually fish out the name of the shared library and the function name in which you crashed!</p>
<p>So why weren’t we seeing this? Well a little investigation revealed that a linked list that was supposed to point to the process’ shared objects was not being initialised (Note this bug has been fixed now and will be available in a newer version of libc.so).</p>
<p>The initialisation function is an internal function, but you can force it to be re-called by trying to figure the address of a symbol with dladdr().</p>
<p>So now, here’s my hello world with dladdr invocation added.  You might already note my error, but let’s run it just in case…</p>
<p>#include &lt;stdio.h&gt;<br />
#include &lt;dlfcn.h&gt;</p>
<p>int main(int argc, char **argv)<br />
{<br />
char *world = NULL;<br />
Dl_info info;</p>
<p>dladdr( main, &amp;info );</p>
<p>printf( &#8220;Hello %s!\n&#8221;, strdup(argv[1]) );</p>
<p>world = &#8220;World&#8221;;</p>
<p>return 0;<br />
}</p>
<p><strong>#./hello<br />
Process 5951519 (hello) terminated SIGSEGV code=1 fltno=11 ip=b0348cec(libc.so.2@strdup+0&#215;20) mapaddr=00048cec. ref=00000000</strong></p>
<p>Well silly me &#8211; I simply forgot to pass a command line (not to mention some nice error checking?  Serves me right for writing such a contrived example&#8230; )</p>
<p><strong>#./hello World<br />
Hello World!</strong></p>
<p><strong>Process 6004767 (hello) exited status=0.</strong></p>
<p>Ah, that&#8217;s better&#8230;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=12&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/04/11/hello-world-sigsegv-remix/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7e3aa5b9792e8f4b938a53f2e679264b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">colinburgess</media:title>
		</media:content>
	</item>
		<item>
		<title>Mutex or Semaphore for Performance?</title>
		<link>http://sendreceivereply.wordpress.com/2007/04/10/mutex-or-semaphore-for-performance/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/04/10/mutex-or-semaphore-for-performance/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 14:19:03 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/04/10/mutex-or-semaphore-for-performance/</guid>
		<description><![CDATA[I had someone who was porting code over to Neutrino ask the other day about the choice of synchronization primitives to use in a semaphore callout that the software had to provide mutual exclusion for its data structures. The developer&#8217;s initial thought was to use a semaphore since that is what the name of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=10&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had someone who was porting code over to Neutrino ask the other day about the choice of synchronization primitives to use in a semaphore callout that the software had to provide mutual exclusion for its data structures.</p>
<p>The developer&#8217;s initial thought was to use a semaphore since that is what the name of the callout implied, and other ports had used named semaphores &#8230; and QNX/POSIX has semaphores, both <a href="http://www.opengroup.org/onlinepubs/007908799/xsh/sem_open.html">named</a> and <a href="http://opengroup.org/onlinepubs/007908799/xsh/sem_init.html">un-named</a>, but the comment about the use of the callout to provide mutual exclusion seemed to imply that despite the naming, a <a href="http://www.opengroup.org/onlinepubs/007908775/xsh/pthread_mutex_init.html">mutex</a> would be a better choice for performance which is when he asked me about it.</p>
<p>Assuming that you are using a <a href="http://en.wikipedia.org/wiki/Semaphore_(programming)">binary semaphore</a> and not a <a href="http://en.wikipedia.org/wiki/Semaphore_(programming)">counting semaphore</a> then purely from a performance point of view here is your ranking from worst to best choices:</p>
<p><strong>Named Semaphore</strong></p>
<p>This is a semaphore that trades off API convenience* (a pathname style location) for performance since you are going to be going through a resource manager (procnto in later versions of Neutrino or mqueue in earlier versions of Neutrino) who will be serializing the access to the semaphore count. While operationally it is the same, this extra messaging is going to impose an extra bit of overhead.</p>
<p><strong>Normal Semaphore</strong><br />
This is a semaphore that is not identified by name, and whose operation is managed by the kernel. For each semaphore operation (<em>sem_wait/sem_post</em>) a kernel call is made to handle the management of the semaphore data. This is a smaller overhead than then message passing and server operations required for a named semaphore, but is still a kernel call for each semaphore call.</p>
<p><strong>Mutex</strong><br />
While a mutex doesn&#8217;t provide the same semantics as a counting semaphore, is can be a great high performance alternative to a binary semaphore. Under Neutrino, mutexes are highly optimized such that they use the processor&#8217;s atomic operations to do an in place compare and exchange. Only if the mutex is contested is there any requirement to enter into the kernel. This means that in most cases where there is only minimal contention for the synchronization primitive there is no additional kernel call overhead</p>
<p><strong>Inline Mutex</strong><br />
For most operations, the standard mutex is going to provide much better performance than a binary named semaphore and also better performance than the normal semaphore. However, if you really want to crank performance (and still use standard primitives) then you might have noticed that there are also inline mutex operations defined in <a href="http://cvs.qnx.com/cgi-bin/cvsweb.cgi/lib/c/public/pthread.h?rev=1.1.1.1&amp;content-type=text/x-cvsweb-markup">pthread.h</a>.</p>
<p>So in general, I tend to favour mutex operations over semaphores just because they are so nicely optimized. If you need to have a counting semaphore, then you might want to consider using a condition variable instead (which relies on a mutex base) for greater flexibility and potentially higher throughput. If that is the case, reading through the post <a href="http://sendreceivereply.wordpress.com/2007/03/13/4/">a condvar is not a semaphore</a> might be usefull.</p>
<hr />*Named semaphores, normal semaphores and mutexes can all be used as synchronization tools that can be used between threads or processes. For named semaphores, this is inherent in the API for creating them, for un-named semaphores and mutexes they need to be created in a block of shared memory.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=10&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/04/10/mutex-or-semaphore-for-performance/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Embedding help into your binaries</title>
		<link>http://sendreceivereply.wordpress.com/2007/04/04/embedding-help-into-your-binaries/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/04/04/embedding-help-into-your-binaries/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 16:36:37 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[QNX]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/04/04/embedding-help-into-your-binaries/</guid>
		<description><![CDATA[Since QNX Neutrino is designed primarily to be deployed on embedded systems but also maintain many of the self-hosted characteristics that makes development on those platforms efficient (no-reboots, easy access, familiar cmd line tools) its help system is dually organized. There is a rich set of standard documentation (HTML or PDF) for the operating system, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=9&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Since QNX Neutrino is designed primarily to be deployed on embedded systems but also maintain many of the <em>self-hosted</em> characteristics that makes development on those platforms efficient (no-reboots, easy access, familiar cmd line tools) its help system is dually organized. There is a rich set of standard documentation (HTML or PDF) for the operating system, its programming environment, various libraries and utility functions.</p>
<p>However, since that documentation is not always at hand when you want to run a quick command* each target binary (ls, find, pidin etc) also contains an embedded text segment that holds a description on how to <em>use</em> the utility. In order to get at this information, you use the imaginatively named <a href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/utilities/u/use.html">use utility</a>.</p>
<p>For example, I never remember all the options to the <em>find </em>utility. If I were on a target then I could type in:</p>
<pre>
 % use find
find  - find files (POSIX)
find  ... [operand_expression]
Operand expressions:
...</pre>
<p>In some ways this information is equivalent to unix style man pages, but since it is embedded directly into the binaries you never have to do any fancy configuration to prune information in (or out). Compared to rooting through and finding the utilities you use and then pruning the man pages appropriately, this is <a href="http://www.script-o-rama.com/movie_scripts/m/mr-deeds-script-transcript-sandler.html">wicked easy</a>.</p>
<p>In addition to the usage type of information, you can also print out build version information that is included with QNX binaries:</p>
<pre>
 % use -i find
NAME=find
DESCRIPTION=find files
DATE=2004/12/16-00:01:41-EST
STATE=Stable
HOST=uberbuild
USER=toolsbuild
VERSION=6.3.0SP1
TAGID=329</pre>
<p>If you are ever contacting QNX support, this is great stuff to send them so that they can match up your binaries directly with the source for a given release if need be.</p>
<p>Under Neutrino the usage information is stuffed into two different ELF sections of the binary.</p>
<pre>
 % ntox86-objdump -h find
/usr/bin/find:     file format elf32-i386
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
...
 19 QNX_usage     00004fb7  00000000  00000000  0000d304  2**0
                  CONTENTS, READONLY
 20 QNX_info      00000085  00000000  00000000  000122bb  2**0
                  CONTENTS, READONLY</pre>
<p>This approach is a double edged sword. On the one hand it means you don&#8217;t pay a memory penalty when loading the process since the QNX loader knows that these sections aren&#8217;t executable and basically ignores them. Since they are standard ELF sections, you can use all of the standard binary manipulation tools to work with them. The downside of this is that these sections can be removed by utilities such as <em>strip</em>, although the Neutrino image build process, using <a href="\QNX630\target\qnx6\usr\help\product\neutrino\utilities\m\mkifs.html">mkifs</a> will preserve these sections in the OS filesystem image.</p>
<p>The cool thing is that this information stuffing isn&#8217;t something just reserved for QNX utilities and shared objects! It can be added to any Neutrino binary via the <a href="\QNX630\target\qnx6\usr\help\product\neutrino\utilities\u\usemsg.html">usemsg utility</a>. There is no set format for the general usage section (QNX_usage), so you can put whatever you like there. The convention is to put command line parameter explanations and example invocations in this free form text section. The information section (QNX_info) is a structured key=value area and has a date and time field that is automatically updated when information is added. It is easy to use this technique to integrate notes that can be easily retrieved on both host and target systems.</p>
<pre>
% use -i ./a.out
No info available in ./a.out.
% usemsg -i qnx=cool ./a.out
% use -i ./a.out
NAME=a.out
DATE=2007-03-25EDT-20:06:24
QNX=cool</pre>
<p>Use messages are definitely a handy bit of infrastructure that make things just a bit easier for you to work with and manage your system software.</p>
<hr />
* For example working remotely connected to a customer site with no development environment at hand.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=9&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/04/04/embedding-help-into-your-binaries/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Goto be gone! Long live do {} while!</title>
		<link>http://sendreceivereply.wordpress.com/2007/03/27/8/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/03/27/8/#comments</comments>
		<pubDate>Tue, 27 Mar 2007 12:43:46 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[API]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/03/27/8/</guid>
		<description><![CDATA[Part of my role at QNX is to be ornery about source code style, formatting, consistancy and the like. Obviously a very popular role to fill =;-) One of the particularly religious debates that we occasionally get into revolves around the use of the goto statement. There are many people who use the goto statement [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=8&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Part of my role at QNX is to be ornery about source code style, formatting, consistancy and the like. Obviously a very popular role to fill =;-)</p>
<p>One of the particularly religious debates that we occasionally get into revolves around the use of the goto statement. There are many people who use the <a href="http://www.acm.org/classics/oct95/">goto statement considered harmful</a> to argue that there is no rightfull place for a goto in our code.</p>
<p>This attachment to a particular dogma means that for complex structure initialization code developers often end up running a series of <em>if</em> clauses initializing each member of the structure in turn. If the code properly deals with errors and rollsback to undo the initialization, you end up with one of two scenarios:</p>
<li>If progress stops on initialization failure, then each <em>if</em> clause ends up having a growing list of clean up items on failure. A good compiler will optimize this, but it is too easy to forget an item and end up with a resource leak of one sort or another.</li>
<li>If progress continues, then you end up with a deeply nested if statement where the final return (on success) lies deep in the heart of the nesting. The cleanup for resources is generally straightforward, but in many cases the cleanup lies so far away (in code editor space) that it is cumbersome to read.</li>
<p>For this reason, I&#8217;ve always appreciated the <em>goto</em> statement as acceptable for these types of &#8220;go to a cleanup&#8221; scenarios where you have a large initialization dependancy (as might happen in a QNX resource manager) and want to group the cleanup so as to improve the readability and reduce the chance of an accidental resource leak. Unlike the use of <em>goto</em> resulting in spaghetti code flow control, this is a much more tempered use of <em>goto</em> statements in C code.</p>
<p>However, the other day I was participating in a code review and came across an interesting use of the <em>do {} while</em><br />
loop to achieve a similar early exit, but without all of the contempt of those who think that goto should be removed from the language all together:</p>
<pre>
  //Structure declaration and initial allocation here
  do {
    // ... Member initialization here
    if(failure) {
      break;
    }
    ...
   //Return successfully allocated and initialized member here
   } while(0);

   //Cleanup and failure reporting all goes here
</pre>
<p>Here you get a nice linear, easy to read and maintain flow of code initialization without being burdened by the error condition flow control that a nested if requires or the deep unrolling of initialization that a chained if requires.</p>
<p>In any case a nice escape away from goto&#8217;s; even though <a href="http://www.cs.utexas.edu/users/EWD/transcriptions/EWD13xx/EWD1308.html">Dijkstra never said goto was considered harmfull</a> =;-).</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=8&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/03/27/8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Grabbing cores</title>
		<link>http://sendreceivereply.wordpress.com/2007/03/21/grabbing-cores/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/03/21/grabbing-cores/#comments</comments>
		<pubDate>Wed, 21 Mar 2007 23:52:10 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[Debugging]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/03/21/grabbing-cores/</guid>
		<description><![CDATA[I love debuggers. I don&#8217;t know what I would do without having a good capable debugger as part of my development toolbox. The ability to see right into the core operation of a piece of software and quickly get and overview of the whole state of the program beats random printf markers anyday. Oddly enough, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=6&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I love debuggers. I don&#8217;t know what I would do without having a good capable debugger as part of my development toolbox. The ability to see right into the core operation of a piece of software and quickly get and overview of the whole state of the program beats random printf markers anyday.</p>
<p>Oddly enough, my first memory of using a debugger had nothing to do with traditional debugging. I was a co-op student working on some speech processing software using the now defunct Mac <a href="http://www.freescale.com/webapp/sps/site/homepage.jsp?nodeId=012726">CodeWarrior</a> development tools.</p>
<p>I was trying to figure out how to insert timing measurements into a large piece of algorithmic software to determine how to best optimize it.</p>
<p><em>&#8220;Simple&#8221;</em> said one of my colleagues at the time. He fired up the debugger and started stepping through the project:</p>
<blockquote><p><strong>step step, step &#8230;&#8230;&#8230;&#8230; step</strong></p></blockquote>
<p><em>&#8220;That&#8217;s the function you should look at&#8221;</em> indicating the one with the long step time delay.</p>
<p>A true <a href="http://en.wikipedia.org/wiki/KISS_principle">KISS principle</a> that I&#8217;ve used over and over to do basic analysis of where a program is spending its time. Simple and effective when you are considering software where delays and latency is measured in seconds.</p>
<p>The cool thing about working with QNX systems is that you can use the same debugger and techniques on just about any piece of system software. Services, drivers and applications are all outside the kernel so there are very few occasions where you can&#8217;t attack a problem using a process level debugger.</p>
<p>Neutrino uses <a href="http://sources.redhat.com/gdb/">gdb</a> as its main debugger (the IDE drives gdb under the covers) and one of the great facilities that gdb enables is the ability to do post-mortem analysis on crashed binaries using core files.</p>
<pre>
 % ntox86-gdb my-x86-binary my-x86-binary-corefile</pre>
<p>or if you are in the IDE then create a post-mortem debug session and select the binary and the core file as part of the launch configuration.</p>
<p>Capturing core files on a target Neutrino system requires that you run the <a href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/utilities/d/dumper.html">dumper program</a>. If (when?) your program abnormally terminates, assuming dumper is running, a core file will be generated and a diagnostic message logged. You can then load up the debugger with the core file and get right to the root of the problem.</p>
<p>The dumper program has a bunch of usefull options, but one of the most usefull is the <code>-p</code> option that allows you to generate a core file for any running process without terminating that process.</p>
<pre>
 % dumper -p process_id -d dump_directory</pre>
<p>This is a great way to capture program snapshots for those situations where you can&#8217;t attach to the running program due to potential latency<br />
or you just want to get an idea of the program state (ie the program seems to be hung up or burning CPU) and don&#8217;t have a local debugger connection.</p>
<p>Once you have the core file, you load up into the debugger the same way as if you had received a core file from a crash.</p>
<p>Simple, easy and totally pain free debugging!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=6&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/03/21/grabbing-cores/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Browsing trumps searching</title>
		<link>http://sendreceivereply.wordpress.com/2007/03/17/browsing-trumps-searching/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/03/17/browsing-trumps-searching/#comments</comments>
		<pubDate>Sat, 17 Mar 2007 00:11:27 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Debugging]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/03/17/browsing-trumps-searching/</guid>
		<description><![CDATA[I was doing some maintenance work (bug fixing) on some code that was using the strncopy(src,dst,n)function to limit the number of bytes that were being copied.  Even though I&#8217;ve used this function hundreds of times, I never remember the exact details of what happens  with respect to the length and the terminating null character is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=5&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was doing some maintenance work (bug fixing) on some code that was using the <a target="_blank" href="http://www.opengroup.org/onlinepubs/009695399/functions/strncpy.html">strncopy(src,dst,n)</a>function to limit the number of bytes that were being copied.  Even though I&#8217;ve used this function hundreds of times, I never remember the exact details of what happens  with respect to the length and the terminating null character is it included as part of the length or isn&#8217;t it (it isn&#8217;t).   As a result I end up taking a trip into our QNX documentation and the C library reference to double check the behaviour.   Here is how the reading went this time for me:</p>
<blockquote><p> <em>copy no more than n bytes over from dst to src. &#8230; yeah yeah &#8230; </em></p></blockquote>
<p>then <strong>whammo</strong> the next line from the docs jumped right out at me:</p>
<blockquote><p><em>If the string pointed to by src is shorter than n characters, null characters are appended to the copy in the array pointed to by dst, until n characters in all have been written.</em></p></blockquote>
<p>Wow! So strncpy() is <em>always</em> padding out the full size of the buffer with null characters. I don&#8217;t know why this hadn&#8217;t struck me before, but this time I was looking at some code that was working with a large maximum buffer (4K) but was most often dealing with strings that were only 10 or 20 characters long.  Since this was being done repeatedly, it seemed like a code change was going to be in order, something along the lines of (using the same <em>src</em>,<em>dst </em>and <em>n</em>):</p>
<pre>
int len = strlen(src) + 1;  

if(len &gt; n) {
   len = n - 1;
   dst[len] = '';
}   

memcpy(dst, src, len);</pre>
<p>This was kind of a drag since it was more code to write, but it was going to be a bit more efficient since we weren&#8217;t going to iterate over all 4K of the buffer padding it in with bytes we didn&#8217;t need &#8230; although we were passing twice through the string. Wanting to double check the order of the <em>src</em> and <em>dst </em>arguments for <a href="http://www.opengroup.org/onlinepubs/007908799/xsh/memcpy.html">memcpy </a>I headed back to the docs. I use the HTML index instead of the search so I jumped to the &#8216;M&#8217; functions. Looking through the list I came across a library function I had never heard of before &#8230; <a href="http://www.opengroup.org/onlinepubs/000095399/functions/memccpy.html">memccpy</a> so I thought I&#8217;d take a quick read of it:</p>
<blockquote><p><em>Copy bytes between buffers until a given byte is found</em></p></blockquote>
<p>Cool! That is exactly what I was looking for. The call does an efficient one pass iteration copying only the data bytes until it hit the matching character or it runs out of space to copy to.  I still needed to deal with ensuring the destination buffer was going to be null terminated (as with strncpy() ) but at least now I wasn&#8217;t spending any time filling in extra bytes as padding:</p>
<pre>
if(memcchr(dst, src, '', n) == NULL) {
dst[n-1] = '';
}</pre>
<p>So, now I get the security of a bounded string buffer copy and efficiency to boot and I picked up a new standard C API for my toolbox &#8230; all because I like to browse the API instead of using the indexed search!  Of course, perhaps at some point this will get even more straightforward if the <a href="http://www.gratisoft.us/todd/papers/strlcpy.html">strlcpy()</a> function becomes part of POSIX/ANSI C standard.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=5&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/03/17/browsing-trumps-searching/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>A condvar is not a semaphore &#8230;</title>
		<link>http://sendreceivereply.wordpress.com/2007/03/13/4/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/03/13/4/#comments</comments>
		<pubDate>Tue, 13 Mar 2007 12:19:38 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[API]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/03/13/4/</guid>
		<description><![CDATA[I&#8217;ve been running into some situations lately where developers have been using condition variables (the pthread_cond_* family of functions) as semaphores (the sem_* family of functions) &#8230; but instead introducing bugs into their programs.The confusion is somewhat understandable. Given that condition variables have a wait() and a signal() function similar to the wait() and post()  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=4&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><font size="2">I&#8217;ve been running into some situations lately where developers have been using condition variables (the <code>pthread_cond_*</code> family of functions) as semaphores (the <code>sem_*</code> family of functions) &#8230; but instead introducing bugs into their programs.</font><font size="2">The confusion is somewhat understandable. Given that condition variables have a <code>wait()</code> and a <code>signal()</code> function similar to the <code>wait()</code> and <code>post()</code>  function available for semaphores, the two might seem interchangeable.</font><font size="2">Here is an example of a condvar being used improperly as a semaphore replacement:</p>
<pre>
 struct _data {
  pthread_mutex_t m;
  pthread_condvar_t c;
  ... other stuff ...
 };
void * writer_thread(void *arg) {
  struct _data *d = (struct _data *)arg;
  ...
  pthread_mutex_lock(&amp;d-&gt;m);
  pthread_cond_signal(&amp;d-&gt;c);
  pthread_mutex_unlock(&amp;d-&gt;m);
  ...
 }
void * reader_thread(void *arg) {
  struct _data *d = (struct _data *)arg;
  ...
  pthread_mutex_lock(&amp;d-&gt;m);
  pthread_cond_wait(&amp;d-&gt;c, &amp;d-&gt;m);
  pthread_mutex_unlock(&amp;d-&gt;m);
  ...
 }</pre>
<p></font></p>
<p><font size="2">The _intention_ here is that the writer_thread is signaling to the reader_thread that things are good and it can continue to operate. If this code were using <code>sem_post()/sem_wait()</code> the code would like operate as intended (assuming proper initialization values).</font><font size="2">However, imagine the following execution sequence (cause by context switches):</font><font size="2"></p>
<pre>
writer_thread:pthread_mutex_lock()
reader_thread:pthread_mutex_lock() <em>&gt; blocks (mutex held)</em>
writer_thread:pthread_cond_signal()
writer_thread:pthread_mutex_unlock()
reader_thread:pthread_cond_wait() <em>&gt; blocks waiting</em>
...</pre>
<p>In this case the writer thread had signaled the reader thread, but since the reader thread was not yet blocked, that signalling is lost. In the best case the writer_thread will have to wait a few extra cycles until the next reader_thread update or in the worst case the writer_thread may block forever if there are no further updates.</p>
<p>Condition variables are like semaphores on steroids. You can trigger off of much more sophisticated combinations of data, but at the cost of managing those triggers and that data yourself.</p>
<p>Assuming that we want our example to respond to every written request, and behave like a counting semaphore, then we should modify it as follows:</p>
<pre>
struct _data {
  pthread_mutex_t m;
  pthread_condvar_t c;
  <strong>int data;</strong>
  ... other stuff ...
};  

void * writer_thread(void *arg) {
  struct _data *d = (struct _data *)arg;
  ...
  pthread_mutex_lock(&amp;d-&gt;m);
  <strong>d-&gt;data++;</strong>
  pthread_cond_signal(&amp;d-&gt;c);
  pthread_mutex_unlock(&amp;d-&gt;m);
   ...
}  

void * reader_thread(void *arg) {
  struct _data *d = (struct _data *)arg;
  ...
  pthread_mutex_lock(&amp;d-&gt;m);
   <strong>while(d-&gt;data &lt;= 0) {
  pthread_cond_wait(&amp;d-&gt;c, &amp;d-&gt;m);
  }
  d-&gt;data--;</strong>
  pthread_mutex_unlock(&amp;d-&gt;m);
  ...
 }</pre>
<p>As you can see, the state data management is more manual, but is entirely within your control. In this case we are triggering on every data increment, but it can be easily adjusted to trigger on every fifth data increment instead.</p>
<pre>
void * reader_thread(void *arg) {
  ...
  while(d-&gt;data &lt;= 5) {
  pthread_cond_wait(&amp;d-&gt;c, &amp;d-&gt;m);
  }
  d-&gt;data -= 5;
  ...</pre>
<p>Code that uses a condvar in a lock/wait/unlock scenario without any intermediate condition testing being done around the wait should <em>always</em> be viewed with suspicion since chances are it was once a semaphore implementation that was switched to using condvars.</p>
<p> If you wanted to give this code a bit of an additional performance boost, you could also avoid the (little) <a target="_blank" href="http://catb.org/jargon/html/T/thundering-herd-problem.html" title="Thundering Herds">thundering herd problem</a> that is introduced here by moving the condvar signalling operation of the writer thread to occur outside of the mutex locked area.  This will save the reader thread from waking up from the condition variable, only to go mutex blocked until the mutex is given up.</p>
<p></font></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=4&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/03/13/4/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello World &#8230; blog version</title>
		<link>http://sendreceivereply.wordpress.com/2007/03/09/hello-world-blog-version/</link>
		<comments>http://sendreceivereply.wordpress.com/2007/03/09/hello-world-blog-version/#comments</comments>
		<pubDate>Fri, 09 Mar 2007 19:51:33 +0000</pubDate>
		<dc:creator>sendreceivereply</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sendreceivereply.wordpress.com/2007/03/09/hello-world-blog-version/</guid>
		<description><![CDATA[As is the tradition in programming, you always start with a Hello World program to get things going.  I&#8217;m assuming that this is no different in the blogging world. What we hope to be bringing you from this site in the coming weeks and months (years?) is the equivalent of the type of interesting QNX [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=3&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As is the tradition in programming, you always start with a <strong>Hello World</strong> program to get things going.  I&#8217;m assuming that this is no different in the blogging world.</p>
<p>What we hope to be bringing you from this site in the coming weeks and months (years?) is the equivalent of the type of interesting QNX development tidbits that old QNX users will remember from the days of QNX News and &#8220;<em>Ask Bruce</em>&#8221; columns. </p>
<p>As someone who interacts with QNX customer systems more often than not in an debugging and analysis capacity I hope to be able to share lots of great &#8220;lessons from the trenches&#8221; that will make your programs faster and your development life more pain free!</p>
<p> Thomas</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sendreceivereply.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sendreceivereply.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sendreceivereply.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sendreceivereply.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sendreceivereply.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sendreceivereply.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sendreceivereply.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sendreceivereply.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sendreceivereply.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sendreceivereply.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sendreceivereply.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sendreceivereply.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sendreceivereply.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sendreceivereply.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sendreceivereply.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sendreceivereply.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sendreceivereply.wordpress.com&amp;blog=858631&amp;post=3&amp;subd=sendreceivereply&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sendreceivereply.wordpress.com/2007/03/09/hello-world-blog-version/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/613ac34275e35ad5ad8344941d9d565d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sendreceivereply</media:title>
		</media:content>
	</item>
	</channel>
</rss>
