<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Neil Dickson's Blog &#187; PwnOS</title>
	<atom:link href="http://ndickson.wordpress.com/category/pwnos/feed/" rel="self" type="application/rss+xml" />
	<link>http://ndickson.wordpress.com</link>
	<description>Inventor IDE, PwnOS, and most everything else I'm up to</description>
	<lastBuildDate>Sat, 26 Sep 2009 06:04:48 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='ndickson.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/39425d5e6fd805e583ea209d05d9fdf7?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Neil Dickson's Blog &#187; PwnOS</title>
		<link>http://ndickson.wordpress.com</link>
	</image>
			<item>
		<title>PwnOS: First Successful Output</title>
		<link>http://ndickson.wordpress.com/2009/06/07/pwnos-first-successful-output/</link>
		<comments>http://ndickson.wordpress.com/2009/06/07/pwnos-first-successful-output/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 21:40:55 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Carleton]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PwnOS]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=148</guid>
		<description><![CDATA[This may seem like a small accomplishment to many, but I now have PwnOS boot code that takes one CPU core from 16-bit mode to 32-bit mode to 64-bit mode using code developed and assembled/linked with Inventor IDE.  Until now, so far as I&#8217;ve been able to find, no linker has supported 16-bit, 32-bit, and 64-bit code smoothly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=148&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This may seem like a small accomplishment to many, but I now have PwnOS boot code that takes one CPU core from 16-bit mode to 32-bit mode to 64-bit mode using code developed and assembled/linked with <a href="http://www.codecortex.com/ide/">Inventor IDE</a>.  Until now, so far as I&#8217;ve been able to find, no linker has supported 16-bit, 32-bit, and 64-bit code smoothly linked together in one output file.  If that&#8217;s the case, Inventor IDE is the first linker to support this, and it makes developing an operating system bootloader an absolute breeze compared with the alternative, which is to:</p>
<ol>
<li>The 16-bit Master Boot Record (MBR) or Boot Sector (BS) loads the rest of the 16-bit bootloader.</li>
<li>The 16-bit bootloader finds and reads in a file on the drive containing the 32-bit bootloader with an entry point at a hard-coded address.</li>
<li>Switch to 32-bit mode and jump to the hard-coded address.</li>
<li>The 32-bit bootloader finds and reads in a file on the drive containing the 64-bit bootloader with an entry point at a hard-coded address.</li>
<li>Switch to 64-bit mode and jump to the hard-coded address.</li>
<li>The 64-bit bootloader actually starts loading the OS after starting the other CPU cores.</li>
</ol>
<p>Now it&#8217;s as simple as:</p>
<ol>
<li>The 16-bit Master Boot Record (MBR) or Boot Sector (BS) load the entire rest of the bootloader.</li>
<li>Switch to 32-bit mode and jump to the 32-bit starting function (address determined automatically by the linker)</li>
<li>Switch to 64-bit mode and jump to the 64-bit starting function (ditto)</li>
<li>The 64-bit function actually starts loading the OS after starting the other CPU cores.</li>
</ol>
<p>Eliminating the need to find and read in files from a filesystem reduces the size and complexity of the code many-fold.  Plus, now the entire OS should easily fit in the 30KB of disk space I&#8217;ve got for the bootloader, so that first step will load the entire OS from the drive.  I would show a screenshot or photo, but it doesn&#8217;t write to the harddrive yet (it&#8217;s probably for the best), and I don&#8217;t have a working camera anymore.  Nonetheless, here&#8217;s roughly (just in a different font) what was output:</p>
<div id="attachment_149" class="wp-caption aligncenter" style="width: 507px"><a href="http://ndickson.files.wordpress.com/2009/06/firstsuccessfuloutput.png"><img class="size-full wp-image-149" title="FirstSuccessfulOutput" src="http://ndickson.files.wordpress.com/2009/06/firstsuccessfuloutput.png?w=497&#038;h=279" alt="Output showing the PwnOS bootloader switching from 16-bit mode to 32-bit mode to 64-bit mode" width="497" height="279" /></a><p class="wp-caption-text">Output showing the PwnOS bootloader switching from 16-bit mode to 32-bit mode to 64-bit mode</p></div>
<p>There have been similar linkers for just 16-bit and 32-bit code, most notably <a href="http://wiki.osdev.org/JLoc">JLOC</a>.  I would link to the original site, but the site vanished many years ago, which explains why there&#8217;s no support for 64-bit code.  There&#8217;s also the standard linker for linux, <a href="http://wiki.osdev.org/LD">LD</a>.  Although it supports 64-bit code and has extensive scripting options, I can&#8217;t seem to find any evidence that it can link code of different modes together, not to mention that I&#8217;d still need to have a custom assembler to output data to some format it supports that keeps the necessary information.  Also, if LD supported this, linux could get to 64-bit mode in less than 1KB of code, and that certainly isn&#8217;t the case right now.</p>
<p>Hopefully other people will be up for trying this out with Inventor IDE Alpha 5b once it&#8217;s out (just the settings dialog box left).  Anyway, I&#8217;ve written some code for more extensive debugging that I&#8217;m anxious to test out, and I still need to get the other CPU cores up and running, but that should be much easier now.  <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=148&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/06/07/pwnos-first-successful-output/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>

		<media:content url="http://ndickson.files.wordpress.com/2009/06/firstsuccessfuloutput.png" medium="image">
			<media:title type="html">FirstSuccessfulOutput</media:title>
		</media:content>
	</item>
		<item>
		<title>Building &#8220;Ensemble&#8221;</title>
		<link>http://ndickson.wordpress.com/2009/03/08/building-ensemble/</link>
		<comments>http://ndickson.wordpress.com/2009/03/08/building-ensemble/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 20:25:49 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PwnOS]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=115</guid>
		<description><![CDATA[Yesterday, several friends and I, especially Calvin, set up 4 computers I bought 68 days ago and received 4 days ago (moral of the story, DO NOT BUY FROM CANADACOMPUTERS!)  Here are the specs:

4 x Intel Core 2 Quad Q8200 2.33GHz
4 x 4GB of 667MHz RAM
4 x 160GB SATA harddrive
5-port Gigabit Ethernet Switch
$2000 after taxes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=115&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Yesterday, several friends and I, especially Calvin, set up 4 computers I bought 68 days ago and received 4 days ago (moral of the story, DO NOT BUY FROM CANADACOMPUTERS!)  Here are the specs:</p>
<ul>
<li>4 x Intel Core 2 Quad Q8200 2.33GHz</li>
<li>4 x 4GB of 667MHz RAM</li>
<li>4 x 160GB SATA harddrive</li>
<li>5-port Gigabit Ethernet Switch</li>
<li>$2000 after taxes and shipping</li>
</ul>
<p>At the recommendation of my friend Ben, I&#8217;m naming the small cluster &#8220;Ensemble&#8221;, a reference to <a href="http://www.amazon.com/Quarantine-Greg-Egan/dp/0061054232/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1236535575&amp;sr=8-1">Quarantine by Greg Egan</a>.  As a further reference to <a href="http://en.wikipedia.org/wiki/Quarantine_(novel)">Quarantine</a>, and to <a href="http://www.dwavesys.com/">D-Wave</a>, I&#8217;ve named the 4 nodes <a href="http://en.wikipedia.org/wiki/Pauli_matrices">&#8220;identity&#8221;, &#8220;sigma-x&#8221;, &#8220;sigma-y&#8221;, &#8220;sigma-z&#8221;</a>.</p>
<p>With these, and with <a href="http://ndickson.wordpress.com/2009/03/04/preview-of-inventor-ide-alpha-5/">Inventor IDE Alpha 5</a>, I can finally start building PwnOS after months of delays.  It will be awesome to have 16 CPU cores and 16 GB of RAM at my disposal.  <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=115&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2009/03/08/building-ensemble/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>Working Alone Sucks</title>
		<link>http://ndickson.wordpress.com/2008/10/26/working-alone-sucks/</link>
		<comments>http://ndickson.wordpress.com/2008/10/26/working-alone-sucks/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 21:44:49 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PwnIDE]]></category>
		<category><![CDATA[PwnOS]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/?p=59</guid>
		<description><![CDATA[That&#8217;s an exaggeration, of course, but what I&#8217;m really trying to say is that working alone on a project for an extended period of time really sucks the life out of me.  With my busy schedule this term, I&#8217;m finding it really hard to find time to work on Inventor IDE.  Next term I&#8217;ll be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=59&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>That&#8217;s an exaggeration, of course, but what I&#8217;m really trying to say is that working alone on a project for an extended period of time really sucks the life out of me.  With my busy schedule this term, I&#8217;m finding it really hard to find time to work on Inventor IDE.  Next term I&#8217;ll be working on it as part of a directed study, and I do have a hard deadline of the end of 2008 for getting built-in assembling fully functional, but progress has been slow.</p>
<p>I got asked about teamwork in an interview with Microsoft&#8217;s Photosynth group, so that got me really thinking about team dynamics.  At the very least, on any sizable project, having someone else to bounce ideas off of is a must.  Since for assignments 1 and 2, the professor of the course I&#8217;m helping with hasn&#8217;t posted my alternate assignments, until I get built-in assembling working and start posting about it widely, I won&#8217;t even have many users off of which  to bounce ideas about Inventor IDE.</p>
<p>Beyond that, assuming there&#8217;s an actual team, there must be some sort of division of labour such that what needs to get done gets done without losing the members.  I&#8217;ve started organizing the team for the next big Code Cortex project, codenamed PwnOS, and it&#8217;s interesting trying to figure out how to split up the work and to keep people interested.  Conveniently, the team came up with a great idea: each person investigates a device protocol and goes through developing support for that device.  It works perfectly, since getting a device to work is one of the really satisfying parts of OS development, and it only depends on having as much of a bootloader as I&#8217;ve already got.  I can then focus on getting some of the other parts of the OS up and running without everyone waiting for me.</p>
<p>Other good news includes that I&#8217;ve found someone quite eager to get a third (unnamed) project off the ground, and I may have found another person to help with Inventor IDE next term.  It&#8217;ll take lots of work to get things going, but I&#8217;m optimistic that we can find a way to make things work, together.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=59&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2008/10/26/working-alone-sucks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>PwnOS Design Document</title>
		<link>http://ndickson.wordpress.com/2007/12/14/pwnos-design-document/</link>
		<comments>http://ndickson.wordpress.com/2007/12/14/pwnos-design-document/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 07:10:59 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[PwnOS]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/2007/12/14/pwnos-design-document/</guid>
		<description><![CDATA[I&#8217;ve now completed the first version of the PwnOS design document.  Development can move forward now that the design has been fairly well cemented.
The design in the document does not reflect the current state of the code.  Significant differences include that the design is to be for 64-bit code, not 32-bit, and page memory will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=31&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve now completed the first version of the <a href="http://www.neildickson.com/os/downloads/PwnOS.docx">PwnOS design document</a>.  Development can move forward now that the design has been fairly well cemented.</p>
<p>The design in the document does not reflect the current state of the code.  Significant differences include that the design is to be for 64-bit code, not 32-bit, and page memory will be managed in 2MB pages by disabling the lowest level of page tables instead of 64KB simulated pages made by handling real pages in groups of 16.  Also, there will be a large, read-only area devoted to libraries common to all processes.</p>
<p>Also included in the document are a brief analysis of high-performance computing and a comparison with other operating systems.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ndickson.wordpress.com/31/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ndickson.wordpress.com/31/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=31&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2007/12/14/pwnos-design-document/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>Not-Really-Interview Questions</title>
		<link>http://ndickson.wordpress.com/2007/10/19/not-really-interview-questions/</link>
		<comments>http://ndickson.wordpress.com/2007/10/19/not-really-interview-questions/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 05:27:18 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Jobs]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PwnOS]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/2007/10/19/not-really-interview-questions/</guid>
		<description><![CDATA[After being informed by a third party that RIM probably prefers to keep interview questions private, (okay, so it was actually much less polite than that, but I won&#8217;t hold that against anyone), I&#8217;ve decided to post about two questions other than those in my interview, but with slightly similar components to how I answered [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=25&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>After being informed by a third party that RIM probably prefers to keep interview questions private, (okay, so it was actually much less polite than that, but I won&#8217;t hold that against anyone), I&#8217;ve decided to post about two questions other than those in my interview, but with slightly similar components to how I answered the otherwise-unrelated questions in my RIM interviews.  I haven&#8217;t checked whether these answers would compile, since I wouldn&#8217;t be able to in an interview.</p>
<p>Question: Write a C function to select <em>k</em> random elements in a random order from a set of <em>n</em> pointers in O(<em>k</em>) time.  The original set can be reordered.</p>
<pre>void** selectRandom(void** pSet,DWORD n,DWORD k) {
    // Create the array to be returned, null-terminated
    void** pSelected = (void**)malloc((k+1)*sizeof(void*));
    pSelected[k] = NULL;
    DWORD selectedIndex = 0;
    // Select elements until no more needed
    while (k--) {
        DWORD index = (DWORD)((rand()*((QWORD)n))&gt;&gt;32);	// This is more uniform and faster than using modulus
        void*const element = pSet[index];		// Select the edge from the list
        pSet[index] = pSet[--n];			// Remove it by replacing with the last element
        pSelected[selectedIndex++] = element;
    }
    return pSelected;
}</pre>
<p>Question: Write a C function to sort an array of floats (i.e. 4-byte floating-point numbers in the appropriate IEEE format) in O(<em>n</em>) time, where <em>n</em> is the number of floats in the array.</p>
<p>The answer needs a bit of explanation first.  Positive floating-point numbers when interpreted as integers are in the same numerical order in both cases.  e.g. 2.0 &gt; 1.0 and the integer interpretation of 2.0 is greater than the integer interpretation of 1.0.  Negative floating-point numbers when interpreted as integers are in the opposite numerical order.  e.g. -2.0 &lt; -1.0, but the integer interpretation of -2.0 is less than the integer interpretation of -1.0.  Mixed sets of negative and positive numbers results in other special cases.  What would be ideal is a constant-time bijective mapping from a floating-point number to an unsigned integer that will maintain perfect ordering through positive and negative numbers.  It can be shown that there is exactly one such mapping, and it is simple enough to be constant time.</p>
<p>The mapping is: take the bitwise not of negative numbers, and flip the sign bit of positive numbers.  After applying this to all numbers in the array, one can use 4-pass, base-256 radix sort on the numbers as unsigned 32-bit integers, then use the reverse mapping back to floating-point numbers.  This works with 6 passes through the array.  There is a way to do the full thing with 4 passes through the array, but it&#8217;s unsure which would be faster.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ndickson.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ndickson.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=25&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2007/10/19/not-really-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>Auto-complete Complete (Mostly)</title>
		<link>http://ndickson.wordpress.com/2007/10/07/auto-complete-complete-mostly/</link>
		<comments>http://ndickson.wordpress.com/2007/10/07/auto-complete-complete-mostly/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 07:14:09 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[PwnIDE]]></category>
		<category><![CDATA[PwnOS]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/2007/10/07/auto-complete-complete-mostly/</guid>
		<description><![CDATA[Context-sensitive auto-complete now works for some contexts.  Contexts that it doesn&#8217;t handle yet will just give you an apology message, since I&#8217;m leaving it at that for the Alpha.  It&#8217;s also not as flashy as I&#8217;m hoping to have it for the Beta, but it&#8217;s plenty sufficient for the Alpha.
I&#8217;m going to have to take [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=23&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Context-sensitive auto-complete now works for some contexts.  Contexts that it doesn&#8217;t handle yet will just give you an apology message, since I&#8217;m leaving it at that for the Alpha.  It&#8217;s also not as flashy as I&#8217;m hoping to have it for the Beta, but it&#8217;s plenty sufficient for the Alpha.</p>
<p>I&#8217;m going to have to take a small break from PwnIDE to work on PwnOS if I&#8217;m planning to use PwnOS for my Operating Systems class project, &#8217;cause PwnOS needs a lot more work to get anything up and running.  However, the first draft of the paper on PwnIDE is due at the end of October, so it&#8217;ll still be in my mind.  The remaining functionality for PwnIDE Alpha is mostly fixing loose ends, whereas the remaining functionality for PwnOS is a lot.  I&#8217;ll make it all work somehow.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ndickson.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ndickson.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=23&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2007/10/07/auto-complete-complete-mostly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>
	</item>
		<item>
		<title>PwnOS Test Interface</title>
		<link>http://ndickson.wordpress.com/2007/05/31/pwnos-test-interface/</link>
		<comments>http://ndickson.wordpress.com/2007/05/31/pwnos-test-interface/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 03:54:46 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[PwnOS]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/2007/05/31/pwnos-test-interface/</guid>
		<description><![CDATA[It may seem a bit premature to be writing a user interface for PwnOS before it&#8217;s fully functional, but thanks to a simple wrapper library I&#8217;ve written, it&#8217;s now fairly simple to make and test PwnOS interface applications under Windows.
The rudimentary interface application I&#8217;ve written (mostly an interface library)  is completely in C++, in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=17&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It may seem a bit premature to be writing a user interface for PwnOS before it&#8217;s fully functional, but thanks to a simple wrapper library I&#8217;ve written, it&#8217;s now fairly simple to make and test PwnOS interface applications under Windows.</p>
<p>The rudimentary interface application I&#8217;ve written (mostly an interface library)  is completely in C++, in case anyone was wondering whether you&#8217;d be able to make applications for PwnOS in something other than assembly language.  I&#8217;m considering making a more formal interface library out of it so that:</p>
<ol>
<li>It&#8217;ll be worth putting in the (or a new) repository, and</li>
<li>Other interfaces and applications will be able to use the same interface library</li>
</ol>
<p>Here&#8217;s a screenshot of the current test interface:</p>
<p><img src="http://www.neildickson.com/os/screenshots/TestUIScreenshot.png" alt="Test UI Screenshot" height="384" width="512" /></p>
<p>Everything in this is simulated, including the cursor.  When running in Windows, the program &#8220;thinks&#8221; that it&#8217;s writing to video memory, when really there&#8217;s a full-screen window reading that chunk of memory and writing it to the window 20 times a second.  One of the funny things with that is that it&#8217;d be quite simple to instead take that chunk of memory and apply it to something like a cube, for Beryl fans.</p>
<p>The button will show 4 different images, one each for up, hover, down, and disabled.  The cursor image is decoded from a GIF file, though there&#8217;s still a bug decoding GIF files that are much larger, so the background and button images are bitmaps.</p>
<p>I&#8217;m more focused on PwnIDE than on PwnOS at the moment, but I&#8217;ll try to figure out what to do with this interface library in case anyone&#8217;s interested in writing interface or other applications for PwnOS.  The classes are quite reminiscent of Java&#8217;s interface API, so it shouldn&#8217;t be to hard to use and expand.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ndickson.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ndickson.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=17&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2007/05/31/pwnos-test-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>

		<media:content url="http://www.neildickson.com/os/screenshots/TestUIScreenshot.png" medium="image">
			<media:title type="html">Test UI Screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>Blog-tastic!</title>
		<link>http://ndickson.wordpress.com/2007/05/30/blog-tastic/</link>
		<comments>http://ndickson.wordpress.com/2007/05/30/blog-tastic/#comments</comments>
		<pubDate>Thu, 31 May 2007 04:54:54 +0000</pubDate>
		<dc:creator>Neil Dickson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PwnIDE]]></category>
		<category><![CDATA[PwnOS]]></category>

		<guid isPermaLink="false">http://ndickson.wordpress.com/2007/05/30/blog-tastic/</guid>
		<description><![CDATA[This blog now updates through wordpress.com, so people can actually post comments.   It also means that it&#8217;ll be easier to update, and that I can separate entries into categories for the front, PwnOS, and PwnIDE pages.  Now I&#8217;ll be able to give updates on each of the projects more often, and people can subscribe [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=16&subd=ndickson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This blog now updates through wordpress.com, so people can actually post comments. <img src="http://www.neildickson.com/smile.gif" alt="Smile" height="17" width="17" />  It also means that it&#8217;ll be easier to update, and that I can separate entries into categories for the <a href="http://www.neildickson.com/#blog">front</a>, <a href="http://www.neildickson.com/os/#blog">PwnOS</a>, and <a href="http://www.neildickson.com/ide/#blog">PwnIDE</a> pages.  Now I&#8217;ll be able to give updates on each of the projects more often, and people can subscribe to one or more of them without subscribing to all of them.</p>
<p>There&#8217;s still a bug that I might not be able to fix any time soon, which is that when you post a comment, you&#8217;ll be redirected to the blog on wordpress.com instead of back here.  The issue is that the SCS web server doesn&#8217;t have the HTTP extension to PHP installed, so I can&#8217;t make POST requests to wordpress.com.  Hopefully that&#8217;s not too much of an issue.  The only other thing is that the dates on older blog entries were lost, so I put them in the message text.</p>
<p>Overall, this should be really handy.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ndickson.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ndickson.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndickson.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndickson.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndickson.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndickson.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndickson.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndickson.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndickson.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndickson.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndickson.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndickson.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndickson.wordpress.com&blog=1158540&post=16&subd=ndickson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ndickson.wordpress.com/2007/05/30/blog-tastic/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/accf49d59449b71b817ca3c4f2c739f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Neil Dickson</media:title>
		</media:content>

		<media:content url="http://www.neildickson.com/smile.gif" medium="image">
			<media:title type="html">Smile</media:title>
		</media:content>
	</item>
	</channel>
</rss>